@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | try { |
| 28 | 28 | $sth = $this->db->prepare($query); |
| 29 | 29 | $sth->execute($query_values); |
| 30 | - } catch(PDOException $e) { |
|
| 30 | + } catch (PDOException $e) { |
|
| 31 | 31 | return "error : ".$e->getMessage(); |
| 32 | 32 | } |
| 33 | 33 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | try { |
| 41 | 41 | $sth = $this->db->prepare($query); |
| 42 | 42 | $sth->execute($query_values); |
| 43 | - } catch(PDOException $e) { |
|
| 43 | + } catch (PDOException $e) { |
|
| 44 | 44 | return "error : ".$e->getMessage(); |
| 45 | 45 | } |
| 46 | 46 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 47 | 47 | return $all; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getLocationInfobyNameType($name,$type) { |
|
| 50 | + public function getLocationInfobyNameType($name, $type) { |
|
| 51 | 51 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
| 52 | - $query_values = array(':name' => $name,':type' => $type); |
|
| 52 | + $query_values = array(':name' => $name, ':type' => $type); |
|
| 53 | 53 | try { |
| 54 | 54 | $sth = $this->db->prepare($query); |
| 55 | 55 | $sth->execute($query_values); |
| 56 | - } catch(PDOException $e) { |
|
| 56 | + } catch (PDOException $e) { |
|
| 57 | 57 | return "error : ".$e->getMessage(); |
| 58 | 58 | } |
| 59 | 59 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $sth = $this->db->prepare($query); |
| 72 | 72 | $sth->execute($query_values); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | echo "error : ".$e->getMessage(); |
| 75 | 75 | return array(); |
| 76 | 76 | } |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | public function getLocationInfoByType($type, $coord = array(), $limit = false) { |
| 82 | 82 | $query = "SELECT * FROM source_location WHERE type = :type"; |
| 83 | 83 | if (is_array($coord) && !empty($coord) && count($coord) == 4) { |
| 84 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 85 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 86 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 87 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 84 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 85 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 86 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 87 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 88 | 88 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
| 89 | 89 | } |
| 90 | 90 | $query .= " ORDER BY last_seen DESC"; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | try { |
| 94 | 94 | $sth = $this->db->prepare($query); |
| 95 | 95 | $sth->execute($query_values); |
| 96 | - } catch(PDOException $e) { |
|
| 96 | + } catch (PDOException $e) { |
|
| 97 | 97 | return "error : ".$e->getMessage(); |
| 98 | 98 | } |
| 99 | 99 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -119,58 +119,58 @@ discard block |
||
| 119 | 119 | try { |
| 120 | 120 | $sth = $this->db->prepare($query); |
| 121 | 121 | $sth->execute($query_values); |
| 122 | - } catch(PDOException $e) { |
|
| 122 | + } catch (PDOException $e) { |
|
| 123 | 123 | return "error : ".$e->getMessage(); |
| 124 | 124 | } |
| 125 | 125 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 126 | 126 | return $all; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
| 129 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 130 | 130 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 131 | 131 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
| 132 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 132 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 133 | 133 | try { |
| 134 | 134 | $sth = $this->db->prepare($query); |
| 135 | 135 | $sth->execute($query_values); |
| 136 | - } catch(PDOException $e) { |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | echo "error : ".$e->getMessage(); |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
| 141 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
| 142 | 142 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 143 | 143 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
| 144 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 144 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 145 | 145 | try { |
| 146 | 146 | $sth = $this->db->prepare($query); |
| 147 | 147 | $sth->execute($query_values); |
| 148 | - } catch(PDOException $e) { |
|
| 148 | + } catch (PDOException $e) { |
|
| 149 | 149 | return "error : ".$e->getMessage(); |
| 150 | 150 | } |
| 151 | 151 | return ''; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
| 154 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
| 155 | 155 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
| 156 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
| 156 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | 159 | $sth->execute($query_values); |
| 160 | - } catch(PDOException $e) { |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | return "error : ".$e->getMessage(); |
| 162 | 162 | } |
| 163 | 163 | return ''; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
| 166 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
| 167 | 167 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
| 168 | 168 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
| 169 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
| 169 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
| 170 | 170 | try { |
| 171 | 171 | $sth = $this->db->prepare($query); |
| 172 | 172 | $sth->execute($query_values); |
| 173 | - } catch(PDOException $e) { |
|
| 173 | + } catch (PDOException $e) { |
|
| 174 | 174 | echo "error : ".$e->getMessage(); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | try { |
| 182 | 182 | $sth = $this->db->prepare($query); |
| 183 | 183 | $sth->execute($query_values); |
| 184 | - } catch(PDOException $e) { |
|
| 184 | + } catch (PDOException $e) { |
|
| 185 | 185 | return "error : ".$e->getMessage(); |
| 186 | 186 | } |
| 187 | 187 | return ''; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | $sth = $this->db->prepare($query); |
| 195 | 195 | $sth->execute($query_values); |
| 196 | - } catch(PDOException $e) { |
|
| 196 | + } catch (PDOException $e) { |
|
| 197 | 197 | return "error : ".$e->getMessage(); |
| 198 | 198 | } |
| 199 | 199 | return ''; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | try { |
| 206 | 206 | $sth = $this->db->prepare($query); |
| 207 | 207 | $sth->execute($query_values); |
| 208 | - } catch(PDOException $e) { |
|
| 208 | + } catch (PDOException $e) { |
|
| 209 | 209 | return "error : ".$e->getMessage(); |
| 210 | 210 | } |
| 211 | 211 | return ''; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | try { |
| 217 | 217 | $sth = $this->db->prepare($query); |
| 218 | 218 | $sth->execute(); |
| 219 | - } catch(PDOException $e) { |
|
| 219 | + } catch (PDOException $e) { |
|
| 220 | 220 | return "error : ".$e->getMessage(); |
| 221 | 221 | } |
| 222 | 222 | return ''; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | try { |
| 247 | 247 | $sth = $this->db->prepare($query); |
| 248 | 248 | $sth->execute(array(':type' => $type)); |
| 249 | - } catch(PDOException $e) { |
|
| 249 | + } catch (PDOException $e) { |
|
| 250 | 250 | return "error"; |
| 251 | 251 | } |
| 252 | 252 | return "success"; |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | if ($this->db === null) die('Error: No DB connection. (Stats)'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function addLastStatsUpdate($type,$stats_date) { |
|
| 31 | + public function addLastStatsUpdate($type, $stats_date) { |
|
| 32 | 32 | $query = "DELETE FROM config WHERE name = :type; |
| 33 | 33 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
| 34 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
| 34 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
| 35 | 35 | try { |
| 36 | 36 | $sth = $this->db->prepare($query); |
| 37 | 37 | $sth->execute($query_values); |
| 38 | - } catch(PDOException $e) { |
|
| 38 | + } catch (PDOException $e) { |
|
| 39 | 39 | return "error : ".$e->getMessage(); |
| 40 | 40 | } |
| 41 | 41 | return ''; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | try { |
| 47 | 47 | $sth = $this->db->prepare($query); |
| 48 | 48 | $sth->execute(array(':type' => $type)); |
| 49 | - } catch(PDOException $e) { |
|
| 49 | + } catch (PDOException $e) { |
|
| 50 | 50 | echo "error : ".$e->getMessage(); |
| 51 | 51 | return array(); |
| 52 | 52 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | try { |
| 69 | 69 | $sth = $this->db->prepare($query); |
| 70 | 70 | $sth->execute(array(':filter_name' => $filter_name)); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error : ".$e->getMessage(); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute(); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $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;"; |
| 88 | 88 | try { |
| 89 | 89 | $sth = $this->db->prepare($query); |
| 90 | 90 | $sth->execute(array(':filter_name' => $filter_name)); |
| 91 | - } catch(PDOException $e) { |
|
| 91 | + } catch (PDOException $e) { |
|
| 92 | 92 | return "error : ".$e->getMessage(); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -100,77 +100,77 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | $sth = $this->db->prepare($query); |
| 102 | 102 | $sth->execute(array(':filter_name' => $filter_name)); |
| 103 | - } catch(PDOException $e) { |
|
| 103 | + } catch (PDOException $e) { |
|
| 104 | 104 | echo "error : ".$e->getMessage(); |
| 105 | 105 | } |
| 106 | 106 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 107 | 107 | if (empty($all)) { |
| 108 | 108 | $filters = array(); |
| 109 | 109 | if ($filter_name != '') { |
| 110 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 110 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 111 | 111 | } |
| 112 | 112 | $Spotter = new Spotter($this->db); |
| 113 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
| 113 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
| 114 | 114 | } |
| 115 | 115 | return $all; |
| 116 | 116 | } |
| 117 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
| 117 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
| 118 | 118 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 119 | 119 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 120 | 120 | try { |
| 121 | 121 | $sth = $this->db->prepare($query); |
| 122 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 123 | - } catch(PDOException $e) { |
|
| 122 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 123 | + } catch (PDOException $e) { |
|
| 124 | 124 | echo "error : ".$e->getMessage(); |
| 125 | 125 | } |
| 126 | 126 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 127 | 127 | return $all; |
| 128 | 128 | } |
| 129 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
| 129 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
| 130 | 130 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 131 | 131 | $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"; |
| 132 | 132 | try { |
| 133 | 133 | $sth = $this->db->prepare($query); |
| 134 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 135 | - } catch(PDOException $e) { |
|
| 134 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 135 | + } catch (PDOException $e) { |
|
| 136 | 136 | echo "error : ".$e->getMessage(); |
| 137 | 137 | } |
| 138 | 138 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 139 | 139 | return $all; |
| 140 | 140 | } |
| 141 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
| 141 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
| 142 | 142 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 143 | 143 | $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"; |
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 147 | - } catch(PDOException $e) { |
|
| 146 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 147 | + } catch (PDOException $e) { |
|
| 148 | 148 | echo "error : ".$e->getMessage(); |
| 149 | 149 | } |
| 150 | 150 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 151 | 151 | return $all; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
| 154 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
| 155 | 155 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 156 | 156 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 160 | - } catch(PDOException $e) { |
|
| 159 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | echo "error : ".$e->getMessage(); |
| 162 | 162 | } |
| 163 | 163 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 164 | 164 | return $all; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
| 167 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
| 168 | 168 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 169 | 169 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 170 | 170 | try { |
| 171 | 171 | $sth = $this->db->prepare($query); |
| 172 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 173 | - } catch(PDOException $e) { |
|
| 172 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 173 | + } catch (PDOException $e) { |
|
| 174 | 174 | echo "error : ".$e->getMessage(); |
| 175 | 175 | } |
| 176 | 176 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -178,23 +178,23 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 181 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 182 | 182 | global $globalStatsFilters; |
| 183 | 183 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 184 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 184 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 185 | 185 | $Spotter = new Spotter($this->db); |
| 186 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 186 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 187 | 187 | $alliance_airlines = array(); |
| 188 | 188 | foreach ($airlines as $airline) { |
| 189 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 189 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 190 | 190 | } |
| 191 | 191 | if ($year == '' && $month == '') { |
| 192 | - 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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 193 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 192 | + 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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 193 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 194 | 194 | try { |
| 195 | 195 | $sth = $this->db->prepare($query); |
| 196 | 196 | $sth->execute(array(':filter_name' => $filter_name)); |
| 197 | - } catch(PDOException $e) { |
|
| 197 | + } catch (PDOException $e) { |
|
| 198 | 198 | echo "error : ".$e->getMessage(); |
| 199 | 199 | } |
| 200 | 200 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -205,29 +205,29 @@ discard block |
||
| 205 | 205 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
| 206 | 206 | try { |
| 207 | 207 | $sth = $this->db->prepare($query); |
| 208 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 209 | - } catch(PDOException $e) { |
|
| 208 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 209 | + } catch (PDOException $e) { |
|
| 210 | 210 | echo "error : ".$e->getMessage(); |
| 211 | 211 | } |
| 212 | 212 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 213 | 213 | } else $all = array(); |
| 214 | 214 | } |
| 215 | 215 | if (empty($all)) { |
| 216 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 217 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 216 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 217 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 218 | 218 | } else { |
| 219 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 219 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 220 | 220 | } |
| 221 | 221 | if ($filter_name != '') { |
| 222 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 222 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 223 | 223 | } |
| 224 | 224 | $Spotter = new Spotter($this->db); |
| 225 | 225 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 226 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 226 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
| 227 | 227 | } |
| 228 | 228 | return $all; |
| 229 | 229 | } |
| 230 | - public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
|
| 230 | + public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 231 | 231 | global $globalStatsFilters, $globalVM; |
| 232 | 232 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 233 | 233 | if ($year == '' && $month == '' && (!isset($globalVM) || $globalVM === FALSE)) { |
@@ -236,23 +236,23 @@ discard block |
||
| 236 | 236 | try { |
| 237 | 237 | $sth = $this->db->prepare($query); |
| 238 | 238 | $sth->execute(array(':filter_name' => $filter_name)); |
| 239 | - } catch(PDOException $e) { |
|
| 239 | + } catch (PDOException $e) { |
|
| 240 | 240 | echo "error : ".$e->getMessage(); |
| 241 | 241 | } |
| 242 | 242 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 243 | 243 | } else $all = array(); |
| 244 | 244 | if (empty($all)) { |
| 245 | - $filters = array('year' => $year,'month' => $month); |
|
| 245 | + $filters = array('year' => $year, 'month' => $month); |
|
| 246 | 246 | if ($filter_name != '') { |
| 247 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 247 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 248 | 248 | } |
| 249 | 249 | $Marine = new Marine($this->db); |
| 250 | 250 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 251 | - $all = $Marine->countAllMarineTypes($limit,0,'',$filters); |
|
| 251 | + $all = $Marine->countAllMarineTypes($limit, 0, '', $filters); |
|
| 252 | 252 | } |
| 253 | 253 | return $all; |
| 254 | 254 | } |
| 255 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 255 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 256 | 256 | global $globalStatsFilters; |
| 257 | 257 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 258 | 258 | if ($year == '' && $month == '') { |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | try { |
| 262 | 262 | $sth = $this->db->prepare($query); |
| 263 | 263 | $sth->execute(array(':filter_name' => $filter_name)); |
| 264 | - } catch(PDOException $e) { |
|
| 264 | + } catch (PDOException $e) { |
|
| 265 | 265 | echo "error : ".$e->getMessage(); |
| 266 | 266 | } |
| 267 | 267 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -269,32 +269,32 @@ discard block |
||
| 269 | 269 | if (empty($all)) { |
| 270 | 270 | $Spotter = new Spotter($this->db); |
| 271 | 271 | $filters = array(); |
| 272 | - $filters = array('year' => $year,'month' => $month); |
|
| 272 | + $filters = array('year' => $year, 'month' => $month); |
|
| 273 | 273 | if ($filter_name != '') { |
| 274 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 274 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 275 | 275 | } |
| 276 | 276 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
| 277 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 277 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
| 278 | 278 | } |
| 279 | 279 | return $all; |
| 280 | 280 | } |
| 281 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 281 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 282 | 282 | global $globalStatsFilters; |
| 283 | 283 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 284 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 284 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 285 | 285 | $Spotter = new Spotter($this->db); |
| 286 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 286 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 287 | 287 | $alliance_airlines = array(); |
| 288 | 288 | foreach ($airlines as $airline) { |
| 289 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 289 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 290 | 290 | } |
| 291 | 291 | if ($year == '' && $month == '') { |
| 292 | - 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"; |
|
| 293 | - 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"; |
|
| 292 | + 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"; |
|
| 293 | + 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"; |
|
| 294 | 294 | try { |
| 295 | 295 | $sth = $this->db->prepare($query); |
| 296 | 296 | $sth->execute(array(':filter_name' => $filter_name)); |
| 297 | - } catch(PDOException $e) { |
|
| 297 | + } catch (PDOException $e) { |
|
| 298 | 298 | echo "error : ".$e->getMessage(); |
| 299 | 299 | } |
| 300 | 300 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -305,21 +305,21 @@ discard block |
||
| 305 | 305 | 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"; |
| 306 | 306 | try { |
| 307 | 307 | $sth = $this->db->prepare($query); |
| 308 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 309 | - } catch(PDOException $e) { |
|
| 308 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 309 | + } catch (PDOException $e) { |
|
| 310 | 310 | echo "error : ".$e->getMessage(); |
| 311 | 311 | } |
| 312 | 312 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 313 | 313 | } else $all = array(); |
| 314 | 314 | } |
| 315 | 315 | if (empty($all)) { |
| 316 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 317 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 316 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 317 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 318 | 318 | } else { |
| 319 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 319 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 320 | 320 | } |
| 321 | 321 | if ($filter_name != '') { |
| 322 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 322 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 323 | 323 | } |
| 324 | 324 | $Spotter = new Spotter($this->db); |
| 325 | 325 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -328,23 +328,23 @@ discard block |
||
| 328 | 328 | return $all; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 331 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 332 | 332 | global $globalStatsFilters; |
| 333 | 333 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 334 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 334 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 335 | 335 | $Spotter = new Spotter($this->db); |
| 336 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 336 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 337 | 337 | $alliance_airlines = array(); |
| 338 | 338 | foreach ($airlines as $airline) { |
| 339 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 339 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 340 | 340 | } |
| 341 | 341 | if ($year == '' && $month == '') { |
| 342 | - 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"; |
|
| 343 | - 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"; |
|
| 342 | + 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"; |
|
| 343 | + 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"; |
|
| 344 | 344 | try { |
| 345 | 345 | $sth = $this->db->prepare($query); |
| 346 | 346 | $sth->execute(array(':filter_name' => $filter_name)); |
| 347 | - } catch(PDOException $e) { |
|
| 347 | + } catch (PDOException $e) { |
|
| 348 | 348 | echo "error : ".$e->getMessage(); |
| 349 | 349 | } |
| 350 | 350 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -355,61 +355,61 @@ discard block |
||
| 355 | 355 | 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"; |
| 356 | 356 | try { |
| 357 | 357 | $sth = $this->db->prepare($query); |
| 358 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 359 | - } catch(PDOException $e) { |
|
| 358 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 359 | + } catch (PDOException $e) { |
|
| 360 | 360 | echo "error : ".$e->getMessage(); |
| 361 | 361 | } |
| 362 | 362 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 363 | 363 | } else $all = array(); |
| 364 | 364 | } |
| 365 | 365 | if (empty($all)) { |
| 366 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 367 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 366 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 367 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 368 | 368 | } else { |
| 369 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 369 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 370 | 370 | } |
| 371 | 371 | if ($filter_name != '') { |
| 372 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 372 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 373 | 373 | } |
| 374 | 374 | $Spotter = new Spotter($this->db); |
| 375 | 375 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
| 376 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
| 376 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
| 377 | 377 | } |
| 378 | 378 | return $all; |
| 379 | 379 | } |
| 380 | 380 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 381 | 381 | global $globalStatsFilters; |
| 382 | 382 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 383 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 383 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 384 | 384 | $Spotter = new Spotter($this->db); |
| 385 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 385 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 386 | 386 | $alliance_airlines = array(); |
| 387 | 387 | foreach ($airlines as $airline) { |
| 388 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 388 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 389 | 389 | } |
| 390 | - 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"; |
|
| 391 | - 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"; |
|
| 390 | + 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"; |
|
| 391 | + 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"; |
|
| 392 | 392 | $query_values = array(':filter_name' => $filter_name); |
| 393 | 393 | } else { |
| 394 | 394 | 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"; |
| 395 | 395 | 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"; |
| 396 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 396 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 397 | 397 | } |
| 398 | 398 | try { |
| 399 | 399 | $sth = $this->db->prepare($query); |
| 400 | 400 | $sth->execute($query_values); |
| 401 | - } catch(PDOException $e) { |
|
| 401 | + } catch (PDOException $e) { |
|
| 402 | 402 | echo "error : ".$e->getMessage(); |
| 403 | 403 | } |
| 404 | 404 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 405 | 405 | if (empty($all)) { |
| 406 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 407 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 406 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 407 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 408 | 408 | } else { |
| 409 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 409 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 410 | 410 | } |
| 411 | 411 | if ($filter_name != '') { |
| 412 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 412 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 413 | 413 | } |
| 414 | 414 | $Spotter = new Spotter($this->db); |
| 415 | 415 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | return $all; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 421 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 422 | 422 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 423 | 423 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 424 | 424 | if ($year == '' && $month == '') { |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | if (isset($forsource)) { |
| 428 | 428 | 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"; |
| 429 | 429 | 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"; |
| 430 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
| 430 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
| 431 | 431 | } else { |
| 432 | 432 | 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"; |
| 433 | 433 | 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"; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | try { |
| 437 | 437 | $sth = $this->db->prepare($query); |
| 438 | 438 | $sth->execute($query_values); |
| 439 | - } catch(PDOException $e) { |
|
| 439 | + } catch (PDOException $e) { |
|
| 440 | 440 | echo "error : ".$e->getMessage(); |
| 441 | 441 | } |
| 442 | 442 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -444,32 +444,32 @@ discard block |
||
| 444 | 444 | if (empty($all)) { |
| 445 | 445 | $Spotter = new Spotter($this->db); |
| 446 | 446 | $filters = array(); |
| 447 | - $filters = array('year' => $year,'month' => $month); |
|
| 447 | + $filters = array('year' => $year, 'month' => $month); |
|
| 448 | 448 | if ($filter_name != '') { |
| 449 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 449 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 450 | 450 | } |
| 451 | 451 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 452 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 452 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
| 453 | 453 | } |
| 454 | 454 | return $all; |
| 455 | 455 | } |
| 456 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 456 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 457 | 457 | global $globalStatsFilters; |
| 458 | 458 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 459 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 459 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 460 | 460 | $Spotter = new Spotter($this->db); |
| 461 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 461 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 462 | 462 | $alliance_airlines = array(); |
| 463 | 463 | foreach ($airlines as $airline) { |
| 464 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 464 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 465 | 465 | } |
| 466 | 466 | if ($year == '' && $month == '') { |
| 467 | - 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"; |
|
| 468 | - 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"; |
|
| 467 | + 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"; |
|
| 468 | + 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"; |
|
| 469 | 469 | try { |
| 470 | 470 | $sth = $this->db->prepare($query); |
| 471 | 471 | $sth->execute(array(':filter_name' => $filter_name)); |
| 472 | - } catch(PDOException $e) { |
|
| 472 | + } catch (PDOException $e) { |
|
| 473 | 473 | echo "error : ".$e->getMessage(); |
| 474 | 474 | } |
| 475 | 475 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -480,45 +480,45 @@ discard block |
||
| 480 | 480 | 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"; |
| 481 | 481 | try { |
| 482 | 482 | $sth = $this->db->prepare($query); |
| 483 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 484 | - } catch(PDOException $e) { |
|
| 483 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 484 | + } catch (PDOException $e) { |
|
| 485 | 485 | echo "error : ".$e->getMessage(); |
| 486 | 486 | } |
| 487 | 487 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 488 | 488 | } else $all = array(); |
| 489 | 489 | } |
| 490 | 490 | if (empty($all)) { |
| 491 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 492 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 491 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 492 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 493 | 493 | } else { |
| 494 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 494 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 495 | 495 | } |
| 496 | 496 | if ($filter_name != '') { |
| 497 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 497 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 498 | 498 | } |
| 499 | 499 | $Spotter = new Spotter($this->db); |
| 500 | 500 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
| 501 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 501 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
| 502 | 502 | } |
| 503 | 503 | return $all; |
| 504 | 504 | } |
| 505 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 505 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 506 | 506 | global $globalStatsFilters; |
| 507 | 507 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 508 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 508 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 509 | 509 | $Spotter = new Spotter($this->db); |
| 510 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 510 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 511 | 511 | $alliance_airlines = array(); |
| 512 | 512 | foreach ($airlines as $airline) { |
| 513 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 513 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 514 | 514 | } |
| 515 | 515 | if ($year == '' && $month == '') { |
| 516 | - 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"; |
|
| 517 | - 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"; |
|
| 516 | + 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"; |
|
| 517 | + 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"; |
|
| 518 | 518 | try { |
| 519 | 519 | $sth = $this->db->prepare($query); |
| 520 | 520 | $sth->execute(array(':filter_name' => $filter_name)); |
| 521 | - } catch(PDOException $e) { |
|
| 521 | + } catch (PDOException $e) { |
|
| 522 | 522 | echo "error : ".$e->getMessage(); |
| 523 | 523 | } |
| 524 | 524 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -529,46 +529,46 @@ discard block |
||
| 529 | 529 | 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"; |
| 530 | 530 | try { |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 533 | - } catch(PDOException $e) { |
|
| 532 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 533 | + } catch (PDOException $e) { |
|
| 534 | 534 | echo "error : ".$e->getMessage(); |
| 535 | 535 | } |
| 536 | 536 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 537 | 537 | } else $all = array(); |
| 538 | 538 | } |
| 539 | 539 | if (empty($all)) { |
| 540 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 541 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 540 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 541 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 542 | 542 | } else { |
| 543 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 543 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 544 | 544 | } |
| 545 | 545 | if ($filter_name != '') { |
| 546 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 546 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 547 | 547 | } |
| 548 | 548 | $Spotter = new Spotter($this->db); |
| 549 | 549 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
| 550 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
| 550 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
| 551 | 551 | } |
| 552 | 552 | return $all; |
| 553 | 553 | } |
| 554 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 554 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 555 | 555 | $Connection = new Connection($this->db); |
| 556 | 556 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 557 | 557 | if ($Connection->tableExists('countries')) { |
| 558 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 558 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 559 | 559 | $Spotter = new Spotter($this->db); |
| 560 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 560 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 561 | 561 | if ($year == '' && $month == '') { |
| 562 | 562 | $alliance_airlines = array(); |
| 563 | 563 | foreach ($airlines as $airline) { |
| 564 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 564 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 565 | 565 | } |
| 566 | - 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"; |
|
| 567 | - 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"; |
|
| 566 | + 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"; |
|
| 567 | + 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"; |
|
| 568 | 568 | try { |
| 569 | 569 | $sth = $this->db->prepare($query); |
| 570 | 570 | $sth->execute(array(':filter_name' => $filter_name)); |
| 571 | - } catch(PDOException $e) { |
|
| 571 | + } catch (PDOException $e) { |
|
| 572 | 572 | echo "error : ".$e->getMessage(); |
| 573 | 573 | } |
| 574 | 574 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | 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"; |
| 581 | 581 | try { |
| 582 | 582 | $sth = $this->db->prepare($query); |
| 583 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 584 | - } catch(PDOException $e) { |
|
| 583 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 584 | + } catch (PDOException $e) { |
|
| 585 | 585 | echo "error : ".$e->getMessage(); |
| 586 | 586 | } |
| 587 | 587 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | return $Spotter->countAllFlightOverCountries($limit); |
| 593 | 593 | } else return array(); |
| 594 | 594 | } |
| 595 | - public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
|
| 595 | + public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 596 | 596 | $Connection = new Connection($this->db); |
| 597 | 597 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 598 | 598 | if ($Connection->tableExists('countries')) { |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | try { |
| 604 | 604 | $sth = $this->db->prepare($query); |
| 605 | 605 | $sth->execute(array(':filter_name' => $filter_name)); |
| 606 | - } catch(PDOException $e) { |
|
| 606 | + } catch (PDOException $e) { |
|
| 607 | 607 | echo "error : ".$e->getMessage(); |
| 608 | 608 | } |
| 609 | 609 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -611,15 +611,15 @@ discard block |
||
| 611 | 611 | if (empty($all)) { |
| 612 | 612 | $filters = array(); |
| 613 | 613 | if ($filter_name != '') { |
| 614 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 614 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 615 | 615 | } |
| 616 | 616 | $Marine = new Marine($this->db); |
| 617 | - $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
|
| 617 | + $all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters); |
|
| 618 | 618 | } |
| 619 | 619 | return $all; |
| 620 | 620 | } else return array(); |
| 621 | 621 | } |
| 622 | - public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
|
| 622 | + public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 623 | 623 | global $globalStatsFilters; |
| 624 | 624 | $Connection = new Connection($this->db); |
| 625 | 625 | if ($filter_name == '') $filter_name = $this->filter_name; |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | try { |
| 632 | 632 | $sth = $this->db->prepare($query); |
| 633 | 633 | $sth->execute(array(':filter_name' => $filter_name)); |
| 634 | - } catch(PDOException $e) { |
|
| 634 | + } catch (PDOException $e) { |
|
| 635 | 635 | echo "error : ".$e->getMessage(); |
| 636 | 636 | } |
| 637 | 637 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -640,15 +640,15 @@ discard block |
||
| 640 | 640 | if (empty($all)) { |
| 641 | 641 | $filters = array(); |
| 642 | 642 | if ($filter_name != '') { |
| 643 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 643 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 644 | 644 | } |
| 645 | 645 | $Tracker = new Tracker($this->db); |
| 646 | - $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
|
| 646 | + $all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters); |
|
| 647 | 647 | } |
| 648 | 648 | return $all; |
| 649 | 649 | } else return array(); |
| 650 | 650 | } |
| 651 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
| 651 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 652 | 652 | global $globalStatsFilters; |
| 653 | 653 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 654 | 654 | if ($year == '' && $month == '') { |
@@ -656,41 +656,41 @@ discard block |
||
| 656 | 656 | 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"; |
| 657 | 657 | try { |
| 658 | 658 | $sth = $this->db->prepare($query); |
| 659 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 660 | - } catch(PDOException $e) { |
|
| 659 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 660 | + } catch (PDOException $e) { |
|
| 661 | 661 | echo "error : ".$e->getMessage(); |
| 662 | 662 | } |
| 663 | 663 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 664 | 664 | } else $all = array(); |
| 665 | 665 | if (empty($all)) { |
| 666 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 666 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 667 | 667 | if ($filter_name != '') { |
| 668 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 668 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 669 | 669 | } |
| 670 | 670 | $Spotter = new Spotter($this->db); |
| 671 | 671 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
| 672 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
| 672 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
| 673 | 673 | } |
| 674 | 674 | return $all; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 677 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 678 | 678 | global $globalStatsFilters; |
| 679 | 679 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 680 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 680 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 681 | 681 | $Spotter = new Spotter($this->db); |
| 682 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 682 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 683 | 683 | if ($year == '' && $month == '') { |
| 684 | 684 | $alliance_airlines = array(); |
| 685 | 685 | foreach ($airlines as $airline) { |
| 686 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 686 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 687 | 687 | } |
| 688 | - 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"; |
|
| 689 | - 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"; |
|
| 688 | + 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"; |
|
| 689 | + 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"; |
|
| 690 | 690 | try { |
| 691 | 691 | $sth = $this->db->prepare($query); |
| 692 | 692 | $sth->execute(array(':filter_name' => $filter_name)); |
| 693 | - } catch(PDOException $e) { |
|
| 693 | + } catch (PDOException $e) { |
|
| 694 | 694 | echo "error : ".$e->getMessage(); |
| 695 | 695 | } |
| 696 | 696 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -701,45 +701,45 @@ discard block |
||
| 701 | 701 | 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"; |
| 702 | 702 | try { |
| 703 | 703 | $sth = $this->db->prepare($query); |
| 704 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 705 | - } catch(PDOException $e) { |
|
| 704 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 705 | + } catch (PDOException $e) { |
|
| 706 | 706 | echo "error : ".$e->getMessage(); |
| 707 | 707 | } |
| 708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 709 | 709 | } else $all = array(); |
| 710 | 710 | } |
| 711 | 711 | if (empty($all)) { |
| 712 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 713 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 712 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 713 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 714 | 714 | } else { |
| 715 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 715 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 716 | 716 | } |
| 717 | 717 | if ($filter_name != '') { |
| 718 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 718 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 719 | 719 | } |
| 720 | 720 | $Spotter = new Spotter($this->db); |
| 721 | 721 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
| 722 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 722 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
| 723 | 723 | } |
| 724 | 724 | return $all; |
| 725 | 725 | } |
| 726 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 726 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 727 | 727 | global $globalStatsFilters; |
| 728 | 728 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 729 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 729 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 730 | 730 | $Spotter = new Spotter($this->db); |
| 731 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 731 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 732 | 732 | if ($year == '' && $month == '') { |
| 733 | 733 | $alliance_airlines = array(); |
| 734 | 734 | foreach ($airlines as $airline) { |
| 735 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 735 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 736 | 736 | } |
| 737 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 738 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 737 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 738 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 739 | 739 | try { |
| 740 | 740 | $sth = $this->db->prepare($query); |
| 741 | 741 | $sth->execute(array(':filter_name' => $filter_name)); |
| 742 | - } catch(PDOException $e) { |
|
| 742 | + } catch (PDOException $e) { |
|
| 743 | 743 | echo "error : ".$e->getMessage(); |
| 744 | 744 | } |
| 745 | 745 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -750,27 +750,27 @@ discard block |
||
| 750 | 750 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
| 751 | 751 | try { |
| 752 | 752 | $sth = $this->db->prepare($query); |
| 753 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 754 | - } catch(PDOException $e) { |
|
| 753 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 754 | + } catch (PDOException $e) { |
|
| 755 | 755 | echo "error : ".$e->getMessage(); |
| 756 | 756 | } |
| 757 | 757 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 758 | 758 | } else $all = array(); |
| 759 | 759 | } |
| 760 | 760 | if (empty($all)) { |
| 761 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 762 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 761 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 762 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 763 | 763 | } else { |
| 764 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 764 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 765 | 765 | } |
| 766 | 766 | if ($filter_name != '') { |
| 767 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 767 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 768 | 768 | } |
| 769 | 769 | $Spotter = new Spotter($this->db); |
| 770 | 770 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
| 771 | 771 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
| 772 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 773 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 772 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
| 773 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
| 774 | 774 | $all = array(); |
| 775 | 775 | foreach ($pall as $value) { |
| 776 | 776 | $icao = $value['airport_departure_icao']; |
@@ -786,27 +786,27 @@ discard block |
||
| 786 | 786 | foreach ($all as $key => $row) { |
| 787 | 787 | $count[$key] = $row['airport_departure_icao_count']; |
| 788 | 788 | } |
| 789 | - array_multisort($count,SORT_DESC,$all); |
|
| 789 | + array_multisort($count, SORT_DESC, $all); |
|
| 790 | 790 | } |
| 791 | 791 | return $all; |
| 792 | 792 | } |
| 793 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 793 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 794 | 794 | global $globalStatsFilters; |
| 795 | 795 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 796 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 796 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 797 | 797 | $Spotter = new Spotter($this->db); |
| 798 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 798 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 799 | 799 | if ($year == '' && $month == '') { |
| 800 | 800 | $alliance_airlines = array(); |
| 801 | 801 | foreach ($airlines as $airline) { |
| 802 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 802 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 803 | 803 | } |
| 804 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 805 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 804 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 805 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 806 | 806 | try { |
| 807 | 807 | $sth = $this->db->prepare($query); |
| 808 | 808 | $sth->execute(array(':filter_name' => $filter_name)); |
| 809 | - } catch(PDOException $e) { |
|
| 809 | + } catch (PDOException $e) { |
|
| 810 | 810 | echo "error : ".$e->getMessage(); |
| 811 | 811 | } |
| 812 | 812 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -817,27 +817,27 @@ discard block |
||
| 817 | 817 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
| 818 | 818 | try { |
| 819 | 819 | $sth = $this->db->prepare($query); |
| 820 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 821 | - } catch(PDOException $e) { |
|
| 820 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 821 | + } catch (PDOException $e) { |
|
| 822 | 822 | echo "error : ".$e->getMessage(); |
| 823 | 823 | } |
| 824 | 824 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 825 | 825 | } else $all = array(); |
| 826 | 826 | } |
| 827 | 827 | if (empty($all)) { |
| 828 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 829 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 828 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 829 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 830 | 830 | } else { |
| 831 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 831 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 832 | 832 | } |
| 833 | 833 | if ($filter_name != '') { |
| 834 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 834 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 835 | 835 | } |
| 836 | 836 | $Spotter = new Spotter($this->db); |
| 837 | 837 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 838 | 838 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 839 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
| 840 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
| 839 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
| 840 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
| 841 | 841 | $all = array(); |
| 842 | 842 | foreach ($pall as $value) { |
| 843 | 843 | $icao = $value['airport_arrival_icao']; |
@@ -853,26 +853,26 @@ discard block |
||
| 853 | 853 | foreach ($all as $key => $row) { |
| 854 | 854 | $count[$key] = $row['airport_arrival_icao_count']; |
| 855 | 855 | } |
| 856 | - array_multisort($count,SORT_DESC,$all); |
|
| 856 | + array_multisort($count, SORT_DESC, $all); |
|
| 857 | 857 | } |
| 858 | 858 | return $all; |
| 859 | 859 | } |
| 860 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
| 860 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
| 861 | 861 | global $globalDBdriver, $globalStatsFilters; |
| 862 | 862 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 863 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 863 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 864 | 864 | $Spotter = new Spotter($this->db); |
| 865 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 865 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 866 | 866 | $alliance_airlines = array(); |
| 867 | 867 | foreach ($airlines as $airline) { |
| 868 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 868 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 869 | 869 | } |
| 870 | 870 | if ($globalDBdriver == 'mysql') { |
| 871 | - 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"; |
|
| 872 | - 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"; |
|
| 871 | + 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"; |
|
| 872 | + 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"; |
|
| 873 | 873 | } else { |
| 874 | - 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"; |
|
| 875 | - 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"; |
|
| 874 | + 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"; |
|
| 875 | + 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"; |
|
| 876 | 876 | } |
| 877 | 877 | $query_data = array(':filter_name' => $filter_name); |
| 878 | 878 | } else { |
@@ -883,23 +883,23 @@ discard block |
||
| 883 | 883 | 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"; |
| 884 | 884 | 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"; |
| 885 | 885 | } |
| 886 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 886 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 887 | 887 | } |
| 888 | 888 | try { |
| 889 | 889 | $sth = $this->db->prepare($query); |
| 890 | 890 | $sth->execute($query_data); |
| 891 | - } catch(PDOException $e) { |
|
| 891 | + } catch (PDOException $e) { |
|
| 892 | 892 | echo "error : ".$e->getMessage(); |
| 893 | 893 | } |
| 894 | 894 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 895 | 895 | if (empty($all)) { |
| 896 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 897 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 896 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 897 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 898 | 898 | } else { |
| 899 | 899 | $filters = array('airlines' => array($stats_airline)); |
| 900 | 900 | } |
| 901 | 901 | if ($filter_name != '') { |
| 902 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 902 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 903 | 903 | } |
| 904 | 904 | $Spotter = new Spotter($this->db); |
| 905 | 905 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | return $all; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') { |
|
| 910 | + public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') { |
|
| 911 | 911 | global $globalDBdriver, $globalStatsFilters; |
| 912 | 912 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 913 | 913 | if ($globalDBdriver == 'mysql') { |
@@ -921,14 +921,14 @@ discard block |
||
| 921 | 921 | try { |
| 922 | 922 | $sth = $this->db->prepare($query); |
| 923 | 923 | $sth->execute($query_data); |
| 924 | - } catch(PDOException $e) { |
|
| 924 | + } catch (PDOException $e) { |
|
| 925 | 925 | echo "error : ".$e->getMessage(); |
| 926 | 926 | } |
| 927 | 927 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 928 | 928 | if (empty($all)) { |
| 929 | 929 | $filters = array(); |
| 930 | 930 | if ($filter_name != '') { |
| 931 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 931 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 932 | 932 | } |
| 933 | 933 | $Marine = new Marine($this->db); |
| 934 | 934 | $all = $Marine->countAllMonthsLastYear($filters); |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | return $all; |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') { |
|
| 939 | + public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') { |
|
| 940 | 940 | global $globalDBdriver, $globalStatsFilters; |
| 941 | 941 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 942 | 942 | if ($globalDBdriver == 'mysql') { |
@@ -950,14 +950,14 @@ discard block |
||
| 950 | 950 | try { |
| 951 | 951 | $sth = $this->db->prepare($query); |
| 952 | 952 | $sth->execute($query_data); |
| 953 | - } catch(PDOException $e) { |
|
| 953 | + } catch (PDOException $e) { |
|
| 954 | 954 | echo "error : ".$e->getMessage(); |
| 955 | 955 | } |
| 956 | 956 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 957 | 957 | if (empty($all)) { |
| 958 | 958 | $filters = array(); |
| 959 | 959 | if ($filter_name != '') { |
| 960 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 960 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 961 | 961 | } |
| 962 | 962 | $Tracker = new Tracker($this->db); |
| 963 | 963 | $all = $Tracker->countAllMonthsLastYear($filters); |
@@ -965,37 +965,37 @@ discard block |
||
| 965 | 965 | return $all; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
| 968 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
| 969 | 969 | global $globalStatsFilters; |
| 970 | 970 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 971 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 971 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 972 | 972 | $Spotter = new Spotter($this->db); |
| 973 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 973 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 974 | 974 | $alliance_airlines = array(); |
| 975 | 975 | foreach ($airlines as $airline) { |
| 976 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 976 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 977 | 977 | } |
| 978 | - $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"; |
|
| 978 | + $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"; |
|
| 979 | 979 | $query_data = array(':filter_name' => $filter_name); |
| 980 | 980 | } else { |
| 981 | 981 | $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"; |
| 982 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 982 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 983 | 983 | } |
| 984 | 984 | try { |
| 985 | 985 | $sth = $this->db->prepare($query); |
| 986 | 986 | $sth->execute($query_data); |
| 987 | - } catch(PDOException $e) { |
|
| 987 | + } catch (PDOException $e) { |
|
| 988 | 988 | echo "error : ".$e->getMessage(); |
| 989 | 989 | } |
| 990 | 990 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 991 | 991 | if (empty($all)) { |
| 992 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 993 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 992 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 993 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 994 | 994 | } else { |
| 995 | 995 | $filters = array('airlines' => array($stats_airline)); |
| 996 | 996 | } |
| 997 | 997 | if ($filter_name != '') { |
| 998 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 998 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 999 | 999 | } |
| 1000 | 1000 | $Spotter = new Spotter($this->db); |
| 1001 | 1001 | $all = $Spotter->countAllDatesLastMonth($filters); |
@@ -1010,14 +1010,14 @@ discard block |
||
| 1010 | 1010 | try { |
| 1011 | 1011 | $sth = $this->db->prepare($query); |
| 1012 | 1012 | $sth->execute($query_data); |
| 1013 | - } catch(PDOException $e) { |
|
| 1013 | + } catch (PDOException $e) { |
|
| 1014 | 1014 | echo "error : ".$e->getMessage(); |
| 1015 | 1015 | } |
| 1016 | 1016 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1017 | 1017 | if (empty($all)) { |
| 1018 | 1018 | $filters = array(); |
| 1019 | 1019 | if ($filter_name != '') { |
| 1020 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1020 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | $Marine = new Marine($this->db); |
| 1023 | 1023 | $all = $Marine->countAllDatesLastMonth($filters); |
@@ -1032,34 +1032,34 @@ discard block |
||
| 1032 | 1032 | try { |
| 1033 | 1033 | $sth = $this->db->prepare($query); |
| 1034 | 1034 | $sth->execute($query_data); |
| 1035 | - } catch(PDOException $e) { |
|
| 1035 | + } catch (PDOException $e) { |
|
| 1036 | 1036 | echo "error : ".$e->getMessage(); |
| 1037 | 1037 | } |
| 1038 | 1038 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1039 | 1039 | if (empty($all)) { |
| 1040 | 1040 | $filters = array(); |
| 1041 | 1041 | if ($filter_name != '') { |
| 1042 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1042 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | $Tracker = new Tracker($this->db); |
| 1045 | 1045 | $all = $Tracker->countAllDatesLastMonth($filters); |
| 1046 | 1046 | } |
| 1047 | 1047 | return $all; |
| 1048 | 1048 | } |
| 1049 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
| 1049 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
| 1050 | 1050 | global $globalDBdriver, $globalStatsFilters; |
| 1051 | 1051 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1052 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1052 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1053 | 1053 | $Spotter = new Spotter($this->db); |
| 1054 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1054 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1055 | 1055 | $alliance_airlines = array(); |
| 1056 | 1056 | foreach ($airlines as $airline) { |
| 1057 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1057 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | if ($globalDBdriver == 'mysql') { |
| 1060 | - $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"; |
|
| 1060 | + $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"; |
|
| 1061 | 1061 | } else { |
| 1062 | - $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"; |
|
| 1062 | + $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"; |
|
| 1063 | 1063 | } |
| 1064 | 1064 | $query_data = array(':filter_name' => $filter_name); |
| 1065 | 1065 | } else { |
@@ -1068,23 +1068,23 @@ discard block |
||
| 1068 | 1068 | } else { |
| 1069 | 1069 | $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"; |
| 1070 | 1070 | } |
| 1071 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1071 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | try { |
| 1074 | 1074 | $sth = $this->db->prepare($query); |
| 1075 | 1075 | $sth->execute($query_data); |
| 1076 | - } catch(PDOException $e) { |
|
| 1076 | + } catch (PDOException $e) { |
|
| 1077 | 1077 | echo "error : ".$e->getMessage(); |
| 1078 | 1078 | } |
| 1079 | 1079 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1080 | 1080 | if (empty($all)) { |
| 1081 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1082 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1081 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1082 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1083 | 1083 | } else { |
| 1084 | 1084 | $filters = array('airlines' => array($stats_airline)); |
| 1085 | 1085 | } |
| 1086 | 1086 | if ($filter_name != '') { |
| 1087 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1087 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | $Spotter = new Spotter($this->db); |
| 1090 | 1090 | $all = $Spotter->countAllDatesLast7Days($filters); |
@@ -1103,14 +1103,14 @@ discard block |
||
| 1103 | 1103 | try { |
| 1104 | 1104 | $sth = $this->db->prepare($query); |
| 1105 | 1105 | $sth->execute($query_data); |
| 1106 | - } catch(PDOException $e) { |
|
| 1106 | + } catch (PDOException $e) { |
|
| 1107 | 1107 | echo "error : ".$e->getMessage(); |
| 1108 | 1108 | } |
| 1109 | 1109 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1110 | 1110 | if (empty($all)) { |
| 1111 | 1111 | $filters = array(); |
| 1112 | 1112 | if ($filter_name != '') { |
| 1113 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1113 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | $Marine = new Marine($this->db); |
| 1116 | 1116 | $all = $Marine->countAllDatesLast7Days($filters); |
@@ -1129,51 +1129,51 @@ discard block |
||
| 1129 | 1129 | try { |
| 1130 | 1130 | $sth = $this->db->prepare($query); |
| 1131 | 1131 | $sth->execute($query_data); |
| 1132 | - } catch(PDOException $e) { |
|
| 1132 | + } catch (PDOException $e) { |
|
| 1133 | 1133 | echo "error : ".$e->getMessage(); |
| 1134 | 1134 | } |
| 1135 | 1135 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1136 | 1136 | if (empty($all)) { |
| 1137 | 1137 | $filters = array(); |
| 1138 | 1138 | if ($filter_name != '') { |
| 1139 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1139 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | $Tracker = new Tracker($this->db); |
| 1142 | 1142 | $all = $Tracker->countAllDatesLast7Days($filters); |
| 1143 | 1143 | } |
| 1144 | 1144 | return $all; |
| 1145 | 1145 | } |
| 1146 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
| 1146 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
| 1147 | 1147 | global $globalStatsFilters; |
| 1148 | 1148 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1149 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1149 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1150 | 1150 | $Spotter = new Spotter($this->db); |
| 1151 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1151 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1152 | 1152 | $alliance_airlines = array(); |
| 1153 | 1153 | foreach ($airlines as $airline) { |
| 1154 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1154 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1155 | 1155 | } |
| 1156 | - $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"; |
|
| 1156 | + $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"; |
|
| 1157 | 1157 | $query_data = array(':filter_name' => $filter_name); |
| 1158 | 1158 | } else { |
| 1159 | 1159 | $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"; |
| 1160 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1160 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | try { |
| 1163 | 1163 | $sth = $this->db->prepare($query); |
| 1164 | 1164 | $sth->execute($query_data); |
| 1165 | - } catch(PDOException $e) { |
|
| 1165 | + } catch (PDOException $e) { |
|
| 1166 | 1166 | echo "error : ".$e->getMessage(); |
| 1167 | 1167 | } |
| 1168 | 1168 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1169 | 1169 | if (empty($all)) { |
| 1170 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1171 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1170 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1171 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1172 | 1172 | } else { |
| 1173 | 1173 | $filters = array('airlines' => array($stats_airline)); |
| 1174 | 1174 | } |
| 1175 | 1175 | if ($filter_name != '') { |
| 1176 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1176 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | $Spotter = new Spotter($this->db); |
| 1179 | 1179 | $all = $Spotter->countAllDates($filters); |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | try { |
| 1189 | 1189 | $sth = $this->db->prepare($query); |
| 1190 | 1190 | $sth->execute($query_data); |
| 1191 | - } catch(PDOException $e) { |
|
| 1191 | + } catch (PDOException $e) { |
|
| 1192 | 1192 | echo "error : ".$e->getMessage(); |
| 1193 | 1193 | } |
| 1194 | 1194 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | try { |
| 1211 | 1211 | $sth = $this->db->prepare($query); |
| 1212 | 1212 | $sth->execute($query_data); |
| 1213 | - } catch(PDOException $e) { |
|
| 1213 | + } catch (PDOException $e) { |
|
| 1214 | 1214 | echo "error : ".$e->getMessage(); |
| 1215 | 1215 | } |
| 1216 | 1216 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1232,34 +1232,34 @@ discard block |
||
| 1232 | 1232 | try { |
| 1233 | 1233 | $sth = $this->db->prepare($query); |
| 1234 | 1234 | $sth->execute($query_data); |
| 1235 | - } catch(PDOException $e) { |
|
| 1235 | + } catch (PDOException $e) { |
|
| 1236 | 1236 | echo "error : ".$e->getMessage(); |
| 1237 | 1237 | } |
| 1238 | 1238 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1239 | 1239 | if (empty($all)) { |
| 1240 | 1240 | $filters = array(); |
| 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->countAllDatesByAirlines($filters); |
| 1246 | 1246 | } |
| 1247 | 1247 | return $all; |
| 1248 | 1248 | } |
| 1249 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
| 1249 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
| 1250 | 1250 | global $globalStatsFilters, $globalDBdriver; |
| 1251 | 1251 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1252 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1252 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1253 | 1253 | $Spotter = new Spotter($this->db); |
| 1254 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1254 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1255 | 1255 | $alliance_airlines = array(); |
| 1256 | 1256 | foreach ($airlines as $airline) { |
| 1257 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1257 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | if ($globalDBdriver == 'mysql') { |
| 1260 | - $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"; |
|
| 1260 | + $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"; |
|
| 1261 | 1261 | } else { |
| 1262 | - $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"; |
|
| 1262 | + $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"; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | $query_data = array(':filter_name' => $filter_name); |
| 1265 | 1265 | } else { |
@@ -1273,18 +1273,18 @@ discard block |
||
| 1273 | 1273 | try { |
| 1274 | 1274 | $sth = $this->db->prepare($query); |
| 1275 | 1275 | $sth->execute($query_data); |
| 1276 | - } catch(PDOException $e) { |
|
| 1276 | + } catch (PDOException $e) { |
|
| 1277 | 1277 | echo "error : ".$e->getMessage(); |
| 1278 | 1278 | } |
| 1279 | 1279 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1280 | 1280 | if (empty($all)) { |
| 1281 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1282 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1281 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1282 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1283 | 1283 | } else { |
| 1284 | 1284 | $filters = array('airlines' => array($stats_airline)); |
| 1285 | 1285 | } |
| 1286 | 1286 | if ($filter_name != '') { |
| 1287 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1287 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | $Spotter = new Spotter($this->db); |
| 1290 | 1290 | $all = $Spotter->countAllMonths($filters); |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | try { |
| 1302 | 1302 | $sth = $this->db->prepare($query); |
| 1303 | 1303 | $sth->execute(); |
| 1304 | - } catch(PDOException $e) { |
|
| 1304 | + } catch (PDOException $e) { |
|
| 1305 | 1305 | echo "error : ".$e->getMessage(); |
| 1306 | 1306 | } |
| 1307 | 1307 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | try { |
| 1322 | 1322 | $sth = $this->db->prepare($query); |
| 1323 | 1323 | $sth->execute(); |
| 1324 | - } catch(PDOException $e) { |
|
| 1324 | + } catch (PDOException $e) { |
|
| 1325 | 1325 | echo "error : ".$e->getMessage(); |
| 1326 | 1326 | } |
| 1327 | 1327 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1338,32 +1338,32 @@ discard block |
||
| 1338 | 1338 | try { |
| 1339 | 1339 | $sth = $this->db->prepare($query); |
| 1340 | 1340 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1341 | - } catch(PDOException $e) { |
|
| 1341 | + } catch (PDOException $e) { |
|
| 1342 | 1342 | echo "error : ".$e->getMessage(); |
| 1343 | 1343 | } |
| 1344 | 1344 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1345 | 1345 | if (empty($all)) { |
| 1346 | 1346 | $filters = array(); |
| 1347 | 1347 | if ($filter_name != '') { |
| 1348 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1348 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | $Spotter = new Spotter($this->db); |
| 1351 | 1351 | $all = $Spotter->countAllMilitaryMonths($filters); |
| 1352 | 1352 | } |
| 1353 | 1353 | return $all; |
| 1354 | 1354 | } |
| 1355 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
| 1355 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
| 1356 | 1356 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1357 | 1357 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1358 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1358 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1359 | 1359 | $Spotter = new Spotter($this->db); |
| 1360 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1360 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1361 | 1361 | $alliance_airlines = array(); |
| 1362 | 1362 | foreach ($airlines as $airline) { |
| 1363 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1363 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1364 | 1364 | } |
| 1365 | - 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"; |
|
| 1366 | - 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"; |
|
| 1365 | + 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"; |
|
| 1366 | + 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"; |
|
| 1367 | 1367 | $query_data = array(':filter_name' => $filter_name); |
| 1368 | 1368 | } else { |
| 1369 | 1369 | 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"; |
@@ -1381,25 +1381,25 @@ discard block |
||
| 1381 | 1381 | try { |
| 1382 | 1382 | $sth = $this->db->prepare($query); |
| 1383 | 1383 | $sth->execute($query_data); |
| 1384 | - } catch(PDOException $e) { |
|
| 1384 | + } catch (PDOException $e) { |
|
| 1385 | 1385 | echo "error : ".$e->getMessage(); |
| 1386 | 1386 | } |
| 1387 | 1387 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1388 | 1388 | if (empty($all)) { |
| 1389 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1390 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1389 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1390 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1391 | 1391 | } else { |
| 1392 | 1392 | $filters = array('airlines' => array($stats_airline)); |
| 1393 | 1393 | } |
| 1394 | 1394 | if ($filter_name != '') { |
| 1395 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1395 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | $Spotter = new Spotter($this->db); |
| 1398 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 1398 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | return $all; |
| 1401 | 1401 | } |
| 1402 | - public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') { |
|
| 1402 | + public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') { |
|
| 1403 | 1403 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1404 | 1404 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1405 | 1405 | if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
@@ -1416,21 +1416,21 @@ discard block |
||
| 1416 | 1416 | try { |
| 1417 | 1417 | $sth = $this->db->prepare($query); |
| 1418 | 1418 | $sth->execute($query_data); |
| 1419 | - } catch(PDOException $e) { |
|
| 1419 | + } catch (PDOException $e) { |
|
| 1420 | 1420 | echo "error : ".$e->getMessage(); |
| 1421 | 1421 | } |
| 1422 | 1422 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1423 | 1423 | if (empty($all)) { |
| 1424 | 1424 | $filters = array(); |
| 1425 | 1425 | if ($filter_name != '') { |
| 1426 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1426 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | $Marine = new Marine($this->db); |
| 1429 | - $all = $Marine->countAllHours($orderby,$filters); |
|
| 1429 | + $all = $Marine->countAllHours($orderby, $filters); |
|
| 1430 | 1430 | } |
| 1431 | 1431 | return $all; |
| 1432 | 1432 | } |
| 1433 | - public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') { |
|
| 1433 | + public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') { |
|
| 1434 | 1434 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1435 | 1435 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1436 | 1436 | if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name"; |
@@ -1447,33 +1447,33 @@ discard block |
||
| 1447 | 1447 | try { |
| 1448 | 1448 | $sth = $this->db->prepare($query); |
| 1449 | 1449 | $sth->execute($query_data); |
| 1450 | - } catch(PDOException $e) { |
|
| 1450 | + } catch (PDOException $e) { |
|
| 1451 | 1451 | echo "error : ".$e->getMessage(); |
| 1452 | 1452 | } |
| 1453 | 1453 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1454 | 1454 | if (empty($all)) { |
| 1455 | 1455 | $filters = array(); |
| 1456 | 1456 | if ($filter_name != '') { |
| 1457 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1457 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | $Tracker = new Tracker($this->db); |
| 1460 | - $all = $Tracker->countAllHours($orderby,$filters); |
|
| 1460 | + $all = $Tracker->countAllHours($orderby, $filters); |
|
| 1461 | 1461 | } |
| 1462 | 1462 | return $all; |
| 1463 | 1463 | } |
| 1464 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 1464 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1465 | 1465 | global $globalStatsFilters; |
| 1466 | 1466 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1467 | 1467 | if ($year == '') $year = date('Y'); |
| 1468 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1468 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1469 | 1469 | if (empty($all)) { |
| 1470 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1471 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1470 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1471 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1472 | 1472 | } else { |
| 1473 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1473 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1474 | 1474 | } |
| 1475 | 1475 | if ($filter_name != '') { |
| 1476 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1476 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1481,15 +1481,15 @@ discard block |
||
| 1481 | 1481 | } |
| 1482 | 1482 | return $all; |
| 1483 | 1483 | } |
| 1484 | - public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
|
| 1484 | + public function countOverallMarine($filter_name = '', $year = '', $month = '') { |
|
| 1485 | 1485 | global $globalStatsFilters; |
| 1486 | 1486 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1487 | 1487 | if ($year == '') $year = date('Y'); |
| 1488 | - $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
|
| 1488 | + $all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month); |
|
| 1489 | 1489 | if (empty($all)) { |
| 1490 | - $filters = array('year' => $year,'month' => $month); |
|
| 1490 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1491 | 1491 | if ($filter_name != '') { |
| 1492 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1492 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | $Marine = new Marine($this->db); |
| 1495 | 1495 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1497,15 +1497,15 @@ discard block |
||
| 1497 | 1497 | } |
| 1498 | 1498 | return $all; |
| 1499 | 1499 | } |
| 1500 | - public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
|
| 1500 | + public function countOverallTracker($filter_name = '', $year = '', $month = '') { |
|
| 1501 | 1501 | global $globalStatsFilters; |
| 1502 | 1502 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1503 | 1503 | if ($year == '') $year = date('Y'); |
| 1504 | - $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
|
| 1504 | + $all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month); |
|
| 1505 | 1505 | if (empty($all)) { |
| 1506 | - $filters = array('year' => $year,'month' => $month); |
|
| 1506 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1507 | 1507 | if ($filter_name != '') { |
| 1508 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1508 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | $Tracker = new Tracker($this->db); |
| 1511 | 1511 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1513,16 +1513,16 @@ discard block |
||
| 1513 | 1513 | } |
| 1514 | 1514 | return $all; |
| 1515 | 1515 | } |
| 1516 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
| 1516 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
| 1517 | 1517 | global $globalStatsFilters; |
| 1518 | 1518 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1519 | 1519 | if ($year == '') $year = date('Y'); |
| 1520 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
| 1520 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
| 1521 | 1521 | if (empty($all)) { |
| 1522 | 1522 | $filters = array(); |
| 1523 | - $filters = array('year' => $year,'month' => $month); |
|
| 1523 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1524 | 1524 | if ($filter_name != '') { |
| 1525 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1525 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | $Spotter = new Spotter($this->db); |
| 1528 | 1528 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1530,19 +1530,19 @@ discard block |
||
| 1530 | 1530 | } |
| 1531 | 1531 | return $all; |
| 1532 | 1532 | } |
| 1533 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
| 1533 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1534 | 1534 | global $globalStatsFilters; |
| 1535 | 1535 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1536 | 1536 | if ($year == '') $year = date('Y'); |
| 1537 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1537 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1538 | 1538 | if (empty($all)) { |
| 1539 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1540 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1539 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1540 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1541 | 1541 | } else { |
| 1542 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1542 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | if ($filter_name != '') { |
| 1545 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1545 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1546 | 1546 | } |
| 1547 | 1547 | $Spotter = new Spotter($this->db); |
| 1548 | 1548 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1550,48 +1550,48 @@ discard block |
||
| 1550 | 1550 | } |
| 1551 | 1551 | return $all; |
| 1552 | 1552 | } |
| 1553 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1553 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1554 | 1554 | global $globalStatsFilters; |
| 1555 | 1555 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1556 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1556 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1557 | 1557 | $Spotter = new Spotter($this->db); |
| 1558 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1558 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1559 | 1559 | if ($year == '' && $month == '') { |
| 1560 | 1560 | $alliance_airlines = array(); |
| 1561 | 1561 | foreach ($airlines as $airline) { |
| 1562 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1562 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1563 | 1563 | } |
| 1564 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1564 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1565 | 1565 | try { |
| 1566 | 1566 | $sth = $this->db->prepare($query); |
| 1567 | 1567 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1568 | - } catch(PDOException $e) { |
|
| 1568 | + } catch (PDOException $e) { |
|
| 1569 | 1569 | echo "error : ".$e->getMessage(); |
| 1570 | 1570 | } |
| 1571 | 1571 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1572 | 1572 | $all = $result[0]['nb']; |
| 1573 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1573 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1574 | 1574 | } else { |
| 1575 | 1575 | if ($year == '' && $month == '') { |
| 1576 | 1576 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1577 | 1577 | try { |
| 1578 | 1578 | $sth = $this->db->prepare($query); |
| 1579 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
| 1580 | - } catch(PDOException $e) { |
|
| 1579 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
| 1580 | + } catch (PDOException $e) { |
|
| 1581 | 1581 | echo "error : ".$e->getMessage(); |
| 1582 | 1582 | } |
| 1583 | 1583 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1584 | 1584 | $all = $result[0]['nb']; |
| 1585 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1585 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | if (empty($all)) { |
| 1588 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1589 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1588 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1589 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1590 | 1590 | } else { |
| 1591 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1591 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1592 | 1592 | } |
| 1593 | 1593 | if ($filter_name != '') { |
| 1594 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1594 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | $Spotter = new Spotter($this->db); |
| 1597 | 1597 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | } |
| 1600 | 1600 | return $all; |
| 1601 | 1601 | } |
| 1602 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
| 1602 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
| 1603 | 1603 | global $globalStatsFilters; |
| 1604 | 1604 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1605 | 1605 | if ($year == '' && $month == '') { |
@@ -1607,17 +1607,17 @@ discard block |
||
| 1607 | 1607 | try { |
| 1608 | 1608 | $sth = $this->db->prepare($query); |
| 1609 | 1609 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1610 | - } catch(PDOException $e) { |
|
| 1610 | + } catch (PDOException $e) { |
|
| 1611 | 1611 | echo "error : ".$e->getMessage(); |
| 1612 | 1612 | } |
| 1613 | 1613 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1614 | 1614 | $all = $result[0]['nb_airline']; |
| 1615 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1615 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
| 1616 | 1616 | if (empty($all)) { |
| 1617 | 1617 | $filters = array(); |
| 1618 | - $filters = array('year' => $year,'month' => $month); |
|
| 1618 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1619 | 1619 | if ($filter_name != '') { |
| 1620 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1620 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | $Spotter = new Spotter($this->db); |
| 1623 | 1623 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | } |
| 1626 | 1626 | return $all; |
| 1627 | 1627 | } |
| 1628 | - public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
|
| 1628 | + public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') { |
|
| 1629 | 1629 | global $globalStatsFilters; |
| 1630 | 1630 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1631 | 1631 | $all = array(); |
@@ -1634,7 +1634,7 @@ discard block |
||
| 1634 | 1634 | try { |
| 1635 | 1635 | $sth = $this->db->prepare($query); |
| 1636 | 1636 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1637 | - } catch(PDOException $e) { |
|
| 1637 | + } catch (PDOException $e) { |
|
| 1638 | 1638 | echo "error : ".$e->getMessage(); |
| 1639 | 1639 | } |
| 1640 | 1640 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1642,9 +1642,9 @@ discard block |
||
| 1642 | 1642 | } |
| 1643 | 1643 | if (empty($all)) { |
| 1644 | 1644 | $filters = array(); |
| 1645 | - $filters = array('year' => $year,'month' => $month); |
|
| 1645 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1646 | 1646 | if ($filter_name != '') { |
| 1647 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1647 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | $Marine = new Marine($this->db); |
| 1650 | 1650 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1652,29 +1652,29 @@ discard block |
||
| 1652 | 1652 | } |
| 1653 | 1653 | return $all; |
| 1654 | 1654 | } |
| 1655 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1655 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1656 | 1656 | global $globalStatsFilters; |
| 1657 | 1657 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1658 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1658 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1659 | 1659 | $Spotter = new Spotter($this->db); |
| 1660 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1660 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1661 | 1661 | if ($year == '' && $month == '') { |
| 1662 | 1662 | $alliance_airlines = array(); |
| 1663 | 1663 | foreach ($airlines as $airline) { |
| 1664 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1664 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1665 | 1665 | } |
| 1666 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1666 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1667 | 1667 | $query_values = array(':filter_name' => $filter_name); |
| 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 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1675 | 1675 | $all = $result[0]['nb']; |
| 1676 | 1676 | } else { |
| 1677 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1677 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | } else { |
| 1680 | 1680 | if ($year == '' && $month == '') { |
@@ -1683,23 +1683,23 @@ discard block |
||
| 1683 | 1683 | try { |
| 1684 | 1684 | $sth = $this->db->prepare($query); |
| 1685 | 1685 | $sth->execute($query_values); |
| 1686 | - } catch(PDOException $e) { |
|
| 1686 | + } catch (PDOException $e) { |
|
| 1687 | 1687 | echo "error : ".$e->getMessage(); |
| 1688 | 1688 | } |
| 1689 | 1689 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1690 | 1690 | $all = $result[0]['nb']; |
| 1691 | 1691 | } else { |
| 1692 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1692 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1693 | 1693 | } |
| 1694 | 1694 | } |
| 1695 | 1695 | if (empty($all)) { |
| 1696 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1697 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1696 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1697 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1698 | 1698 | } else { |
| 1699 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1699 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | if ($filter_name != '') { |
| 1702 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1702 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | $Spotter = new Spotter($this->db); |
| 1705 | 1705 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1707,7 +1707,7 @@ discard block |
||
| 1707 | 1707 | } |
| 1708 | 1708 | return $all; |
| 1709 | 1709 | } |
| 1710 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 1710 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1711 | 1711 | global $globalStatsFilters; |
| 1712 | 1712 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1713 | 1713 | //if ($year == '') $year = date('Y'); |
@@ -1717,18 +1717,18 @@ discard block |
||
| 1717 | 1717 | try { |
| 1718 | 1718 | $sth = $this->db->prepare($query); |
| 1719 | 1719 | $sth->execute($query_values); |
| 1720 | - } catch(PDOException $e) { |
|
| 1720 | + } catch (PDOException $e) { |
|
| 1721 | 1721 | echo "error : ".$e->getMessage(); |
| 1722 | 1722 | } |
| 1723 | 1723 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1724 | 1724 | $all = $result[0]['nb']; |
| 1725 | 1725 | } else { |
| 1726 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1726 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | if (empty($all)) { |
| 1729 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1729 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1730 | 1730 | if ($filter_name != '') { |
| 1731 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1731 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | $Spotter = new Spotter($this->db); |
| 1734 | 1734 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1737,104 +1737,104 @@ discard block |
||
| 1737 | 1737 | return $all; |
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
| 1740 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
| 1741 | 1741 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1742 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1742 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1743 | 1743 | $Spotter = new Spotter($this->db); |
| 1744 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1744 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1745 | 1745 | $alliance_airlines = array(); |
| 1746 | 1746 | foreach ($airlines as $airline) { |
| 1747 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1747 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1748 | 1748 | } |
| 1749 | - $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"; |
|
| 1750 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
| 1749 | + $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"; |
|
| 1750 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
| 1751 | 1751 | } else { |
| 1752 | 1752 | $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"; |
| 1753 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1753 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | try { |
| 1756 | 1756 | $sth = $this->db->prepare($query); |
| 1757 | 1757 | $sth->execute($query_values); |
| 1758 | - } catch(PDOException $e) { |
|
| 1758 | + } catch (PDOException $e) { |
|
| 1759 | 1759 | echo "error : ".$e->getMessage(); |
| 1760 | 1760 | } |
| 1761 | 1761 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1762 | 1762 | return $all; |
| 1763 | 1763 | } |
| 1764 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
| 1764 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
| 1765 | 1765 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1766 | 1766 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1767 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1767 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1768 | 1768 | try { |
| 1769 | 1769 | $sth = $this->db->prepare($query); |
| 1770 | 1770 | $sth->execute($query_values); |
| 1771 | - } catch(PDOException $e) { |
|
| 1771 | + } catch (PDOException $e) { |
|
| 1772 | 1772 | echo "error : ".$e->getMessage(); |
| 1773 | 1773 | } |
| 1774 | 1774 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1775 | 1775 | return $all; |
| 1776 | 1776 | } |
| 1777 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
| 1777 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
| 1778 | 1778 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1779 | 1779 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1780 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1780 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1781 | 1781 | try { |
| 1782 | 1782 | $sth = $this->db->prepare($query); |
| 1783 | 1783 | $sth->execute($query_values); |
| 1784 | - } catch(PDOException $e) { |
|
| 1784 | + } catch (PDOException $e) { |
|
| 1785 | 1785 | echo "error : ".$e->getMessage(); |
| 1786 | 1786 | } |
| 1787 | 1787 | } |
| 1788 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
| 1788 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
| 1789 | 1789 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1790 | 1790 | global $globalArchiveMonths, $globalDBdriver; |
| 1791 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1791 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1792 | 1792 | $Spotter = new Spotter($this->db); |
| 1793 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1793 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1794 | 1794 | $alliance_airlines = array(); |
| 1795 | 1795 | foreach ($airlines as $airline) { |
| 1796 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1796 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1797 | 1797 | } |
| 1798 | 1798 | if ($globalDBdriver == 'mysql') { |
| 1799 | 1799 | if ($month == '') { |
| 1800 | - $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"; |
|
| 1800 | + $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"; |
|
| 1801 | 1801 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1802 | 1802 | } else { |
| 1803 | - $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"; |
|
| 1804 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1803 | + $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"; |
|
| 1804 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1805 | 1805 | } |
| 1806 | 1806 | } else { |
| 1807 | 1807 | if ($month == '') { |
| 1808 | - $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"; |
|
| 1808 | + $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"; |
|
| 1809 | 1809 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1810 | 1810 | } else { |
| 1811 | - $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"; |
|
| 1812 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1811 | + $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"; |
|
| 1812 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1813 | 1813 | } |
| 1814 | 1814 | } |
| 1815 | 1815 | } else { |
| 1816 | 1816 | if ($globalDBdriver == 'mysql') { |
| 1817 | 1817 | if ($month == '') { |
| 1818 | 1818 | $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"; |
| 1819 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1819 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1820 | 1820 | } else { |
| 1821 | 1821 | $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"; |
| 1822 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1822 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | } else { |
| 1825 | 1825 | if ($month == '') { |
| 1826 | 1826 | $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"; |
| 1827 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1827 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1828 | 1828 | } else { |
| 1829 | 1829 | $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"; |
| 1830 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1830 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1831 | 1831 | } |
| 1832 | 1832 | } |
| 1833 | 1833 | } |
| 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 | echo "error : ".$e->getMessage(); |
| 1839 | 1839 | } |
| 1840 | 1840 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1843,17 +1843,17 @@ discard block |
||
| 1843 | 1843 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1844 | 1844 | global $globalArchiveMonths, $globalDBdriver; |
| 1845 | 1845 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1846 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1846 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1847 | 1847 | $Spotter = new Spotter($this->db); |
| 1848 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1848 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1849 | 1849 | $alliance_airlines = array(); |
| 1850 | 1850 | foreach ($airlines as $airline) { |
| 1851 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1851 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1852 | 1852 | } |
| 1853 | 1853 | if ($globalDBdriver == 'mysql') { |
| 1854 | - $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"; |
|
| 1854 | + $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"; |
|
| 1855 | 1855 | } else { |
| 1856 | - $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"; |
|
| 1856 | + $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"; |
|
| 1857 | 1857 | } |
| 1858 | 1858 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
| 1859 | 1859 | } else { |
@@ -1867,7 +1867,7 @@ discard block |
||
| 1867 | 1867 | try { |
| 1868 | 1868 | $sth = $this->db->prepare($query); |
| 1869 | 1869 | $sth->execute($query_values); |
| 1870 | - } catch(PDOException $e) { |
|
| 1870 | + } catch (PDOException $e) { |
|
| 1871 | 1871 | echo "error : ".$e->getMessage(); |
| 1872 | 1872 | } |
| 1873 | 1873 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1876,17 +1876,17 @@ discard block |
||
| 1876 | 1876 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1877 | 1877 | global $globalArchiveMonths, $globalDBdriver; |
| 1878 | 1878 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1879 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1879 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1880 | 1880 | $Spotter = new Spotter($this->db); |
| 1881 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1881 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1882 | 1882 | $alliance_airlines = array(); |
| 1883 | 1883 | foreach ($airlines as $airline) { |
| 1884 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1884 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1885 | 1885 | } |
| 1886 | 1886 | if ($globalDBdriver == 'mysql') { |
| 1887 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1887 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1888 | 1888 | } else { |
| 1889 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1889 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1890 | 1890 | } |
| 1891 | 1891 | } else { |
| 1892 | 1892 | if ($globalDBdriver == 'mysql') { |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | try { |
| 1899 | 1899 | $sth = $this->db->prepare($query); |
| 1900 | 1900 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 1901 | - } catch(PDOException $e) { |
|
| 1901 | + } catch (PDOException $e) { |
|
| 1902 | 1902 | echo "error : ".$e->getMessage(); |
| 1903 | 1903 | } |
| 1904 | 1904 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1915,7 +1915,7 @@ discard block |
||
| 1915 | 1915 | try { |
| 1916 | 1916 | $sth = $this->db->prepare($query); |
| 1917 | 1917 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1918 | - } catch(PDOException $e) { |
|
| 1918 | + } catch (PDOException $e) { |
|
| 1919 | 1919 | echo "error : ".$e->getMessage(); |
| 1920 | 1920 | } |
| 1921 | 1921 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1932,20 +1932,20 @@ discard block |
||
| 1932 | 1932 | try { |
| 1933 | 1933 | $sth = $this->db->prepare($query); |
| 1934 | 1934 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1935 | - } catch(PDOException $e) { |
|
| 1935 | + } catch (PDOException $e) { |
|
| 1936 | 1936 | echo "error : ".$e->getMessage(); |
| 1937 | 1937 | } |
| 1938 | 1938 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1939 | 1939 | return $all[0]['total']; |
| 1940 | 1940 | } |
| 1941 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
| 1941 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
| 1942 | 1942 | global $globalArchiveMonths, $globalDBdriver; |
| 1943 | 1943 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1944 | 1944 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1945 | 1945 | try { |
| 1946 | 1946 | $sth = $this->db->prepare($query); |
| 1947 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1948 | - } catch(PDOException $e) { |
|
| 1947 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
| 1948 | + } catch (PDOException $e) { |
|
| 1949 | 1949 | echo "error : ".$e->getMessage(); |
| 1950 | 1950 | } |
| 1951 | 1951 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1963,20 +1963,20 @@ discard block |
||
| 1963 | 1963 | try { |
| 1964 | 1964 | $sth = $this->db->prepare($query); |
| 1965 | 1965 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1966 | - } catch(PDOException $e) { |
|
| 1966 | + } catch (PDOException $e) { |
|
| 1967 | 1967 | echo "error : ".$e->getMessage(); |
| 1968 | 1968 | } |
| 1969 | 1969 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1970 | 1970 | return $all[0]['total']; |
| 1971 | 1971 | } |
| 1972 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
| 1972 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
| 1973 | 1973 | global $globalArchiveMonths, $globalDBdriver; |
| 1974 | 1974 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1975 | 1975 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1976 | 1976 | try { |
| 1977 | 1977 | $sth = $this->db->prepare($query); |
| 1978 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1979 | - } catch(PDOException $e) { |
|
| 1978 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
| 1979 | + } catch (PDOException $e) { |
|
| 1980 | 1980 | echo "error : ".$e->getMessage(); |
| 1981 | 1981 | } |
| 1982 | 1982 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | else return 0; |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1987 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1988 | 1988 | global $globalDBdriver; |
| 1989 | 1989 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1990 | 1990 | if ($globalDBdriver == 'mysql') { |
@@ -1992,15 +1992,15 @@ discard block |
||
| 1992 | 1992 | } else { |
| 1993 | 1993 | $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);"; |
| 1994 | 1994 | } |
| 1995 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1995 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1996 | 1996 | try { |
| 1997 | 1997 | $sth = $this->db->prepare($query); |
| 1998 | 1998 | $sth->execute($query_values); |
| 1999 | - } catch(PDOException $e) { |
|
| 1999 | + } catch (PDOException $e) { |
|
| 2000 | 2000 | return "error : ".$e->getMessage(); |
| 2001 | 2001 | } |
| 2002 | 2002 | } |
| 2003 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 2003 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 2004 | 2004 | global $globalDBdriver; |
| 2005 | 2005 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 2006 | 2006 | if ($globalDBdriver == 'mysql') { |
@@ -2009,11 +2009,11 @@ discard block |
||
| 2009 | 2009 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 2010 | 2010 | $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);"; |
| 2011 | 2011 | } |
| 2012 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2012 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2013 | 2013 | try { |
| 2014 | 2014 | $sth = $this->db->prepare($query); |
| 2015 | 2015 | $sth->execute($query_values); |
| 2016 | - } catch(PDOException $e) { |
|
| 2016 | + } catch (PDOException $e) { |
|
| 2017 | 2017 | return "error : ".$e->getMessage(); |
| 2018 | 2018 | } |
| 2019 | 2019 | } |
@@ -2037,95 +2037,95 @@ discard block |
||
| 2037 | 2037 | } |
| 2038 | 2038 | */ |
| 2039 | 2039 | |
| 2040 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
| 2040 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
| 2041 | 2041 | global $globalDBdriver; |
| 2042 | 2042 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
| 2043 | 2043 | $query_values = array(); |
| 2044 | 2044 | if ($globalDBdriver == 'mysql') { |
| 2045 | 2045 | if ($year != '') { |
| 2046 | 2046 | $query .= ' AND YEAR(stats_date) = :year'; |
| 2047 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2047 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2048 | 2048 | } |
| 2049 | 2049 | if ($month != '') { |
| 2050 | 2050 | $query .= ' AND MONTH(stats_date) = :month'; |
| 2051 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2051 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2052 | 2052 | } |
| 2053 | 2053 | if ($day != '') { |
| 2054 | 2054 | $query .= ' AND DAY(stats_date) = :day'; |
| 2055 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2055 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2056 | 2056 | } |
| 2057 | 2057 | } else { |
| 2058 | 2058 | if ($year != '') { |
| 2059 | 2059 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
| 2060 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2060 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | if ($month != '') { |
| 2063 | 2063 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
| 2064 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2064 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2065 | 2065 | } |
| 2066 | 2066 | if ($day != '') { |
| 2067 | 2067 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
| 2068 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2068 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | $query .= " ORDER BY source_name"; |
| 2072 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
| 2072 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
| 2073 | 2073 | try { |
| 2074 | 2074 | $sth = $this->db->prepare($query); |
| 2075 | 2075 | $sth->execute($query_values); |
| 2076 | - } catch(PDOException $e) { |
|
| 2076 | + } catch (PDOException $e) { |
|
| 2077 | 2077 | echo "error : ".$e->getMessage(); |
| 2078 | 2078 | } |
| 2079 | 2079 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2080 | 2080 | return $all; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
| 2083 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
| 2084 | 2084 | global $globalDBdriver; |
| 2085 | 2085 | if ($globalDBdriver == 'mysql') { |
| 2086 | 2086 | $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"; |
| 2087 | 2087 | } else { |
| 2088 | 2088 | $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);"; |
| 2089 | 2089 | } |
| 2090 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 2090 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
| 2091 | 2091 | try { |
| 2092 | 2092 | $sth = $this->db->prepare($query); |
| 2093 | 2093 | $sth->execute($query_values); |
| 2094 | - } catch(PDOException $e) { |
|
| 2094 | + } catch (PDOException $e) { |
|
| 2095 | 2095 | return "error : ".$e->getMessage(); |
| 2096 | 2096 | } |
| 2097 | 2097 | } |
| 2098 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 2098 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
| 2099 | 2099 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
| 2100 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2100 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2101 | 2101 | try { |
| 2102 | 2102 | $sth = $this->db->prepare($query); |
| 2103 | 2103 | $sth->execute($query_values); |
| 2104 | - } catch(PDOException $e) { |
|
| 2104 | + } catch (PDOException $e) { |
|
| 2105 | 2105 | return "error : ".$e->getMessage(); |
| 2106 | 2106 | } |
| 2107 | 2107 | } |
| 2108 | - public function addStatMarine($type,$date_name,$cnt,$filter_name = '') { |
|
| 2108 | + public function addStatMarine($type, $date_name, $cnt, $filter_name = '') { |
|
| 2109 | 2109 | $query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)"; |
| 2110 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2110 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2111 | 2111 | try { |
| 2112 | 2112 | $sth = $this->db->prepare($query); |
| 2113 | 2113 | $sth->execute($query_values); |
| 2114 | - } catch(PDOException $e) { |
|
| 2114 | + } catch (PDOException $e) { |
|
| 2115 | 2115 | return "error : ".$e->getMessage(); |
| 2116 | 2116 | } |
| 2117 | 2117 | } |
| 2118 | - public function addStatTracker($type,$date_name,$cnt,$filter_name = '') { |
|
| 2118 | + public function addStatTracker($type, $date_name, $cnt, $filter_name = '') { |
|
| 2119 | 2119 | $query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)"; |
| 2120 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2120 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2121 | 2121 | try { |
| 2122 | 2122 | $sth = $this->db->prepare($query); |
| 2123 | 2123 | $sth->execute($query_values); |
| 2124 | - } catch(PDOException $e) { |
|
| 2124 | + } catch (PDOException $e) { |
|
| 2125 | 2125 | return "error : ".$e->getMessage(); |
| 2126 | 2126 | } |
| 2127 | 2127 | } |
| 2128 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2128 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2129 | 2129 | global $globalDBdriver; |
| 2130 | 2130 | if ($globalDBdriver == 'mysql') { |
| 2131 | 2131 | if ($reset) { |
@@ -2140,15 +2140,15 @@ discard block |
||
| 2140 | 2140 | $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);"; |
| 2141 | 2141 | } |
| 2142 | 2142 | } |
| 2143 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2143 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 2144 | 2144 | try { |
| 2145 | 2145 | $sth = $this->db->prepare($query); |
| 2146 | 2146 | $sth->execute($query_values); |
| 2147 | - } catch(PDOException $e) { |
|
| 2147 | + } catch (PDOException $e) { |
|
| 2148 | 2148 | return "error : ".$e->getMessage(); |
| 2149 | 2149 | } |
| 2150 | 2150 | } |
| 2151 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2151 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2152 | 2152 | global $globalDBdriver; |
| 2153 | 2153 | if ($globalDBdriver == 'mysql') { |
| 2154 | 2154 | if ($reset) { |
@@ -2163,15 +2163,15 @@ discard block |
||
| 2163 | 2163 | $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);"; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
| 2166 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2166 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2167 | 2167 | try { |
| 2168 | 2168 | $sth = $this->db->prepare($query); |
| 2169 | 2169 | $sth->execute($query_values); |
| 2170 | - } catch(PDOException $e) { |
|
| 2170 | + } catch (PDOException $e) { |
|
| 2171 | 2171 | return "error : ".$e->getMessage(); |
| 2172 | 2172 | } |
| 2173 | 2173 | } |
| 2174 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2174 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2175 | 2175 | global $globalDBdriver; |
| 2176 | 2176 | if ($globalDBdriver == 'mysql') { |
| 2177 | 2177 | if ($reset) { |
@@ -2186,15 +2186,15 @@ discard block |
||
| 2186 | 2186 | $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);"; |
| 2187 | 2187 | } |
| 2188 | 2188 | } |
| 2189 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 2189 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
| 2190 | 2190 | try { |
| 2191 | 2191 | $sth = $this->db->prepare($query); |
| 2192 | 2192 | $sth->execute($query_values); |
| 2193 | - } catch(PDOException $e) { |
|
| 2193 | + } catch (PDOException $e) { |
|
| 2194 | 2194 | return "error : ".$e->getMessage(); |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | - public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) { |
|
| 2197 | + public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) { |
|
| 2198 | 2198 | global $globalDBdriver; |
| 2199 | 2199 | if ($globalDBdriver == 'mysql') { |
| 2200 | 2200 | if ($reset) { |
@@ -2209,15 +2209,15 @@ discard block |
||
| 2209 | 2209 | $query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
| 2210 | 2210 | } |
| 2211 | 2211 | } |
| 2212 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2212 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2213 | 2213 | try { |
| 2214 | 2214 | $sth = $this->db->prepare($query); |
| 2215 | 2215 | $sth->execute($query_values); |
| 2216 | - } catch(PDOException $e) { |
|
| 2216 | + } catch (PDOException $e) { |
|
| 2217 | 2217 | return "error : ".$e->getMessage(); |
| 2218 | 2218 | } |
| 2219 | 2219 | } |
| 2220 | - public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) { |
|
| 2220 | + public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) { |
|
| 2221 | 2221 | global $globalDBdriver; |
| 2222 | 2222 | if ($globalDBdriver == 'mysql') { |
| 2223 | 2223 | if ($reset) { |
@@ -2232,15 +2232,15 @@ discard block |
||
| 2232 | 2232 | $query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
| 2233 | 2233 | } |
| 2234 | 2234 | } |
| 2235 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2235 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2236 | 2236 | try { |
| 2237 | 2237 | $sth = $this->db->prepare($query); |
| 2238 | 2238 | $sth->execute($query_values); |
| 2239 | - } catch(PDOException $e) { |
|
| 2239 | + } catch (PDOException $e) { |
|
| 2240 | 2240 | return "error : ".$e->getMessage(); |
| 2241 | 2241 | } |
| 2242 | 2242 | } |
| 2243 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2243 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2244 | 2244 | global $globalDBdriver; |
| 2245 | 2245 | if ($globalDBdriver == 'mysql') { |
| 2246 | 2246 | if ($reset) { |
@@ -2255,15 +2255,15 @@ discard block |
||
| 2255 | 2255 | $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);"; |
| 2256 | 2256 | } |
| 2257 | 2257 | } |
| 2258 | - $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); |
|
| 2258 | + $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); |
|
| 2259 | 2259 | try { |
| 2260 | 2260 | $sth = $this->db->prepare($query); |
| 2261 | 2261 | $sth->execute($query_values); |
| 2262 | - } catch(PDOException $e) { |
|
| 2262 | + } catch (PDOException $e) { |
|
| 2263 | 2263 | return "error : ".$e->getMessage(); |
| 2264 | 2264 | } |
| 2265 | 2265 | } |
| 2266 | - public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) { |
|
| 2266 | + public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) { |
|
| 2267 | 2267 | global $globalDBdriver; |
| 2268 | 2268 | if ($globalDBdriver == 'mysql') { |
| 2269 | 2269 | if ($reset) { |
@@ -2278,15 +2278,15 @@ discard block |
||
| 2278 | 2278 | $query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type = :type AND filter_name = :filter_name);"; |
| 2279 | 2279 | } |
| 2280 | 2280 | } |
| 2281 | - $query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2281 | + $query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2282 | 2282 | try { |
| 2283 | 2283 | $sth = $this->db->prepare($query); |
| 2284 | 2284 | $sth->execute($query_values); |
| 2285 | - } catch(PDOException $e) { |
|
| 2285 | + } catch (PDOException $e) { |
|
| 2286 | 2286 | return "error : ".$e->getMessage(); |
| 2287 | 2287 | } |
| 2288 | 2288 | } |
| 2289 | - public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) { |
|
| 2289 | + public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) { |
|
| 2290 | 2290 | global $globalDBdriver; |
| 2291 | 2291 | if ($globalDBdriver == 'mysql') { |
| 2292 | 2292 | if ($reset) { |
@@ -2301,15 +2301,15 @@ discard block |
||
| 2301 | 2301 | $query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; |
| 2302 | 2302 | } |
| 2303 | 2303 | } |
| 2304 | - $query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2304 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2305 | 2305 | try { |
| 2306 | 2306 | $sth = $this->db->prepare($query); |
| 2307 | 2307 | $sth->execute($query_values); |
| 2308 | - } catch(PDOException $e) { |
|
| 2308 | + } catch (PDOException $e) { |
|
| 2309 | 2309 | return "error : ".$e->getMessage(); |
| 2310 | 2310 | } |
| 2311 | 2311 | } |
| 2312 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
| 2312 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
| 2313 | 2313 | global $globalDBdriver; |
| 2314 | 2314 | if ($globalDBdriver == 'mysql') { |
| 2315 | 2315 | if ($reset) { |
@@ -2324,15 +2324,15 @@ discard block |
||
| 2324 | 2324 | $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);"; |
| 2325 | 2325 | } |
| 2326 | 2326 | } |
| 2327 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 2327 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 2328 | 2328 | try { |
| 2329 | 2329 | $sth = $this->db->prepare($query); |
| 2330 | 2330 | $sth->execute($query_values); |
| 2331 | - } catch(PDOException $e) { |
|
| 2331 | + } catch (PDOException $e) { |
|
| 2332 | 2332 | return "error : ".$e->getMessage(); |
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
| 2335 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
| 2336 | 2336 | global $globalDBdriver; |
| 2337 | 2337 | if ($globalDBdriver == 'mysql') { |
| 2338 | 2338 | if ($reset) { |
@@ -2347,15 +2347,15 @@ discard block |
||
| 2347 | 2347 | $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);"; |
| 2348 | 2348 | } |
| 2349 | 2349 | } |
| 2350 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 2350 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 2351 | 2351 | try { |
| 2352 | 2352 | $sth = $this->db->prepare($query); |
| 2353 | 2353 | $sth->execute($query_values); |
| 2354 | - } catch(PDOException $e) { |
|
| 2354 | + } catch (PDOException $e) { |
|
| 2355 | 2355 | return "error : ".$e->getMessage(); |
| 2356 | 2356 | } |
| 2357 | 2357 | } |
| 2358 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
| 2358 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
| 2359 | 2359 | global $globalDBdriver; |
| 2360 | 2360 | if ($globalDBdriver == 'mysql') { |
| 2361 | 2361 | if ($reset) { |
@@ -2370,15 +2370,15 @@ discard block |
||
| 2370 | 2370 | $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);"; |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
| 2373 | - $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); |
|
| 2373 | + $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); |
|
| 2374 | 2374 | try { |
| 2375 | 2375 | $sth = $this->db->prepare($query); |
| 2376 | 2376 | $sth->execute($query_values); |
| 2377 | - } catch(PDOException $e) { |
|
| 2377 | + } catch (PDOException $e) { |
|
| 2378 | 2378 | return "error : ".$e->getMessage(); |
| 2379 | 2379 | } |
| 2380 | 2380 | } |
| 2381 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2381 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2382 | 2382 | global $globalDBdriver; |
| 2383 | 2383 | if ($airport_icao != '') { |
| 2384 | 2384 | if ($globalDBdriver == 'mysql') { |
@@ -2394,16 +2394,16 @@ discard block |
||
| 2394 | 2394 | $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);"; |
| 2395 | 2395 | } |
| 2396 | 2396 | } |
| 2397 | - $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); |
|
| 2397 | + $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); |
|
| 2398 | 2398 | try { |
| 2399 | 2399 | $sth = $this->db->prepare($query); |
| 2400 | 2400 | $sth->execute($query_values); |
| 2401 | - } catch(PDOException $e) { |
|
| 2401 | + } catch (PDOException $e) { |
|
| 2402 | 2402 | return "error : ".$e->getMessage(); |
| 2403 | 2403 | } |
| 2404 | 2404 | } |
| 2405 | 2405 | } |
| 2406 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
| 2406 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
| 2407 | 2407 | global $globalDBdriver; |
| 2408 | 2408 | if ($airport_icao != '') { |
| 2409 | 2409 | if ($globalDBdriver == 'mysql') { |
@@ -2411,16 +2411,16 @@ discard block |
||
| 2411 | 2411 | } else { |
| 2412 | 2412 | $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);"; |
| 2413 | 2413 | } |
| 2414 | - $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); |
|
| 2414 | + $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); |
|
| 2415 | 2415 | try { |
| 2416 | 2416 | $sth = $this->db->prepare($query); |
| 2417 | 2417 | $sth->execute($query_values); |
| 2418 | - } catch(PDOException $e) { |
|
| 2418 | + } catch (PDOException $e) { |
|
| 2419 | 2419 | return "error : ".$e->getMessage(); |
| 2420 | 2420 | } |
| 2421 | 2421 | } |
| 2422 | 2422 | } |
| 2423 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 2423 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 2424 | 2424 | global $globalDBdriver; |
| 2425 | 2425 | if ($airport_icao != '') { |
| 2426 | 2426 | if ($globalDBdriver == 'mysql') { |
@@ -2436,16 +2436,16 @@ discard block |
||
| 2436 | 2436 | $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);"; |
| 2437 | 2437 | } |
| 2438 | 2438 | } |
| 2439 | - $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); |
|
| 2439 | + $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); |
|
| 2440 | 2440 | try { |
| 2441 | 2441 | $sth = $this->db->prepare($query); |
| 2442 | 2442 | $sth->execute($query_values); |
| 2443 | - } catch(PDOException $e) { |
|
| 2443 | + } catch (PDOException $e) { |
|
| 2444 | 2444 | return "error : ".$e->getMessage(); |
| 2445 | 2445 | } |
| 2446 | 2446 | } |
| 2447 | 2447 | } |
| 2448 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
| 2448 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
| 2449 | 2449 | global $globalDBdriver; |
| 2450 | 2450 | if ($airport_icao != '') { |
| 2451 | 2451 | if ($globalDBdriver == 'mysql') { |
@@ -2453,11 +2453,11 @@ discard block |
||
| 2453 | 2453 | } else { |
| 2454 | 2454 | $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);"; |
| 2455 | 2455 | } |
| 2456 | - $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); |
|
| 2456 | + $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); |
|
| 2457 | 2457 | try { |
| 2458 | 2458 | $sth = $this->db->prepare($query); |
| 2459 | 2459 | $sth->execute($query_values); |
| 2460 | - } catch(PDOException $e) { |
|
| 2460 | + } catch (PDOException $e) { |
|
| 2461 | 2461 | return "error : ".$e->getMessage(); |
| 2462 | 2462 | } |
| 2463 | 2463 | } |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | try { |
| 2470 | 2470 | $sth = $this->db->prepare($query); |
| 2471 | 2471 | $sth->execute($query_values); |
| 2472 | - } catch(PDOException $e) { |
|
| 2472 | + } catch (PDOException $e) { |
|
| 2473 | 2473 | return "error : ".$e->getMessage(); |
| 2474 | 2474 | } |
| 2475 | 2475 | } |
@@ -2479,7 +2479,7 @@ discard block |
||
| 2479 | 2479 | try { |
| 2480 | 2480 | $sth = $this->db->prepare($query); |
| 2481 | 2481 | $sth->execute($query_values); |
| 2482 | - } catch(PDOException $e) { |
|
| 2482 | + } catch (PDOException $e) { |
|
| 2483 | 2483 | return "error : ".$e->getMessage(); |
| 2484 | 2484 | } |
| 2485 | 2485 | } |
@@ -2489,7 +2489,7 @@ discard block |
||
| 2489 | 2489 | try { |
| 2490 | 2490 | $sth = $this->db->prepare($query); |
| 2491 | 2491 | $sth->execute($query_values); |
| 2492 | - } catch(PDOException $e) { |
|
| 2492 | + } catch (PDOException $e) { |
|
| 2493 | 2493 | return "error : ".$e->getMessage(); |
| 2494 | 2494 | } |
| 2495 | 2495 | } |
@@ -2499,7 +2499,7 @@ discard block |
||
| 2499 | 2499 | try { |
| 2500 | 2500 | $sth = $this->db->prepare($query); |
| 2501 | 2501 | $sth->execute($query_values); |
| 2502 | - } catch(PDOException $e) { |
|
| 2502 | + } catch (PDOException $e) { |
|
| 2503 | 2503 | return "error : ".$e->getMessage(); |
| 2504 | 2504 | } |
| 2505 | 2505 | } |
@@ -2509,13 +2509,13 @@ discard block |
||
| 2509 | 2509 | try { |
| 2510 | 2510 | $sth = $this->db->prepare($query); |
| 2511 | 2511 | $sth->execute($query_values); |
| 2512 | - } catch(PDOException $e) { |
|
| 2512 | + } catch (PDOException $e) { |
|
| 2513 | 2513 | return "error : ".$e->getMessage(); |
| 2514 | 2514 | } |
| 2515 | 2515 | } |
| 2516 | 2516 | |
| 2517 | 2517 | public function addOldStats() { |
| 2518 | - global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
| 2518 | + global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
| 2519 | 2519 | $Common = new Common(); |
| 2520 | 2520 | $Connection = new Connection($this->db); |
| 2521 | 2521 | date_default_timezone_set('UTC'); |
@@ -2530,9 +2530,9 @@ discard block |
||
| 2530 | 2530 | $filtername = 'marine'; |
| 2531 | 2531 | if ($Connection->tableExists('countries')) { |
| 2532 | 2532 | if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
| 2533 | - $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
|
| 2533 | + $alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day); |
|
| 2534 | 2534 | foreach ($alldata as $number) { |
| 2535 | - echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
|
| 2535 | + echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset); |
|
| 2536 | 2536 | } |
| 2537 | 2537 | } |
| 2538 | 2538 | if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
@@ -2542,44 +2542,44 @@ discard block |
||
| 2542 | 2542 | $lastyear = false; |
| 2543 | 2543 | foreach ($alldata as $number) { |
| 2544 | 2544 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2545 | - $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2545 | + $this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2546 | 2546 | } |
| 2547 | 2547 | echo 'Marine data...'."\n"; |
| 2548 | 2548 | $this->deleteStatMarine('month'); |
| 2549 | 2549 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2550 | 2550 | $alldata = $Marine->countAllDatesLastMonth($filter_last_month); |
| 2551 | 2551 | foreach ($alldata as $number) { |
| 2552 | - $this->addStatMarine('month',$number['date_name'],$number['date_count']); |
|
| 2552 | + $this->addStatMarine('month', $number['date_name'], $number['date_count']); |
|
| 2553 | 2553 | } |
| 2554 | 2554 | echo '-> countAllDates...'."\n"; |
| 2555 | 2555 | $previousdata = $this->countAllDatesMarine(); |
| 2556 | 2556 | $this->deleteStatMarine('date'); |
| 2557 | - $alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month)); |
|
| 2557 | + $alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month)); |
|
| 2558 | 2558 | $values = array(); |
| 2559 | 2559 | foreach ($alldata as $cnt) { |
| 2560 | 2560 | $values[] = $cnt['date_count']; |
| 2561 | 2561 | } |
| 2562 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2563 | - array_splice($alldata,11); |
|
| 2562 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2563 | + array_splice($alldata, 11); |
|
| 2564 | 2564 | foreach ($alldata as $number) { |
| 2565 | - $this->addStatMarine('date',$number['date_name'],$number['date_count']); |
|
| 2565 | + $this->addStatMarine('date', $number['date_name'], $number['date_count']); |
|
| 2566 | 2566 | } |
| 2567 | 2567 | |
| 2568 | 2568 | $this->deleteStatMarine('hour'); |
| 2569 | 2569 | echo '-> countAllHours...'."\n"; |
| 2570 | - $alldata = $Marine->countAllHours('hour',$filter_last_month); |
|
| 2570 | + $alldata = $Marine->countAllHours('hour', $filter_last_month); |
|
| 2571 | 2571 | foreach ($alldata as $number) { |
| 2572 | - $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
|
| 2572 | + $this->addStatMarine('hour', $number['hour_name'], $number['hour_count']); |
|
| 2573 | 2573 | } |
| 2574 | 2574 | if ($globalDebug) echo 'Count all types...'."\n"; |
| 2575 | - $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
|
| 2575 | + $alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day); |
|
| 2576 | 2576 | foreach ($alldata as $number) { |
| 2577 | - $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
|
| 2577 | + $this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset); |
|
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | 2580 | echo 'Insert last stats update date...'."\n"; |
| 2581 | 2581 | date_default_timezone_set('UTC'); |
| 2582 | - $this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s')); |
|
| 2582 | + $this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s')); |
|
| 2583 | 2583 | } |
| 2584 | 2584 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2585 | 2585 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
@@ -2591,9 +2591,9 @@ discard block |
||
| 2591 | 2591 | $Tracker = new Tracker($this->db); |
| 2592 | 2592 | if ($Connection->tableExists('countries')) { |
| 2593 | 2593 | if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
| 2594 | - $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
|
| 2594 | + $alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day); |
|
| 2595 | 2595 | foreach ($alldata as $number) { |
| 2596 | - $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
|
| 2596 | + $this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset); |
|
| 2597 | 2597 | } |
| 2598 | 2598 | } |
| 2599 | 2599 | if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
@@ -2603,43 +2603,43 @@ discard block |
||
| 2603 | 2603 | $lastyear = false; |
| 2604 | 2604 | foreach ($alldata as $number) { |
| 2605 | 2605 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2606 | - $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2606 | + $this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2607 | 2607 | } |
| 2608 | 2608 | echo 'Tracker data...'."\n"; |
| 2609 | 2609 | $this->deleteStatTracker('month'); |
| 2610 | 2610 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2611 | 2611 | $alldata = $Tracker->countAllDatesLastMonth($filter_last_month); |
| 2612 | 2612 | foreach ($alldata as $number) { |
| 2613 | - $this->addStatTracker('month',$number['date_name'],$number['date_count']); |
|
| 2613 | + $this->addStatTracker('month', $number['date_name'], $number['date_count']); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | echo '-> countAllDates...'."\n"; |
| 2616 | 2616 | $previousdata = $this->countAllDatesTracker(); |
| 2617 | 2617 | $this->deleteStatTracker('date'); |
| 2618 | - $alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month)); |
|
| 2618 | + $alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month)); |
|
| 2619 | 2619 | $values = array(); |
| 2620 | 2620 | foreach ($alldata as $cnt) { |
| 2621 | 2621 | $values[] = $cnt['date_count']; |
| 2622 | 2622 | } |
| 2623 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2624 | - array_splice($alldata,11); |
|
| 2623 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2624 | + array_splice($alldata, 11); |
|
| 2625 | 2625 | foreach ($alldata as $number) { |
| 2626 | - $this->addStatTracker('date',$number['date_name'],$number['date_count']); |
|
| 2626 | + $this->addStatTracker('date', $number['date_name'], $number['date_count']); |
|
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | $this->deleteStatTracker('hour'); |
| 2630 | 2630 | echo '-> countAllHours...'."\n"; |
| 2631 | - $alldata = $Tracker->countAllHours('hour',$filter_last_month); |
|
| 2631 | + $alldata = $Tracker->countAllHours('hour', $filter_last_month); |
|
| 2632 | 2632 | foreach ($alldata as $number) { |
| 2633 | - $this->addStatTracker('hour',$number['hour_name'],$number['hour_count']); |
|
| 2633 | + $this->addStatTracker('hour', $number['hour_name'], $number['hour_count']); |
|
| 2634 | 2634 | } |
| 2635 | 2635 | if ($globalDebug) echo 'Count all types...'."\n"; |
| 2636 | - $alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day); |
|
| 2636 | + $alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day); |
|
| 2637 | 2637 | foreach ($alldata as $number) { |
| 2638 | - $this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset); |
|
| 2638 | + $this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | echo 'Insert last stats update date...'."\n"; |
| 2641 | 2641 | date_default_timezone_set('UTC'); |
| 2642 | - $this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s')); |
|
| 2642 | + $this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s')); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
@@ -2657,41 +2657,41 @@ discard block |
||
| 2657 | 2657 | $Spotter = new Spotter($this->db); |
| 2658 | 2658 | |
| 2659 | 2659 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 2660 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
| 2660 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
| 2661 | 2661 | foreach ($alldata as $number) { |
| 2662 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
| 2662 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 2665 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
| 2665 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
| 2666 | 2666 | foreach ($alldata as $number) { |
| 2667 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
| 2667 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
| 2668 | 2668 | } |
| 2669 | 2669 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
| 2670 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
| 2670 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
| 2671 | 2671 | foreach ($alldata as $number) { |
| 2672 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
| 2672 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 2675 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
| 2675 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
| 2676 | 2676 | foreach ($alldata as $number) { |
| 2677 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2677 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2678 | 2678 | } |
| 2679 | 2679 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 2680 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
| 2680 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
| 2681 | 2681 | foreach ($alldata as $number) { |
| 2682 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
| 2682 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 2685 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
| 2685 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
| 2686 | 2686 | foreach ($alldata as $number) { |
| 2687 | 2687 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
| 2688 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
| 2688 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 2692 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
| 2692 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
| 2693 | 2693 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 2694 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 2694 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
| 2695 | 2695 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 2696 | 2696 | $alldata = array(); |
| 2697 | 2697 | foreach ($pall as $value) { |
@@ -2708,14 +2708,14 @@ discard block |
||
| 2708 | 2708 | foreach ($alldata as $key => $row) { |
| 2709 | 2709 | $count[$key] = $row['airport_departure_icao_count']; |
| 2710 | 2710 | } |
| 2711 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2711 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2712 | 2712 | foreach ($alldata as $number) { |
| 2713 | - 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); |
|
| 2713 | + 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); |
|
| 2714 | 2714 | } |
| 2715 | 2715 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 2716 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
| 2716 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
| 2717 | 2717 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 2718 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 2718 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
| 2719 | 2719 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 2720 | 2720 | $alldata = array(); |
| 2721 | 2721 | foreach ($pall as $value) { |
@@ -2732,18 +2732,18 @@ discard block |
||
| 2732 | 2732 | foreach ($alldata as $key => $row) { |
| 2733 | 2733 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2734 | 2734 | } |
| 2735 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2735 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2736 | 2736 | foreach ($alldata as $number) { |
| 2737 | - 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); |
|
| 2737 | + 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); |
|
| 2738 | 2738 | } |
| 2739 | 2739 | if ($Connection->tableExists('countries')) { |
| 2740 | 2740 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
| 2741 | 2741 | //$SpotterArchive = new SpotterArchive(); |
| 2742 | 2742 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2743 | 2743 | $Spotter = new Spotter($this->db); |
| 2744 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
| 2744 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
| 2745 | 2745 | foreach ($alldata as $number) { |
| 2746 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
| 2746 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
| 2747 | 2747 | } |
| 2748 | 2748 | } |
| 2749 | 2749 | |
@@ -2753,12 +2753,12 @@ discard block |
||
| 2753 | 2753 | $this->deleteStatsByType('fatalities_byyear'); |
| 2754 | 2754 | $alldata = $Accident->countFatalitiesByYear(); |
| 2755 | 2755 | foreach ($alldata as $number) { |
| 2756 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
| 2756 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
| 2757 | 2757 | } |
| 2758 | 2758 | $this->deleteStatsByType('fatalities_bymonth'); |
| 2759 | 2759 | $alldata = $Accident->countFatalitiesLast12Months(); |
| 2760 | 2760 | foreach ($alldata as $number) { |
| 2761 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
| 2761 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
| 2762 | 2762 | } |
| 2763 | 2763 | } |
| 2764 | 2764 | |
@@ -2772,37 +2772,37 @@ discard block |
||
| 2772 | 2772 | $lastyear = false; |
| 2773 | 2773 | foreach ($alldata as $number) { |
| 2774 | 2774 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2775 | - $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']))); |
|
| 2775 | + $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']))); |
|
| 2776 | 2776 | } |
| 2777 | 2777 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
| 2778 | 2778 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2779 | 2779 | foreach ($alldata as $number) { |
| 2780 | - $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']))); |
|
| 2780 | + $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']))); |
|
| 2781 | 2781 | } |
| 2782 | 2782 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 2783 | 2783 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2784 | 2784 | foreach ($alldata as $number) { |
| 2785 | - $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']))); |
|
| 2785 | + $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']))); |
|
| 2786 | 2786 | } |
| 2787 | 2787 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 2788 | 2788 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2789 | 2789 | foreach ($alldata as $number) { |
| 2790 | - $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']))); |
|
| 2790 | + $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']))); |
|
| 2791 | 2791 | } |
| 2792 | 2792 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
| 2793 | 2793 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2794 | 2794 | foreach ($alldata as $number) { |
| 2795 | - $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']))); |
|
| 2795 | + $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']))); |
|
| 2796 | 2796 | } |
| 2797 | 2797 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2798 | 2798 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2799 | 2799 | foreach ($alldata as $number) { |
| 2800 | - $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']))); |
|
| 2800 | + $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']))); |
|
| 2801 | 2801 | } |
| 2802 | 2802 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2803 | 2803 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2804 | 2804 | foreach ($alldata as $number) { |
| 2805 | - $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']))); |
|
| 2805 | + $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']))); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | if ($globalDebug) echo 'Airports data...'."\n"; |
| 2808 | 2808 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2847,7 +2847,7 @@ discard block |
||
| 2847 | 2847 | } |
| 2848 | 2848 | $alldata = $pall; |
| 2849 | 2849 | foreach ($alldata as $number) { |
| 2850 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
| 2850 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
| 2851 | 2851 | } |
| 2852 | 2852 | echo '...Arrival'."\n"; |
| 2853 | 2853 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2888,7 +2888,7 @@ discard block |
||
| 2888 | 2888 | } |
| 2889 | 2889 | $alldata = $pall; |
| 2890 | 2890 | foreach ($alldata as $number) { |
| 2891 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
| 2891 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
| 2892 | 2892 | } |
| 2893 | 2893 | |
| 2894 | 2894 | echo 'Flights data...'."\n"; |
@@ -2896,28 +2896,28 @@ discard block |
||
| 2896 | 2896 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2897 | 2897 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
| 2898 | 2898 | foreach ($alldata as $number) { |
| 2899 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
| 2899 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
| 2900 | 2900 | } |
| 2901 | 2901 | echo '-> countAllDates...'."\n"; |
| 2902 | 2902 | $previousdata = $this->countAllDates(); |
| 2903 | 2903 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
| 2904 | 2904 | $this->deleteStatFlight('date'); |
| 2905 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
| 2905 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
| 2906 | 2906 | $values = array(); |
| 2907 | 2907 | foreach ($alldata as $cnt) { |
| 2908 | 2908 | $values[] = $cnt['date_count']; |
| 2909 | 2909 | } |
| 2910 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2911 | - array_splice($alldata,11); |
|
| 2910 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2911 | + array_splice($alldata, 11); |
|
| 2912 | 2912 | foreach ($alldata as $number) { |
| 2913 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
| 2913 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
| 2914 | 2914 | } |
| 2915 | 2915 | |
| 2916 | 2916 | $this->deleteStatFlight('hour'); |
| 2917 | 2917 | echo '-> countAllHours...'."\n"; |
| 2918 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
| 2918 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
| 2919 | 2919 | foreach ($alldata as $number) { |
| 2920 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
| 2920 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | 2923 | // Count by airlines |
@@ -2926,42 +2926,42 @@ discard block |
||
| 2926 | 2926 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
| 2927 | 2927 | $SpotterArchive = new SpotterArchive($this->db); |
| 2928 | 2928 | //$Spotter = new Spotter($this->db); |
| 2929 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
| 2929 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
| 2930 | 2930 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 2931 | 2931 | foreach ($alldata as $number) { |
| 2932 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
| 2932 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
| 2933 | 2933 | } |
| 2934 | 2934 | } |
| 2935 | 2935 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
| 2936 | 2936 | $Spotter = new Spotter($this->db); |
| 2937 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
| 2937 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
| 2938 | 2938 | foreach ($alldata as $number) { |
| 2939 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
| 2939 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
| 2940 | 2940 | } |
| 2941 | 2941 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
| 2942 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
| 2942 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
| 2943 | 2943 | foreach ($alldata as $number) { |
| 2944 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
| 2944 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
| 2945 | 2945 | } |
| 2946 | 2946 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
| 2947 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
| 2947 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
| 2948 | 2948 | foreach ($alldata as $number) { |
| 2949 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2949 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2950 | 2950 | } |
| 2951 | 2951 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
| 2952 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
| 2952 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
| 2953 | 2953 | foreach ($alldata as $number) { |
| 2954 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
| 2954 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
| 2957 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
| 2957 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
| 2958 | 2958 | foreach ($alldata as $number) { |
| 2959 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
| 2959 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
| 2960 | 2960 | } |
| 2961 | 2961 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 2962 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2962 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2963 | 2963 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 2964 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2964 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2965 | 2965 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 2966 | 2966 | //$alldata = array(); |
| 2967 | 2967 | foreach ($dall as $value) { |
@@ -2981,12 +2981,12 @@ discard block |
||
| 2981 | 2981 | } |
| 2982 | 2982 | $alldata = $pall; |
| 2983 | 2983 | foreach ($alldata as $number) { |
| 2984 | - 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); |
|
| 2984 | + 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); |
|
| 2985 | 2985 | } |
| 2986 | 2986 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 2987 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2987 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2988 | 2988 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 2989 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2989 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2990 | 2990 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 2991 | 2991 | //$alldata = array(); |
| 2992 | 2992 | foreach ($dall as $value) { |
@@ -3006,7 +3006,7 @@ discard block |
||
| 3006 | 3006 | } |
| 3007 | 3007 | $alldata = $pall; |
| 3008 | 3008 | foreach ($alldata as $number) { |
| 3009 | - 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); |
|
| 3009 | + 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); |
|
| 3010 | 3010 | } |
| 3011 | 3011 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
| 3012 | 3012 | $Spotter = new Spotter($this->db); |
@@ -3014,27 +3014,27 @@ discard block |
||
| 3014 | 3014 | $lastyear = false; |
| 3015 | 3015 | foreach ($alldata as $number) { |
| 3016 | 3016 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 3017 | - $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']); |
|
| 3017 | + $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']); |
|
| 3018 | 3018 | } |
| 3019 | 3019 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
| 3020 | 3020 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 3021 | 3021 | foreach ($alldata as $number) { |
| 3022 | - $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']); |
|
| 3022 | + $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']); |
|
| 3023 | 3023 | } |
| 3024 | 3024 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
| 3025 | 3025 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 3026 | 3026 | foreach ($alldata as $number) { |
| 3027 | - $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']); |
|
| 3027 | + $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']); |
|
| 3028 | 3028 | } |
| 3029 | 3029 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
| 3030 | 3030 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 3031 | 3031 | foreach ($alldata as $number) { |
| 3032 | - $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']); |
|
| 3032 | + $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']); |
|
| 3033 | 3033 | } |
| 3034 | 3034 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
| 3035 | 3035 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 3036 | 3036 | foreach ($alldata as $number) { |
| 3037 | - $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']); |
|
| 3037 | + $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']); |
|
| 3038 | 3038 | } |
| 3039 | 3039 | if ($globalDebug) echo '...Departure'."\n"; |
| 3040 | 3040 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -3057,7 +3057,7 @@ discard block |
||
| 3057 | 3057 | } |
| 3058 | 3058 | $alldata = $pall; |
| 3059 | 3059 | foreach ($alldata as $number) { |
| 3060 | - $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']); |
|
| 3060 | + $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']); |
|
| 3061 | 3061 | } |
| 3062 | 3062 | if ($globalDebug) echo '...Arrival'."\n"; |
| 3063 | 3063 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -3080,32 +3080,32 @@ discard block |
||
| 3080 | 3080 | } |
| 3081 | 3081 | $alldata = $pall; |
| 3082 | 3082 | foreach ($alldata as $number) { |
| 3083 | - $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']); |
|
| 3083 | + $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']); |
|
| 3084 | 3084 | } |
| 3085 | 3085 | |
| 3086 | 3086 | if ($globalDebug) echo 'Flights data...'."\n"; |
| 3087 | 3087 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
| 3088 | 3088 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 3089 | 3089 | foreach ($alldata as $number) { |
| 3090 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
| 3090 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 3091 | 3091 | } |
| 3092 | 3092 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
| 3093 | 3093 | //$previousdata = $this->countAllDatesByAirlines(); |
| 3094 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 3094 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 3095 | 3095 | $values = array(); |
| 3096 | 3096 | foreach ($alldata as $cnt) { |
| 3097 | 3097 | $values[] = $cnt['date_count']; |
| 3098 | 3098 | } |
| 3099 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 3100 | - array_splice($alldata,11); |
|
| 3099 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 3100 | + array_splice($alldata, 11); |
|
| 3101 | 3101 | foreach ($alldata as $number) { |
| 3102 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
| 3102 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 3103 | 3103 | } |
| 3104 | 3104 | |
| 3105 | 3105 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
| 3106 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
| 3106 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
| 3107 | 3107 | foreach ($alldata as $number) { |
| 3108 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
| 3108 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
| 3109 | 3109 | } |
| 3110 | 3110 | |
| 3111 | 3111 | // Stats by filters |
@@ -3129,7 +3129,7 @@ discard block |
||
| 3129 | 3129 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 3130 | 3130 | } |
| 3131 | 3131 | } |
| 3132 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 3132 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 3133 | 3133 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 3134 | 3134 | $reset = true; |
| 3135 | 3135 | } |
@@ -3137,38 +3137,38 @@ discard block |
||
| 3137 | 3137 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
| 3138 | 3138 | $Spotter = new Spotter($this->db); |
| 3139 | 3139 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 3140 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
| 3140 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
| 3141 | 3141 | foreach ($alldata as $number) { |
| 3142 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
| 3142 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 3145 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
| 3145 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
| 3146 | 3146 | foreach ($alldata as $number) { |
| 3147 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
| 3147 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
| 3148 | 3148 | } |
| 3149 | 3149 | if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
| 3150 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
| 3150 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
| 3151 | 3151 | foreach ($alldata as $number) { |
| 3152 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
| 3152 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
| 3153 | 3153 | } |
| 3154 | 3154 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 3155 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
| 3155 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
| 3156 | 3156 | foreach ($alldata as $number) { |
| 3157 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
| 3157 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
| 3158 | 3158 | } |
| 3159 | 3159 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 3160 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
| 3160 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
| 3161 | 3161 | foreach ($alldata as $number) { |
| 3162 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
| 3162 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
| 3163 | 3163 | } |
| 3164 | 3164 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 3165 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
| 3165 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
| 3166 | 3166 | foreach ($alldata as $number) { |
| 3167 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
| 3167 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
| 3168 | 3168 | } |
| 3169 | 3169 | if ($globalDebug) echo 'Count departure airports...'."\n"; |
| 3170 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
| 3171 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 3170 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 3171 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 3172 | 3172 | $alldata = array(); |
| 3173 | 3173 | foreach ($pall as $value) { |
| 3174 | 3174 | $icao = $value['airport_departure_icao']; |
@@ -3184,13 +3184,13 @@ discard block |
||
| 3184 | 3184 | foreach ($alldata as $key => $row) { |
| 3185 | 3185 | $count[$key] = $row['airport_departure_icao_count']; |
| 3186 | 3186 | } |
| 3187 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 3187 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 3188 | 3188 | foreach ($alldata as $number) { |
| 3189 | - 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); |
|
| 3189 | + 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); |
|
| 3190 | 3190 | } |
| 3191 | 3191 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 3192 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 3193 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 3192 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 3193 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 3194 | 3194 | $alldata = array(); |
| 3195 | 3195 | foreach ($pall as $value) { |
| 3196 | 3196 | $icao = $value['airport_arrival_icao']; |
@@ -3206,9 +3206,9 @@ discard block |
||
| 3206 | 3206 | foreach ($alldata as $key => $row) { |
| 3207 | 3207 | $count[$key] = $row['airport_arrival_icao_count']; |
| 3208 | 3208 | } |
| 3209 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 3209 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 3210 | 3210 | foreach ($alldata as $number) { |
| 3211 | - 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); |
|
| 3211 | + 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); |
|
| 3212 | 3212 | } |
| 3213 | 3213 | if ($globalDebug) echo 'Count all months...'."\n"; |
| 3214 | 3214 | $Spotter = new Spotter($this->db); |
@@ -3216,36 +3216,36 @@ discard block |
||
| 3216 | 3216 | $lastyear = false; |
| 3217 | 3217 | foreach ($alldata as $number) { |
| 3218 | 3218 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 3219 | - $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); |
|
| 3219 | + $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); |
|
| 3220 | 3220 | } |
| 3221 | 3221 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 3222 | 3222 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 3223 | 3223 | foreach ($alldata as $number) { |
| 3224 | - $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); |
|
| 3224 | + $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); |
|
| 3225 | 3225 | } |
| 3226 | 3226 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 3227 | 3227 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 3228 | 3228 | foreach ($alldata as $number) { |
| 3229 | - $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); |
|
| 3229 | + $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); |
|
| 3230 | 3230 | } |
| 3231 | 3231 | if ($globalDebug) echo 'Count all military by months...'."\n"; |
| 3232 | 3232 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 3233 | 3233 | foreach ($alldata as $number) { |
| 3234 | - $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); |
|
| 3234 | + $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); |
|
| 3235 | 3235 | } |
| 3236 | 3236 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 3237 | 3237 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 3238 | 3238 | foreach ($alldata as $number) { |
| 3239 | - $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); |
|
| 3239 | + $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); |
|
| 3240 | 3240 | } |
| 3241 | 3241 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 3242 | 3242 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 3243 | 3243 | foreach ($alldata as $number) { |
| 3244 | - $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); |
|
| 3244 | + $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); |
|
| 3245 | 3245 | } |
| 3246 | 3246 | echo '...Departure'."\n"; |
| 3247 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
| 3248 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 3247 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
| 3248 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
| 3249 | 3249 | foreach ($dall as $value) { |
| 3250 | 3250 | $icao = $value['departure_airport_icao']; |
| 3251 | 3251 | $ddate = $value['date']; |
@@ -3263,11 +3263,11 @@ discard block |
||
| 3263 | 3263 | } |
| 3264 | 3264 | $alldata = $pall; |
| 3265 | 3265 | foreach ($alldata as $number) { |
| 3266 | - $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); |
|
| 3266 | + $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); |
|
| 3267 | 3267 | } |
| 3268 | 3268 | echo '...Arrival'."\n"; |
| 3269 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
| 3270 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 3269 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
| 3270 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
| 3271 | 3271 | foreach ($dall as $value) { |
| 3272 | 3272 | $icao = $value['arrival_airport_icao']; |
| 3273 | 3273 | $ddate = $value['date']; |
@@ -3285,39 +3285,39 @@ discard block |
||
| 3285 | 3285 | } |
| 3286 | 3286 | $alldata = $pall; |
| 3287 | 3287 | foreach ($alldata as $number) { |
| 3288 | - $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); |
|
| 3288 | + $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); |
|
| 3289 | 3289 | } |
| 3290 | 3290 | echo 'Flights data...'."\n"; |
| 3291 | 3291 | echo '-> countAllDatesLastMonth...'."\n"; |
| 3292 | 3292 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
| 3293 | 3293 | foreach ($alldata as $number) { |
| 3294 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
| 3294 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 3295 | 3295 | } |
| 3296 | 3296 | echo '-> countAllDates...'."\n"; |
| 3297 | - $previousdata = $this->countAllDates('',$filter_name); |
|
| 3298 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
| 3297 | + $previousdata = $this->countAllDates('', $filter_name); |
|
| 3298 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
| 3299 | 3299 | $values = array(); |
| 3300 | 3300 | foreach ($alldata as $cnt) { |
| 3301 | 3301 | $values[] = $cnt['date_count']; |
| 3302 | 3302 | } |
| 3303 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 3304 | - array_splice($alldata,11); |
|
| 3303 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 3304 | + array_splice($alldata, 11); |
|
| 3305 | 3305 | foreach ($alldata as $number) { |
| 3306 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
| 3306 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 3307 | 3307 | } |
| 3308 | 3308 | |
| 3309 | 3309 | echo '-> countAllHours...'."\n"; |
| 3310 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
| 3310 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
| 3311 | 3311 | foreach ($alldata as $number) { |
| 3312 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
| 3312 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
| 3313 | 3313 | } |
| 3314 | 3314 | echo 'Insert last stats update date...'."\n"; |
| 3315 | 3315 | date_default_timezone_set('UTC'); |
| 3316 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
| 3316 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
| 3317 | 3317 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
| 3318 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 3318 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 3319 | 3319 | $this->deleteOldStats($filter_name); |
| 3320 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
| 3320 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
| 3321 | 3321 | } |
| 3322 | 3322 | } |
| 3323 | 3323 | } |
@@ -3330,16 +3330,16 @@ discard block |
||
| 3330 | 3330 | // SUM all previous month to put as year |
| 3331 | 3331 | $previous_year = date('Y'); |
| 3332 | 3332 | $previous_year--; |
| 3333 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3334 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3335 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3336 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 3333 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3334 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3335 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3336 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 3337 | 3337 | $allairlines = $this->getAllAirlineNames(); |
| 3338 | 3338 | foreach ($allairlines as $data) { |
| 3339 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3340 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3341 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3342 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 3339 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3340 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3341 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3342 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -3348,21 +3348,21 @@ discard block |
||
| 3348 | 3348 | try { |
| 3349 | 3349 | $sth = $this->db->prepare($query); |
| 3350 | 3350 | $sth->execute(); |
| 3351 | - } catch(PDOException $e) { |
|
| 3351 | + } catch (PDOException $e) { |
|
| 3352 | 3352 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3353 | 3353 | } |
| 3354 | 3354 | $query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'"; |
| 3355 | 3355 | try { |
| 3356 | 3356 | $sth = $this->db->prepare($query); |
| 3357 | 3357 | $sth->execute(); |
| 3358 | - } catch(PDOException $e) { |
|
| 3358 | + } catch (PDOException $e) { |
|
| 3359 | 3359 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3360 | 3360 | } |
| 3361 | 3361 | $query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'"; |
| 3362 | 3362 | try { |
| 3363 | 3363 | $sth = $this->db->prepare($query); |
| 3364 | 3364 | $sth->execute(); |
| 3365 | - } catch(PDOException $e) { |
|
| 3365 | + } catch (PDOException $e) { |
|
| 3366 | 3366 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3367 | 3367 | } |
| 3368 | 3368 | } |
@@ -3375,7 +3375,7 @@ discard block |
||
| 3375 | 3375 | try { |
| 3376 | 3376 | $sth = $this->db->prepare($query); |
| 3377 | 3377 | $sth->execute(); |
| 3378 | - } catch(PDOException $e) { |
|
| 3378 | + } catch (PDOException $e) { |
|
| 3379 | 3379 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3380 | 3380 | } |
| 3381 | 3381 | if ($globalDBdriver == 'mysql') { |
@@ -3386,7 +3386,7 @@ discard block |
||
| 3386 | 3386 | try { |
| 3387 | 3387 | $sth = $this->db->prepare($query); |
| 3388 | 3388 | $sth->execute(); |
| 3389 | - } catch(PDOException $e) { |
|
| 3389 | + } catch (PDOException $e) { |
|
| 3390 | 3390 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3391 | 3391 | } |
| 3392 | 3392 | if ($globalDBdriver == 'mysql') { |
@@ -3397,15 +3397,15 @@ discard block |
||
| 3397 | 3397 | try { |
| 3398 | 3398 | $sth = $this->db->prepare($query); |
| 3399 | 3399 | $sth->execute(); |
| 3400 | - } catch(PDOException $e) { |
|
| 3400 | + } catch (PDOException $e) { |
|
| 3401 | 3401 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 3402 | 3402 | } |
| 3403 | 3403 | } |
| 3404 | 3404 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
| 3405 | 3405 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 3406 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 3406 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 3407 | 3407 | $this->deleteOldStats(); |
| 3408 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
| 3408 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
| 3409 | 3409 | $lastyearupdate = true; |
| 3410 | 3410 | } |
| 3411 | 3411 | } |
@@ -3427,7 +3427,7 @@ discard block |
||
| 3427 | 3427 | try { |
| 3428 | 3428 | $sth = $this->db->prepare($query); |
| 3429 | 3429 | $sth->execute(); |
| 3430 | - } catch(PDOException $e) { |
|
| 3430 | + } catch (PDOException $e) { |
|
| 3431 | 3431 | return "error : ".$e->getMessage(); |
| 3432 | 3432 | } |
| 3433 | 3433 | echo 'Archive old tracker data...'."\n"; |
@@ -3443,7 +3443,7 @@ discard block |
||
| 3443 | 3443 | try { |
| 3444 | 3444 | $sth = $this->db->prepare($query); |
| 3445 | 3445 | $sth->execute(); |
| 3446 | - } catch(PDOException $e) { |
|
| 3446 | + } catch (PDOException $e) { |
|
| 3447 | 3447 | return "error : ".$e->getMessage(); |
| 3448 | 3448 | } |
| 3449 | 3449 | echo 'Archive old marine data...'."\n"; |
@@ -3459,7 +3459,7 @@ discard block |
||
| 3459 | 3459 | try { |
| 3460 | 3460 | $sth = $this->db->prepare($query); |
| 3461 | 3461 | $sth->execute(); |
| 3462 | - } catch(PDOException $e) { |
|
| 3462 | + } catch (PDOException $e) { |
|
| 3463 | 3463 | return "error : ".$e->getMessage(); |
| 3464 | 3464 | } |
| 3465 | 3465 | } |
@@ -3472,7 +3472,7 @@ discard block |
||
| 3472 | 3472 | try { |
| 3473 | 3473 | $sth = $this->db->prepare($query); |
| 3474 | 3474 | $sth->execute(); |
| 3475 | - } catch(PDOException $e) { |
|
| 3475 | + } catch (PDOException $e) { |
|
| 3476 | 3476 | return "error : ".$e->getMessage(); |
| 3477 | 3477 | } |
| 3478 | 3478 | echo 'Deleting old tracker data...'."\n"; |
@@ -3484,7 +3484,7 @@ discard block |
||
| 3484 | 3484 | try { |
| 3485 | 3485 | $sth = $this->db->prepare($query); |
| 3486 | 3486 | $sth->execute(); |
| 3487 | - } catch(PDOException $e) { |
|
| 3487 | + } catch (PDOException $e) { |
|
| 3488 | 3488 | return "error : ".$e->getMessage(); |
| 3489 | 3489 | } |
| 3490 | 3490 | echo 'Deleting old marine data...'."\n"; |
@@ -3496,14 +3496,14 @@ discard block |
||
| 3496 | 3496 | try { |
| 3497 | 3497 | $sth = $this->db->prepare($query); |
| 3498 | 3498 | $sth->execute(); |
| 3499 | - } catch(PDOException $e) { |
|
| 3499 | + } catch (PDOException $e) { |
|
| 3500 | 3500 | return "error : ".$e->getMessage(); |
| 3501 | 3501 | } |
| 3502 | 3502 | } |
| 3503 | 3503 | if (!isset($lastyearupdate)) { |
| 3504 | 3504 | echo 'Insert last stats update date...'."\n"; |
| 3505 | 3505 | date_default_timezone_set('UTC'); |
| 3506 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
| 3506 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
| 3507 | 3507 | } |
| 3508 | 3508 | if ($globalStatsResetYear) { |
| 3509 | 3509 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -26,33 +26,33 @@ discard block |
||
| 26 | 26 | * @param bool $and |
| 27 | 27 | * @return string the SQL part |
| 28 | 28 | */ |
| 29 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 29 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 30 | 30 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 31 | 31 | $filters = array(); |
| 32 | 32 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 33 | 33 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 34 | 34 | $filters = $globalStatsFilters[$globalFilterName]; |
| 35 | 35 | } else { |
| 36 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 36 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | if (isset($filter[0]['source'])) { |
| 40 | - $filters = array_merge($filters,$filter); |
|
| 40 | + $filters = array_merge($filters, $filter); |
|
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | - foreach($filters as $flt) { |
|
| 45 | + foreach ($filters as $flt) { |
|
| 46 | 46 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 48 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 49 | 49 | } else { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 55 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 55 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 58 | 58 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -84,15 +84,15 @@ discard block |
||
| 84 | 84 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 87 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 90 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 90 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 91 | 91 | } |
| 92 | 92 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 93 | 93 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 94 | 94 | if ($filter_query_where != '') { |
| 95 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 95 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 96 | 96 | } |
| 97 | 97 | $filter_query = $filter_query_join.$filter_query_where; |
| 98 | 98 | return $filter_query; |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | if ($limit != '') |
| 118 | 118 | { |
| 119 | 119 | $limit_array = explode(',', $limit); |
| 120 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 121 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 120 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 121 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 122 | 122 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 123 | 123 | { |
| 124 | 124 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } else { |
| 142 | 142 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
| 143 | 143 | } |
| 144 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 144 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 145 | 145 | |
| 146 | 146 | return $spotter_array; |
| 147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | global $globalDBdriver, $globalLiveInterval; |
| 158 | 158 | date_default_timezone_set('UTC'); |
| 159 | 159 | |
| 160 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 160 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 161 | 161 | |
| 162 | 162 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 163 | 163 | if ($globalDBdriver == 'mysql') { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | try { |
| 176 | 176 | $sth = $this->db->prepare($query); |
| 177 | 177 | $sth->execute(); |
| 178 | - } catch(PDOException $e) { |
|
| 178 | + } catch (PDOException $e) { |
|
| 179 | 179 | echo $e->getMessage(); |
| 180 | 180 | die; |
| 181 | 181 | } |
@@ -192,25 +192,25 @@ discard block |
||
| 192 | 192 | * @param bool $limit |
| 193 | 193 | * @return array the spotter information |
| 194 | 194 | */ |
| 195 | - public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
|
| 195 | + public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false) |
|
| 196 | 196 | { |
| 197 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
| 198 | 198 | date_default_timezone_set('UTC'); |
| 199 | 199 | $usecoord = false; |
| 200 | 200 | if (is_array($coord) && !empty($coord)) { |
| 201 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 202 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 203 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 204 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 201 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 202 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 203 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 204 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 205 | 205 | $usecoord = true; |
| 206 | 206 | } |
| 207 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 207 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 208 | 208 | |
| 209 | 209 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 210 | 210 | if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
| 211 | 211 | if ($globalDBdriver == 'mysql') { |
| 212 | 212 | if (isset($globalArchive) && $globalArchive) { |
| 213 | - $query = "SELECT * FROM ( |
|
| 213 | + $query = "SELECT * FROM ( |
|
| 214 | 214 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 215 | 215 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 216 | 216 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } else { |
| 234 | 234 | if (isset($globalArchive) && $globalArchive) { |
| 235 | - $query = "SELECT * FROM ( |
|
| 235 | + $query = "SELECT * FROM ( |
|
| 236 | 236 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
| 237 | 237 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
| 238 | 238 | if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | try { |
| 257 | 257 | $sth = $this->db->prepare($query); |
| 258 | 258 | $sth->execute(); |
| 259 | - } catch(PDOException $e) { |
|
| 259 | + } catch (PDOException $e) { |
|
| 260 | 260 | echo $e->getMessage(); |
| 261 | 261 | die; |
| 262 | 262 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | public function getLiveTrackerCount($filter = array()) |
| 274 | 274 | { |
| 275 | 275 | global $globalDBdriver, $globalLiveInterval; |
| 276 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 276 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 277 | 277 | |
| 278 | 278 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 279 | 279 | if ($globalDBdriver == 'mysql') { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | try { |
| 285 | 285 | $sth = $this->db->prepare($query); |
| 286 | 286 | $sth->execute(); |
| 287 | - } catch(PDOException $e) { |
|
| 287 | + } catch (PDOException $e) { |
|
| 288 | 288 | echo $e->getMessage(); |
| 289 | 289 | die; |
| 290 | 290 | } |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | $filter_query = $this->getFilter($filter); |
| 309 | 309 | |
| 310 | 310 | if (is_array($coord)) { |
| 311 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 312 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 313 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 314 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 311 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 312 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 313 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 314 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 315 | 315 | } else return array(); |
| 316 | 316 | if ($globalDBdriver == 'mysql') { |
| 317 | 317 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 335 | 335 | $Tracker = new Tracker($this->db); |
| 336 | 336 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 337 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 337 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 338 | 338 | |
| 339 | 339 | if (is_array($coord)) { |
| 340 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 341 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 342 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 343 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 340 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 341 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 342 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 343 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 344 | 344 | } else return array(); |
| 345 | 345 | /* |
| 346 | 346 | if ($globalDBdriver == 'mysql') { |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | if ($globalDBdriver == 'mysql') { |
| 356 | 356 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 357 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 357 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 358 | 358 | FROM tracker_live |
| 359 | 359 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date |
| 360 | 360 | AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 361 | 361 | AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0 ORDER BY date DESC'; |
| 362 | 362 | } else { |
| 363 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 363 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 364 | 364 | FROM tracker_live |
| 365 | 365 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate |
| 366 | 366 | FROM tracker_live l |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | } else { |
| 374 | 374 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 375 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 375 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 376 | 376 | FROM tracker_live |
| 377 | 377 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date |
| 378 | 378 | AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 379 | 379 | AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 380 | 380 | AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ORDER BY date DESC"; |
| 381 | 381 | } else { |
| 382 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 382 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
| 383 | 383 | FROM tracker_live |
| 384 | 384 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate |
| 385 | 385 | FROM tracker_live l |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | if ($interval == '1m') |
| 440 | 440 | { |
| 441 | 441 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 442 | - } else if ($interval == '15m'){ |
|
| 442 | + } else if ($interval == '15m') { |
|
| 443 | 443 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -447,14 +447,14 @@ discard block |
||
| 447 | 447 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 450 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
| 451 | 451 | WHERE tracker_live.latitude <> '' |
| 452 | 452 | AND tracker_live.longitude <> '' |
| 453 | 453 | ".$additional_query." |
| 454 | 454 | HAVING distance < :radius |
| 455 | 455 | ORDER BY distance"; |
| 456 | 456 | |
| 457 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 457 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 458 | 458 | |
| 459 | 459 | return $spotter_array; |
| 460 | 460 | } |
@@ -472,9 +472,9 @@ discard block |
||
| 472 | 472 | date_default_timezone_set('UTC'); |
| 473 | 473 | |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 475 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 476 | 476 | |
| 477 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 477 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 478 | 478 | |
| 479 | 479 | return $spotter_array; |
| 480 | 480 | } |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | * @param $date |
| 487 | 487 | * @return array the spotter information |
| 488 | 488 | */ |
| 489 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
| 489 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
| 490 | 490 | { |
| 491 | 491 | $Tracker = new Tracker($this->db); |
| 492 | 492 | date_default_timezone_set('UTC'); |
| 493 | 493 | |
| 494 | 494 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 495 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 495 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 496 | 496 | |
| 497 | - $date = date('c',$date); |
|
| 498 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 497 | + $date = date('c', $date); |
|
| 498 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 499 | 499 | |
| 500 | 500 | return $spotter_array; |
| 501 | 501 | } |
@@ -512,9 +512,9 @@ discard block |
||
| 512 | 512 | date_default_timezone_set('UTC'); |
| 513 | 513 | |
| 514 | 514 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 515 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 515 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 516 | 516 | |
| 517 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 517 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 518 | 518 | |
| 519 | 519 | return $spotter_array; |
| 520 | 520 | } |
@@ -526,15 +526,15 @@ discard block |
||
| 526 | 526 | * @param $date |
| 527 | 527 | * @return array the spotter information |
| 528 | 528 | */ |
| 529 | - public function getDateLiveTrackerDataById($id,$date) |
|
| 529 | + public function getDateLiveTrackerDataById($id, $date) |
|
| 530 | 530 | { |
| 531 | 531 | $Tracker = new Tracker($this->db); |
| 532 | 532 | date_default_timezone_set('UTC'); |
| 533 | 533 | |
| 534 | 534 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 535 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 536 | - $date = date('c',$date); |
|
| 537 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 535 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
| 536 | + $date = date('c', $date); |
|
| 537 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 538 | 538 | |
| 539 | 539 | return $spotter_array; |
| 540 | 540 | } |
@@ -551,13 +551,13 @@ discard block |
||
| 551 | 551 | date_default_timezone_set('UTC'); |
| 552 | 552 | |
| 553 | 553 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 554 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 554 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
| 555 | 555 | |
| 556 | 556 | try { |
| 557 | 557 | |
| 558 | 558 | $sth = $this->db->prepare($query); |
| 559 | 559 | $sth->execute(array(':ident' => $ident)); |
| 560 | - } catch(PDOException $e) { |
|
| 560 | + } catch (PDOException $e) { |
|
| 561 | 561 | echo $e->getMessage(); |
| 562 | 562 | die; |
| 563 | 563 | } |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @param bool $liveinterval |
| 574 | 574 | * @return array the spotter information |
| 575 | 575 | */ |
| 576 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
| 576 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
| 577 | 577 | { |
| 578 | 578 | global $globalDBdriver, $globalLiveInterval; |
| 579 | 579 | date_default_timezone_set('UTC'); |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | if ($globalDBdriver == 'mysql') { |
| 583 | 583 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 584 | 584 | if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 585 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 585 | + elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'"; |
|
| 586 | 586 | $query .= ' ORDER BY date'; |
| 587 | 587 | } else { |
| 588 | 588 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 589 | 589 | if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
| 590 | - elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'"; |
|
| 590 | + elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'"; |
|
| 591 | 591 | $query .= ' ORDER BY date'; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | try { |
| 595 | 595 | $sth = $this->db->prepare($query); |
| 596 | 596 | $sth->execute(array(':id' => $id)); |
| 597 | - } catch(PDOException $e) { |
|
| 597 | + } catch (PDOException $e) { |
|
| 598 | 598 | echo $e->getMessage(); |
| 599 | 599 | die; |
| 600 | 600 | } |
@@ -612,12 +612,12 @@ discard block |
||
| 612 | 612 | { |
| 613 | 613 | date_default_timezone_set('UTC'); |
| 614 | 614 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 615 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 615 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
| 616 | 616 | try { |
| 617 | 617 | |
| 618 | 618 | $sth = $this->db->prepare($query); |
| 619 | 619 | $sth->execute(array(':ident' => $ident)); |
| 620 | - } catch(PDOException $e) { |
|
| 620 | + } catch (PDOException $e) { |
|
| 621 | 621 | echo $e->getMessage(); |
| 622 | 622 | die; |
| 623 | 623 | } |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $sth = $this->db->prepare($query); |
| 649 | 649 | $sth->execute(); |
| 650 | - } catch(PDOException $e) { |
|
| 650 | + } catch (PDOException $e) { |
|
| 651 | 651 | return "error"; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -670,14 +670,14 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
| 673 | - } catch(PDOException $e) { |
|
| 673 | + } catch (PDOException $e) { |
|
| 674 | 674 | return "error"; |
| 675 | 675 | } |
| 676 | 676 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
| 677 | 677 | $i = 0; |
| 678 | - $j =0; |
|
| 678 | + $j = 0; |
|
| 679 | 679 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 680 | - foreach($all as $row) |
|
| 680 | + foreach ($all as $row) |
|
| 681 | 681 | { |
| 682 | 682 | $i++; |
| 683 | 683 | $j++; |
@@ -685,9 +685,9 @@ discard block |
||
| 685 | 685 | if ($globalDebug) echo "."; |
| 686 | 686 | try { |
| 687 | 687 | |
| 688 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 688 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 689 | 689 | $sth->execute(); |
| 690 | - } catch(PDOException $e) { |
|
| 690 | + } catch (PDOException $e) { |
|
| 691 | 691 | return "error"; |
| 692 | 692 | } |
| 693 | 693 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -698,9 +698,9 @@ discard block |
||
| 698 | 698 | if ($i > 0) { |
| 699 | 699 | try { |
| 700 | 700 | |
| 701 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 701 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 702 | 702 | $sth->execute(); |
| 703 | - } catch(PDOException $e) { |
|
| 703 | + } catch (PDOException $e) { |
|
| 704 | 704 | return "error"; |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | $sth = $this->db->prepare($query); |
| 715 | 715 | $sth->execute(); |
| 716 | - } catch(PDOException $e) { |
|
| 716 | + } catch (PDOException $e) { |
|
| 717 | 717 | return "error"; |
| 718 | 718 | } |
| 719 | 719 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -761,13 +761,13 @@ discard block |
||
| 761 | 761 | public function deleteLiveTrackerDataByIdent($ident) |
| 762 | 762 | { |
| 763 | 763 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 764 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 764 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
| 765 | 765 | |
| 766 | 766 | try { |
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute(array(':ident' => $ident)); |
| 770 | - } catch(PDOException $e) { |
|
| 770 | + } catch (PDOException $e) { |
|
| 771 | 771 | return "error"; |
| 772 | 772 | } |
| 773 | 773 | |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | public function deleteLiveTrackerDataById($id) |
| 784 | 784 | { |
| 785 | 785 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 786 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 786 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
| 787 | 787 | |
| 788 | 788 | try { |
| 789 | 789 | |
| 790 | 790 | $sth = $this->db->prepare($query); |
| 791 | 791 | $sth->execute(array(':id' => $id)); |
| 792 | - } catch(PDOException $e) { |
|
| 792 | + } catch (PDOException $e) { |
|
| 793 | 793 | return "error"; |
| 794 | 794 | } |
| 795 | 795 | |
@@ -807,13 +807,13 @@ discard block |
||
| 807 | 807 | { |
| 808 | 808 | global $globalDBdriver, $globalTimezone; |
| 809 | 809 | if ($globalDBdriver == 'mysql') { |
| 810 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 810 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
| 811 | 811 | WHERE tracker_live.ident = :ident |
| 812 | 812 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 813 | 813 | AND tracker_live.date < UTC_TIMESTAMP()'; |
| 814 | 814 | $query_data = array(':ident' => $ident); |
| 815 | 815 | } else { |
| 816 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 816 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
| 817 | 817 | WHERE tracker_live.ident = :ident |
| 818 | 818 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 819 | 819 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -822,8 +822,8 @@ discard block |
||
| 822 | 822 | |
| 823 | 823 | $sth = $this->db->prepare($query); |
| 824 | 824 | $sth->execute($query_data); |
| 825 | - $ident_result=''; |
|
| 826 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 825 | + $ident_result = ''; |
|
| 826 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 827 | 827 | { |
| 828 | 828 | $ident_result = $row['ident']; |
| 829 | 829 | } |
@@ -840,13 +840,13 @@ discard block |
||
| 840 | 840 | { |
| 841 | 841 | global $globalDBdriver, $globalTimezone; |
| 842 | 842 | if ($globalDBdriver == 'mysql') { |
| 843 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 843 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 844 | 844 | WHERE tracker_live.ident = :ident |
| 845 | 845 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 846 | 846 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 847 | 847 | $query_data = array(':ident' => $ident); |
| 848 | 848 | } else { |
| 849 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 849 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 850 | 850 | WHERE tracker_live.ident = :ident |
| 851 | 851 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 852 | 852 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -855,8 +855,8 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | $sth = $this->db->prepare($query); |
| 857 | 857 | $sth->execute($query_data); |
| 858 | - $ident_result=''; |
|
| 859 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 858 | + $ident_result = ''; |
|
| 859 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 860 | 860 | { |
| 861 | 861 | $ident_result = $row['famtrackid']; |
| 862 | 862 | } |
@@ -873,13 +873,13 @@ discard block |
||
| 873 | 873 | { |
| 874 | 874 | global $globalDBdriver, $globalTimezone; |
| 875 | 875 | if ($globalDBdriver == 'mysql') { |
| 876 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 876 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 877 | 877 | WHERE tracker_live.famtrackid = :id |
| 878 | 878 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 879 | 879 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
| 880 | 880 | $query_data = array(':id' => $id); |
| 881 | 881 | } else { |
| 882 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 882 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
| 883 | 883 | WHERE tracker_live.famtrackid = :id |
| 884 | 884 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 885 | 885 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -888,8 +888,8 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | $sth = $this->db->prepare($query); |
| 890 | 890 | $sth->execute($query_data); |
| 891 | - $ident_result=''; |
|
| 892 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 891 | + $ident_result = ''; |
|
| 892 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 893 | 893 | { |
| 894 | 894 | $ident_result = $row['famtrackid']; |
| 895 | 895 | } |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | * @param string $over_country |
| 917 | 917 | * @return String success or false |
| 918 | 918 | */ |
| 919 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 919 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 920 | 920 | { |
| 921 | 921 | global $globalURL, $globalArchive, $globalDebug; |
| 922 | 922 | $Common = new Common(); |
@@ -975,21 +975,21 @@ discard block |
||
| 975 | 975 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 976 | 976 | |
| 977 | 977 | |
| 978 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 979 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 980 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 981 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 982 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 983 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 985 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 986 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 987 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 988 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 989 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 990 | - |
|
| 991 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 992 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 978 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 979 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 980 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 981 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 982 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 983 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 985 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 986 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 987 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 988 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 989 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 990 | + |
|
| 991 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 992 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 993 | 993 | |
| 994 | 994 | $query = ''; |
| 995 | 995 | if ($globalArchive) { |
@@ -999,12 +999,12 @@ discard block |
||
| 999 | 999 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 1000 | 1000 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 1001 | 1001 | |
| 1002 | - $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); |
|
| 1002 | + $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); |
|
| 1003 | 1003 | try { |
| 1004 | 1004 | $sth = $this->db->prepare($query); |
| 1005 | 1005 | $sth->execute($query_values); |
| 1006 | 1006 | $sth->closeCursor(); |
| 1007 | - } catch(PDOException $e) { |
|
| 1007 | + } catch (PDOException $e) { |
|
| 1008 | 1008 | return "error : ".$e->getMessage(); |
| 1009 | 1009 | } |
| 1010 | 1010 | /* |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1015 | 1015 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
| 1016 | 1016 | $TrackerArchive = new TrackerArchive($this->db); |
| 1017 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
| 1017 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
| 1018 | 1018 | if ($globalDebug) echo $result.')'; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | |
| 1025 | 1025 | public function getOrderBy() |
| 1026 | 1026 | { |
| 1027 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 1027 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
| 1028 | 1028 | return $orderby; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $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"; |
|
| 45 | + $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"; |
|
| 46 | 46 | } else { |
| 47 | - $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"; |
|
| 47 | + $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"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $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"; |
|
| 80 | + $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"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
| 131 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | 135 | |
| 136 | 136 | //$country = $over_country; |
| 137 | 137 | // Route is not added in marine_archive |
| 138 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 138 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 139 | 139 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
| 140 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 140 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
| 144 | 144 | $sth->closeCursor(); |
| 145 | - } catch(PDOException $e) { |
|
| 145 | + } catch (PDOException $e) { |
|
| 146 | 146 | return "error : ".$e->getMessage(); |
| 147 | 147 | } |
| 148 | 148 | return "success"; |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 164 | 164 | //$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"; |
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 167 | 167 | return $spotter_array; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 182 | 182 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 183 | 183 | //$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"; |
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | 187 | /* |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 198 | 198 | return $spotter_array; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | date_default_timezone_set('UTC'); |
| 210 | 210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute(array(':id' => $id)); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | echo $e->getMessage(); |
| 220 | 220 | die; |
| 221 | 221 | } |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | date_default_timezone_set('UTC'); |
| 235 | 235 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | 240 | try { |
| 241 | 241 | $sth = $this->db->prepare($query); |
| 242 | 242 | $sth->execute(array(':id' => $id)); |
| 243 | - } catch(PDOException $e) { |
|
| 243 | + } catch (PDOException $e) { |
|
| 244 | 244 | echo $e->getMessage(); |
| 245 | 245 | die; |
| 246 | 246 | } |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | date_default_timezone_set('UTC'); |
| 263 | 263 | |
| 264 | 264 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 265 | - $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"; |
|
| 265 | + $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"; |
|
| 266 | 266 | |
| 267 | 267 | try { |
| 268 | 268 | $sth = $this->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':ident' => $ident)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | echo $e->getMessage(); |
| 272 | 272 | die; |
| 273 | 273 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | date_default_timezone_set('UTC'); |
| 289 | 289 | |
| 290 | 290 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 291 | - $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"; |
|
| 291 | + $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"; |
|
| 292 | 292 | |
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute(array(':id' => $id)); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | echo $e->getMessage(); |
| 298 | 298 | die; |
| 299 | 299 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | date_default_timezone_set('UTC'); |
| 314 | 314 | |
| 315 | 315 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | 317 | |
| 318 | 318 | try { |
| 319 | 319 | $sth = $this->db->prepare($query); |
| 320 | 320 | $sth->execute(array(':id' => $id)); |
| 321 | - } catch(PDOException $e) { |
|
| 321 | + } catch (PDOException $e) { |
|
| 322 | 322 | echo $e->getMessage(); |
| 323 | 323 | die; |
| 324 | 324 | } |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | |
| 342 | 342 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 343 | - $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"; |
|
| 343 | + $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"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute(array(':ident' => $ident)); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -364,12 +364,12 @@ discard block |
||
| 364 | 364 | * @param $date |
| 365 | 365 | * @return array the spotter information |
| 366 | 366 | */ |
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 367 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 368 | 368 | { |
| 369 | 369 | $Marine = new Marine($this->db); |
| 370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 371 | 371 | $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"; |
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo $e->getMessage(); |
| 393 | 393 | die; |
| 394 | 394 | } |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @param array $filter |
| 403 | 403 | * @return array the spotter information |
| 404 | 404 | */ |
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 405 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 406 | 406 | { |
| 407 | 407 | global $globalDBdriver; |
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $filter_query = ''; |
| 411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 413 | 413 | } |
| 414 | 414 | // Use spotter_output also ? |
| 415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 416 | - $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 "; |
|
| 416 | + $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 "; |
|
| 417 | 417 | } |
| 418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 419 | 419 | $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 "; |
| 420 | 420 | } |
| 421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $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 |
|
| 441 | + $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 |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | 446 | } else { |
| 447 | 447 | //$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'; |
| 448 | - $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 |
|
| 448 | + $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 |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -472,24 +472,24 @@ discard block |
||
| 472 | 472 | * @param array $filter |
| 473 | 473 | * @return array the spotter information |
| 474 | 474 | */ |
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 476 | 476 | { |
| 477 | 477 | global $globalDBdriver; |
| 478 | 478 | date_default_timezone_set('UTC'); |
| 479 | 479 | |
| 480 | 480 | $filter_query = ''; |
| 481 | 481 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 483 | 483 | } |
| 484 | 484 | // Should use spotter_output also ? |
| 485 | 485 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 486 | - $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 "; |
|
| 486 | + $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 "; |
|
| 487 | 487 | } |
| 488 | 488 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 489 | 489 | $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 "; |
| 490 | 490 | } |
| 491 | 491 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | FROM marine_archive |
| 500 | 500 | 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'; |
| 501 | 501 | */ |
| 502 | - $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 |
|
| 502 | + $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 |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$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'; |
| 516 | 516 | */ |
| 517 | - $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 |
|
| 517 | + $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 |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | try { |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
| 529 | - } catch(PDOException $e) { |
|
| 529 | + } catch (PDOException $e) { |
|
| 530 | 530 | echo $e->getMessage(); |
| 531 | 531 | die; |
| 532 | 532 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @param array $filter |
| 544 | 544 | * @return array the spotter information |
| 545 | 545 | */ |
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveMarineCount($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 fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 556 | + $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 "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $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 "; |
| 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 | } |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | * @param array $filters |
| 618 | 618 | * @return array the spotter information |
| 619 | 619 | */ |
| 620 | - 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()) |
|
| 620 | + 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()) |
|
| 621 | 621 | { |
| 622 | 622 | global $globalTimezone, $globalDBdriver; |
| 623 | 623 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | } else { |
| 639 | 639 | $q_array = explode(" ", $q); |
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 641 | + foreach ($q_array as $q_item) { |
|
| 642 | 642 | $additional_query .= " AND ("; |
| 643 | 643 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 644 | 644 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($registration != "") |
| 672 | 672 | { |
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 673 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($registration)) |
| 675 | 675 | { |
| 676 | 676 | return array(); |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | if ($aircraft_icao != "") |
| 683 | 683 | { |
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 685 | 685 | if (!is_string($aircraft_icao)) |
| 686 | 686 | { |
| 687 | 687 | return array(); |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | if ($aircraft_manufacturer != "") |
| 694 | 694 | { |
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 696 | 696 | if (!is_string($aircraft_manufacturer)) |
| 697 | 697 | { |
| 698 | 698 | return array(); |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_icao != "") |
| 715 | 715 | { |
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_icao)) |
| 718 | 718 | { |
| 719 | 719 | return array(); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($airline_country != "") |
| 726 | 726 | { |
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 727 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($airline_country)) |
| 729 | 729 | { |
| 730 | 730 | return array(); |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airline_type != "") |
| 737 | 737 | { |
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 738 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airline_type)) |
| 740 | 740 | { |
| 741 | 741 | return array(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($airport != "") |
| 759 | 759 | { |
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 760 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($airport)) |
| 762 | 762 | { |
| 763 | 763 | return array(); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($airport_country != "") |
| 770 | 770 | { |
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 771 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($airport_country)) |
| 773 | 773 | { |
| 774 | 774 | return array(); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($callsign != "") |
| 781 | 781 | { |
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 782 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 783 | 783 | if (!is_string($callsign)) |
| 784 | 784 | { |
| 785 | 785 | return array(); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $translate = $Translation->ident2icao($callsign); |
| 788 | 788 | if ($translate != $callsign) { |
| 789 | 789 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 790 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 791 | 791 | } else { |
| 792 | 792 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 793 | 793 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($owner != "") |
| 798 | 798 | { |
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 799 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 800 | 800 | if (!is_string($owner)) |
| 801 | 801 | { |
| 802 | 802 | return array(); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($pilot_name != "") |
| 809 | 809 | { |
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 810 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($pilot_name)) |
| 812 | 812 | { |
| 813 | 813 | return array(); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($pilot_id != "") |
| 820 | 820 | { |
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 821 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | 822 | if (!is_string($pilot_id)) |
| 823 | 823 | { |
| 824 | 824 | return array(); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | if ($departure_airport_route != "") |
| 831 | 831 | { |
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 833 | 833 | if (!is_string($departure_airport_route)) |
| 834 | 834 | { |
| 835 | 835 | return array(); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ($arrival_airport_route != "") |
| 842 | 842 | { |
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 844 | 844 | if (!is_string($arrival_airport_route)) |
| 845 | 845 | { |
| 846 | 846 | return array(); |
@@ -853,8 +853,8 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $altitude_array = explode(",", $altitude); |
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | 860 | if ($altitude_array[1] != "") |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | { |
| 873 | 873 | $date_array = explode(",", $date_posted); |
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | 878 | if ($globalTimezone != '') { |
| 879 | 879 | date_default_timezone_set($globalTimezone); |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | { |
| 906 | 906 | $limit_array = explode(",", $limit); |
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | 911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 912 | 912 | { |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $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 |
|
| 920 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 921 | + $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 |
|
| 922 | 922 | 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)) |
| 923 | 923 | 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"; |
| 924 | 924 | } else { |
@@ -935,12 +935,12 @@ discard block |
||
| 935 | 935 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | 942 | } |
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 944 | 944 | |
| 945 | 945 | return $spotter_array; |
| 946 | 946 | } |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | try { |
| 958 | 958 | $sth = $this->db->prepare($query); |
| 959 | 959 | $sth->execute(); |
| 960 | - } catch(PDOException $e) { |
|
| 960 | + } catch (PDOException $e) { |
|
| 961 | 961 | return "error"; |
| 962 | 962 | } |
| 963 | 963 | return ''; |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | { |
| 998 | 998 | $limit_array = explode(",", $limit); |
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1002 | 1002 | |
| 1003 | 1003 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1004 | 1004 | { |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | $query_values = array(); |
| 1043 | 1043 | $limit_query = ''; |
| 1044 | 1044 | $additional_query = ''; |
| 1045 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1045 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1046 | 1046 | |
| 1047 | 1047 | if ($owner != "") |
| 1048 | 1048 | { |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | { |
| 1060 | 1060 | $limit_array = explode(",", $limit); |
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1066 | 1066 | { |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $query_values = array(); |
| 1104 | 1104 | $limit_query = ''; |
| 1105 | 1105 | $additional_query = ''; |
| 1106 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1106 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1107 | 1107 | |
| 1108 | 1108 | if ($pilot != "") |
| 1109 | 1109 | { |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | { |
| 1116 | 1116 | $limit_array = explode(",", $limit); |
| 1117 | 1117 | |
| 1118 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | 1120 | |
| 1121 | 1121 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1122 | 1122 | { |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @param string $sincedate |
| 1149 | 1149 | * @return array the airline country list |
| 1150 | 1150 | */ |
| 1151 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1151 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1152 | 1152 | { |
| 1153 | 1153 | global $globalDBdriver; |
| 1154 | 1154 | /* |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | $flight_array = array(); |
| 1178 | 1178 | $temp_array = array(); |
| 1179 | 1179 | |
| 1180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | 1181 | { |
| 1182 | 1182 | $temp_array['flight_count'] = $row['nb']; |
| 1183 | 1183 | $temp_array['flight_country'] = $row['name']; |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @param string $sincedate |
| 1197 | 1197 | * @return array the airline country list |
| 1198 | 1198 | */ |
| 1199 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1199 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | /* |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $flight_array = array(); |
| 1226 | 1226 | $temp_array = array(); |
| 1227 | 1227 | |
| 1228 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1228 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1231 | 1231 | $temp_array['flight_count'] = $row['nb']; |
@@ -1244,14 +1244,14 @@ discard block |
||
| 1244 | 1244 | * @param $date |
| 1245 | 1245 | * @return array the spotter information |
| 1246 | 1246 | */ |
| 1247 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1247 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1248 | 1248 | { |
| 1249 | 1249 | $Marine = new Marine($this->db); |
| 1250 | 1250 | date_default_timezone_set('UTC'); |
| 1251 | 1251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1252 | 1252 | $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'; |
| 1253 | - $date = date('c',$date); |
|
| 1254 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1253 | + $date = date('c', $date); |
|
| 1254 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1255 | 1255 | return $spotter_array; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1262,14 +1262,14 @@ discard block |
||
| 1262 | 1262 | * @param $date |
| 1263 | 1263 | * @return array the spotter information |
| 1264 | 1264 | */ |
| 1265 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1265 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | $Marine = new Marine($this->db); |
| 1268 | 1268 | date_default_timezone_set('UTC'); |
| 1269 | 1269 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1270 | 1270 | $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'; |
| 1271 | - $date = date('c',$date); |
|
| 1272 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1271 | + $date = date('c', $date); |
|
| 1272 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1273 | 1273 | return $spotter_array; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | * @param array $filters |
| 1283 | 1283 | * @return array the spotter information |
| 1284 | 1284 | */ |
| 1285 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1285 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1286 | 1286 | { |
| 1287 | 1287 | global $global_query; |
| 1288 | 1288 | $Marine = new Marine($this->db); |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | $query_values = array(); |
| 1291 | 1291 | $limit_query = ''; |
| 1292 | 1292 | $additional_query = ''; |
| 1293 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1293 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1294 | 1294 | |
| 1295 | 1295 | if ($airport != "") |
| 1296 | 1296 | { |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | { |
| 1308 | 1308 | $limit_array = explode(",", $limit); |
| 1309 | 1309 | |
| 1310 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1312 | 1312 | |
| 1313 | 1313 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1314 | 1314 | { |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | * @param bool $and |
| 29 | 29 | * @return String the SQL part |
| 30 | 30 | */ |
| 31 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 31 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 34 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 35 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 36 | 36 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | 39 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 49 | 49 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * @return Array Return ATC |
| 76 | 76 | */ |
| 77 | 77 | public function getById($id) { |
| 78 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 78 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 79 | 79 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
| 80 | 80 | $query_values = array(':id' => $id); |
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute($query_values); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -94,19 +94,19 @@ discard block |
||
| 94 | 94 | * @param String $format_source Format source |
| 95 | 95 | * @return Array Return ATC |
| 96 | 96 | */ |
| 97 | - public function getByIdent($ident,$format_source = '') { |
|
| 98 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 97 | + public function getByIdent($ident, $format_source = '') { |
|
| 98 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 99 | 99 | if ($format_source == '') { |
| 100 | 100 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
| 101 | 101 | $query_values = array(':ident' => $ident); |
| 102 | 102 | } else { |
| 103 | 103 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
| 104 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 104 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 105 | 105 | } |
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | * @param String $format_source Format source |
| 129 | 129 | * @param String $source_name Source name |
| 130 | 130 | */ |
| 131 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 132 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 133 | - $info = str_replace('^','<br />',$info); |
|
| 134 | - $info = str_replace('&sect;','',$info); |
|
| 135 | - $info = str_replace('"','',$info); |
|
| 131 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 132 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 133 | + $info = str_replace('^', '<br />', $info); |
|
| 134 | + $info = str_replace('&sect;', '', $info); |
|
| 135 | + $info = str_replace('"', '', $info); |
|
| 136 | 136 | if ($type == '') $type = NULL; |
| 137 | 137 | $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)"; |
| 138 | - $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); |
|
| 138 | + $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); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
| 142 | - } catch(PDOException $e) { |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
| 145 | 145 | return ''; |
@@ -160,18 +160,18 @@ discard block |
||
| 160 | 160 | * @param String $format_source Format source |
| 161 | 161 | * @param String $source_name Source name |
| 162 | 162 | */ |
| 163 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 164 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 165 | - $info = str_replace('^','<br />',$info); |
|
| 166 | - $info = str_replace('&sect;','',$info); |
|
| 167 | - $info = str_replace('"','',$info); |
|
| 163 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 164 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 165 | + $info = str_replace('^', '<br />', $info); |
|
| 166 | + $info = str_replace('&sect;', '', $info); |
|
| 167 | + $info = str_replace('"', '', $info); |
|
| 168 | 168 | if ($type == '') $type = NULL; |
| 169 | 169 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 170 | - $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); |
|
| 170 | + $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); |
|
| 171 | 171 | try { |
| 172 | 172 | $sth = $this->db->prepare($query); |
| 173 | 173 | $sth->execute($query_values); |
| 174 | - } catch(PDOException $e) { |
|
| 174 | + } catch (PDOException $e) { |
|
| 175 | 175 | return "error : ".$e->getMessage(); |
| 176 | 176 | } |
| 177 | 177 | return ''; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | try { |
| 188 | 188 | $sth = $this->db->prepare($query); |
| 189 | 189 | $sth->execute($query_values); |
| 190 | - } catch(PDOException $e) { |
|
| 190 | + } catch (PDOException $e) { |
|
| 191 | 191 | return "error : ".$e->getMessage(); |
| 192 | 192 | } |
| 193 | 193 | return ''; |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | * @param String $ident Flight ident |
| 199 | 199 | * @param String $format_source Format source |
| 200 | 200 | */ |
| 201 | - public function deleteByIdent($ident,$format_source) { |
|
| 201 | + public function deleteByIdent($ident, $format_source) { |
|
| 202 | 202 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
| 203 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 203 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 204 | 204 | try { |
| 205 | 205 | $sth = $this->db->prepare($query); |
| 206 | 206 | $sth->execute($query_values); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | return "error : ".$e->getMessage(); |
| 209 | 209 | } |
| 210 | 210 | return ''; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | try { |
| 220 | 220 | $sth = $this->db->prepare($query); |
| 221 | 221 | $sth->execute($query_values); |
| 222 | - } catch(PDOException $e) { |
|
| 222 | + } catch (PDOException $e) { |
|
| 223 | 223 | return "error : ".$e->getMessage(); |
| 224 | 224 | } |
| 225 | 225 | return ''; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | try { |
| 239 | 239 | $sth = $this->db->prepare($query); |
| 240 | 240 | $sth->execute(); |
| 241 | - } catch(PDOException $e) { |
|
| 241 | + } catch (PDOException $e) { |
|
| 242 | 242 | return "error"; |
| 243 | 243 | } |
| 244 | 244 | return "success"; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /* |
| 22 | 22 | * Initialize DB connection |
| 23 | 23 | */ |
| 24 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
| 24 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | 27 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | * @return String the icao |
| 39 | 39 | */ |
| 40 | 40 | public function ident2icao($ident) { |
| 41 | - if (substr($ident,0,2) == 'AF') { |
|
| 42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 41 | + if (substr($ident, 0, 2) == 'AF') { |
|
| 42 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 43 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 44 | 44 | } else { |
| 45 | 45 | $Spotter = new Spotter($this->db); |
| 46 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
| 46 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
| 47 | 47 | if (isset($identicao[0])) { |
| 48 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 48 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 49 | 49 | } else $icao = $ident; |
| 50 | 50 | } |
| 51 | 51 | return $icao; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $sth = $this->db->prepare($query); |
| 71 | 71 | $sth->execute(); |
| 72 | - } catch(PDOException $e) { |
|
| 72 | + } catch (PDOException $e) { |
|
| 73 | 73 | return "error"; |
| 74 | 74 | } |
| 75 | 75 | return "success"; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $sth = $this->db->prepare($query); |
| 95 | 95 | $sth->execute(); |
| 96 | - } catch(PDOException $e) { |
|
| 96 | + } catch (PDOException $e) { |
|
| 97 | 97 | return "error"; |
| 98 | 98 | } |
| 99 | 99 | return "success"; |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | $ident = ''; |
| 120 | 120 | $message = ''; |
| 121 | 121 | $result = array(); |
| 122 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 123 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 125 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 122 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 123 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 124 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 125 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
| 126 | 126 | if ($n != 0) { |
| 127 | - $registration = str_replace('.','',$registration); |
|
| 128 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
| 127 | + $registration = str_replace('.', '', $registration); |
|
| 128 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
| 129 | 129 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
| 130 | 130 | } else $message = $data; |
| 131 | 131 | $decode = array(); |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | $temp = ''; |
| 146 | 146 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
| 147 | 147 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 148 | - $latitude = $la / 10000.0; |
|
| 149 | - $longitude = $ln / 10000.0; |
|
| 148 | + $latitude = $la/10000.0; |
|
| 149 | + $longitude = $ln/10000.0; |
|
| 150 | 150 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 151 | 151 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 152 | 152 | // Temp not always available |
| 153 | 153 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
| 154 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 155 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 154 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
| 155 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
| 156 | 156 | |
| 157 | 157 | //$icao = $Translation->checkTranslation($ident); |
| 158 | 158 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | $dhour = ''; |
| 165 | 165 | $darr = ''; |
| 166 | 166 | $ahour = ''; |
| 167 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
| 167 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
| 168 | 168 | if ($n == 4 && strlen($darr) == 4) { |
| 169 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 170 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 171 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 169 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 170 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 171 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
| 172 | 172 | //$icao = ACARS->ident2icao($ident); |
| 173 | 173 | //$icao = $Translation->checkTranslation($ident); |
| 174 | 174 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 175 | 175 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 176 | 176 | $found = true; |
| 177 | 177 | } |
| 178 | - elseif ($n == 2 || $n == 4) { |
|
| 179 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 178 | + elseif ($n == 2 || $n == 4) { |
|
| 179 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 180 | 180 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
| 181 | 181 | //$icao = ACARS->ident2icao($ident); |
| 182 | 182 | //$icao = $Translation->checkTranslation($ident); |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | $ahour = ''; |
| 235 | 235 | $aair = ''; |
| 236 | 236 | $apiste = ''; |
| 237 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
| 237 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
| 238 | 238 | if ($n > 8) { |
| 239 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 240 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 241 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 239 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
| 240 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
| 241 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
| 242 | 242 | $icao = trim($aident); |
| 243 | 243 | |
| 244 | 244 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 264 | 264 | $las = $las.'.'.$lass; |
| 265 | 265 | $lns = $lns.'.'.$lns; |
| 266 | - $latitude = $las / 1000.0; |
|
| 267 | - $longitude = $lns / 1000.0; |
|
| 266 | + $latitude = $las/1000.0; |
|
| 267 | + $longitude = $lns/1000.0; |
|
| 268 | 268 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 269 | 269 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 270 | 270 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | $alt = ''; |
| 360 | 360 | $fuel = ''; |
| 361 | 361 | $speed = ''; |
| 362 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 362 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
| 363 | 363 | if ($n == 9) { |
| 364 | 364 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 365 | 365 | $icao = trim($aident); |
| 366 | 366 | $decode['icao'] = $icao; |
| 367 | - $latitude = $las / 100.0; |
|
| 368 | - $longitude = $lns / 100.0; |
|
| 367 | + $latitude = $las/100.0; |
|
| 368 | + $longitude = $lns/100.0; |
|
| 369 | 369 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 370 | 370 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 371 | 371 | |
| 372 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
| 372 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
| 373 | 373 | $found = true; |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 389 | 389 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 390 | 390 | |
| 391 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
| 391 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
| 392 | 392 | $found = true; |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | $dair = ''; |
| 422 | 422 | $darr = ''; |
| 423 | 423 | $aident = ''; |
| 424 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 424 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
| 425 | 425 | if ($n == 8) { |
| 426 | 426 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 427 | 427 | $icao = trim($aident); |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | $dair = ''; |
| 455 | 455 | $darr = ''; |
| 456 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
| 456 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
| 457 | 457 | if ($n == 3) { |
| 458 | 458 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 459 | 459 | //$icao = $Translation->checkTranslation($ident); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | $dair = ''; |
| 470 | 470 | $darr = ''; |
| 471 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
| 471 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
| 472 | 472 | if ($n == 3) { |
| 473 | 473 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
| 474 | 474 | //$icao = $Translation->checkTranslation($ident); |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | if (!$found) { |
| 481 | - $n = sscanf($message,'MET01%4c',$airport); |
|
| 481 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
| 482 | 482 | if ($n == 1) { |
| 483 | 483 | if ($globalDebug) echo 'airport name : '.$airport; |
| 484 | 484 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -486,241 +486,241 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | if ($label == 'H1') { |
| 489 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
| 490 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
| 489 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
| 490 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
| 491 | 491 | } |
| 492 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 493 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
| 492 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
| 493 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
| 494 | 494 | } |
| 495 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 496 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
| 495 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
| 496 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
| 497 | 497 | } |
| 498 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
| 498 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
| 499 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
| 500 | 500 | } |
| 501 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 502 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
| 501 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
| 502 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
| 503 | 503 | } |
| 504 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 505 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
| 504 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
| 505 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
| 506 | 506 | } |
| 507 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 508 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
| 507 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
| 508 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
| 509 | 509 | } |
| 510 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 511 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
| 510 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
| 511 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
| 512 | 512 | } |
| 513 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 514 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
| 513 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
| 514 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
| 515 | 515 | } |
| 516 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 517 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
| 516 | + elseif (preg_match(':^#CF:', $message)) { |
|
| 517 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
| 518 | 518 | } |
| 519 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 520 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
| 519 | + elseif (preg_match(':^#DF:', $message)) { |
|
| 520 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
| 521 | 521 | } |
| 522 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 523 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
| 522 | + elseif (preg_match(':^#EC:', $message)) { |
|
| 523 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
| 524 | 524 | } |
| 525 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 526 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
| 525 | + elseif (preg_match(':^#EI:', $message)) { |
|
| 526 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
| 527 | 527 | } |
| 528 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 529 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
| 528 | + elseif (preg_match(':^#H1:', $message)) { |
|
| 529 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
| 530 | 530 | } |
| 531 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 532 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
| 531 | + elseif (preg_match(':^#H2:', $message)) { |
|
| 532 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
| 533 | 533 | } |
| 534 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 535 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
| 534 | + elseif (preg_match(':^#HD:', $message)) { |
|
| 535 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
| 536 | 536 | } |
| 537 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 538 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
| 537 | + elseif (preg_match(':^#M1:', $message)) { |
|
| 538 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
| 539 | 539 | } |
| 540 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 541 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
| 540 | + elseif (preg_match(':^#M2:', $message)) { |
|
| 541 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
| 542 | 542 | } |
| 543 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 544 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
| 543 | + elseif (preg_match(':^#M3:', $message)) { |
|
| 544 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
| 545 | 545 | } |
| 546 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 547 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
| 546 | + elseif (preg_match(':^#MD:', $message)) { |
|
| 547 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
| 548 | 548 | } |
| 549 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 550 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
| 549 | + elseif (preg_match(':^#PS:', $message)) { |
|
| 550 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
| 551 | 551 | } |
| 552 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 553 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
| 552 | + elseif (preg_match(':^#S1:', $message)) { |
|
| 553 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
| 554 | 554 | } |
| 555 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 556 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
| 555 | + elseif (preg_match(':^#S2:', $message)) { |
|
| 556 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
| 557 | 557 | } |
| 558 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 559 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
| 558 | + elseif (preg_match(':^#SD:', $message)) { |
|
| 559 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
| 560 | 560 | } |
| 561 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 562 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
| 561 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
| 562 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
| 563 | 563 | } |
| 564 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 565 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
| 564 | + elseif (preg_match(':^#WO:', $message)) { |
|
| 565 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
| 566 | 566 | } |
| 567 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 568 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
| 567 | + elseif (preg_match(':^#A1:', $message)) { |
|
| 568 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
| 569 | 569 | } |
| 570 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 571 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
| 570 | + elseif (preg_match(':^#A3:', $message)) { |
|
| 571 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
| 572 | 572 | } |
| 573 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 574 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
| 573 | + elseif (preg_match(':^#A4:', $message)) { |
|
| 574 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
| 575 | 575 | } |
| 576 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 577 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
| 576 | + elseif (preg_match(':^#A6:', $message)) { |
|
| 577 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
| 578 | 578 | } |
| 579 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 580 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
| 579 | + elseif (preg_match(':^#A8:', $message)) { |
|
| 580 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
| 581 | 581 | } |
| 582 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 583 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
| 582 | + elseif (preg_match(':^#A9:', $message)) { |
|
| 583 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
| 584 | 584 | } |
| 585 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 586 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
| 585 | + elseif (preg_match(':^#A0:', $message)) { |
|
| 586 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
| 587 | 587 | } |
| 588 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 589 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 588 | + elseif (preg_match(':^#AA:', $message)) { |
|
| 589 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 590 | 590 | } |
| 591 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 592 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
| 591 | + elseif (preg_match(':^#AB:', $message)) { |
|
| 592 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
| 593 | 593 | } |
| 594 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 595 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
| 594 | + elseif (preg_match(':^#AC:', $message)) { |
|
| 595 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
| 596 | 596 | } |
| 597 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 598 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
| 597 | + elseif (preg_match(':^#AD:', $message)) { |
|
| 598 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
| 599 | 599 | } |
| 600 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 601 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
| 600 | + elseif (preg_match(':^#AF:', $message)) { |
|
| 601 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
| 602 | 602 | } |
| 603 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 604 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
| 603 | + elseif (preg_match(':^#B1:', $message)) { |
|
| 604 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
| 605 | 605 | } |
| 606 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 607 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
| 606 | + elseif (preg_match(':^#B2:', $message)) { |
|
| 607 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
| 608 | 608 | } |
| 609 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 610 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
| 609 | + elseif (preg_match(':^#B3:', $message)) { |
|
| 610 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
| 611 | 611 | } |
| 612 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 613 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
| 612 | + elseif (preg_match(':^#B4:', $message)) { |
|
| 613 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
| 614 | 614 | } |
| 615 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 616 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
| 615 | + elseif (preg_match(':^#B6:', $message)) { |
|
| 616 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
| 617 | 617 | } |
| 618 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 619 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
| 618 | + elseif (preg_match(':^#B8:', $message)) { |
|
| 619 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
| 620 | 620 | } |
| 621 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 622 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
| 621 | + elseif (preg_match(':^#B9:', $message)) { |
|
| 622 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
| 623 | 623 | } |
| 624 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 625 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
| 624 | + elseif (preg_match(':^#B0:', $message)) { |
|
| 625 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
| 626 | 626 | } |
| 627 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 628 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
| 627 | + elseif (preg_match(':^#BA:', $message)) { |
|
| 628 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
| 629 | 629 | } |
| 630 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 631 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
| 630 | + elseif (preg_match(':^#BB:', $message)) { |
|
| 631 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
| 632 | 632 | } |
| 633 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 634 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
| 633 | + elseif (preg_match(':^#BC:', $message)) { |
|
| 634 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
| 635 | 635 | } |
| 636 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 637 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
| 636 | + elseif (preg_match(':^#BD:', $message)) { |
|
| 637 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
| 638 | 638 | } |
| 639 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 640 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
| 639 | + elseif (preg_match(':^#BE:', $message)) { |
|
| 640 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
| 641 | 641 | } |
| 642 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 643 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
| 642 | + elseif (preg_match(':^#BF:', $message)) { |
|
| 643 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
| 644 | 644 | } |
| 645 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 646 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
| 645 | + elseif (preg_match(':^#H3:', $message)) { |
|
| 646 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | if ($label == '10') { |
| 650 | - if (preg_match(':^DTO01:',$message)) { |
|
| 651 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
| 650 | + if (preg_match(':^DTO01:', $message)) { |
|
| 651 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
| 652 | 652 | } |
| 653 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 654 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
| 653 | + elseif (preg_match(':^AIS01:', $message)) { |
|
| 654 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
| 655 | 655 | } |
| 656 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 657 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
| 656 | + elseif (preg_match(':^FTX01:', $message)) { |
|
| 657 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
| 658 | 658 | } |
| 659 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 660 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
| 659 | + elseif (preg_match(':^FPL01:', $message)) { |
|
| 660 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
| 661 | 661 | } |
| 662 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 663 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
| 662 | + elseif (preg_match(':^WAB01:', $message)) { |
|
| 663 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
| 664 | 664 | } |
| 665 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 666 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
| 665 | + elseif (preg_match(':^MET01:', $message)) { |
|
| 666 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
| 667 | 667 | } |
| 668 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 669 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
| 668 | + elseif (preg_match(':^WAB02:', $message)) { |
|
| 669 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | if ($label == '15') { |
| 673 | - if (preg_match(':^FST01:',$message)) { |
|
| 674 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
| 673 | + if (preg_match(':^FST01:', $message)) { |
|
| 674 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | if (!$found && $label == 'SA') { |
| 678 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
| 678 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
| 679 | 679 | if ($n == 4) { |
| 680 | 680 | $vsta = array('Version' => $version); |
| 681 | 681 | if ($state == 'E') { |
| 682 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
| 682 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
| 683 | 683 | } |
| 684 | 684 | elseif ($state == 'L') { |
| 685 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
| 685 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
| 686 | 686 | } |
| 687 | 687 | else { |
| 688 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
| 688 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
| 689 | 689 | } |
| 690 | 690 | if ($type == 'V') { |
| 691 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
| 691 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
| 692 | 692 | } |
| 693 | 693 | elseif ($type == 'S') { |
| 694 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
| 694 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
| 695 | 695 | } |
| 696 | 696 | elseif ($type == 'H') { |
| 697 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
| 697 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
| 698 | 698 | } |
| 699 | 699 | elseif ($type == 'G') { |
| 700 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
| 700 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
| 701 | 701 | } |
| 702 | 702 | elseif ($type == 'C') { |
| 703 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
| 703 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
| 704 | 704 | } |
| 705 | 705 | elseif ($type == '2') { |
| 706 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
| 706 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
| 707 | 707 | } |
| 708 | 708 | elseif ($type == 'X') { |
| 709 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
| 709 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
| 710 | 710 | } |
| 711 | 711 | elseif ($type == 'I') { |
| 712 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
| 712 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
| 713 | 713 | } |
| 714 | 714 | else { |
| 715 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
| 715 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
| 716 | 716 | } |
| 717 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
| 718 | - $decode = array_merge($vsta,$decode); |
|
| 717 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
| 718 | + $decode = array_merge($vsta, $decode); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | $title = $this->getTitlefromLabel($label); |
| 723 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 723 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
| 724 | 724 | /* |
| 725 | 725 | // Business jets always use GS0001 |
| 726 | 726 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -748,13 +748,13 @@ discard block |
||
| 748 | 748 | $Translation = new Translation($this->db); |
| 749 | 749 | $message = $this->parse($data); |
| 750 | 750 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
| 751 | - $ident = (string)$message['ident']; |
|
| 751 | + $ident = (string) $message['ident']; |
|
| 752 | 752 | $label = $message['label']; |
| 753 | 753 | $block_id = $message['block_id']; |
| 754 | 754 | $msg_no = $message['msg_no']; |
| 755 | 755 | $msg = $message['message']; |
| 756 | 756 | $decode = $message['decode']; |
| 757 | - $registration = (string)$message['registration']; |
|
| 757 | + $registration = (string) $message['registration']; |
|
| 758 | 758 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
| 759 | 759 | else $latitude = ''; |
| 760 | 760 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -768,20 +768,20 @@ discard block |
||
| 768 | 768 | $Image->addSpotterImage($registration); |
| 769 | 769 | } |
| 770 | 770 | // Business jets always use GS0001 |
| 771 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 771 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
| 772 | 772 | if ($globalDebug && isset($info) && $info != '') echo $info; |
| 773 | 773 | if (count($decode) > 0) $decode_json = json_encode($decode); |
| 774 | 774 | else $decode_json = ''; |
| 775 | 775 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 776 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
| 776 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
| 777 | 777 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 778 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
| 778 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
| 779 | 779 | } |
| 780 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 781 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 782 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 780 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 781 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
| 782 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
| 783 | 783 | if ($globalDebug && count($decode) > 0) { |
| 784 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
| 784 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | * @param string $decode |
| 799 | 799 | * @return bool |
| 800 | 800 | */ |
| 801 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 801 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 802 | 802 | global $globalDebug; |
| 803 | 803 | date_default_timezone_set('UTC'); |
| 804 | 804 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -806,22 +806,22 @@ discard block |
||
| 806 | 806 | $this->db = $Connection->db; |
| 807 | 807 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
| 808 | 808 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 809 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
| 809 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
| 810 | 810 | try { |
| 811 | 811 | $stht = $this->db->prepare($query_test); |
| 812 | 812 | $stht->execute($query_test_values); |
| 813 | - } catch(PDOException $e) { |
|
| 813 | + } catch (PDOException $e) { |
|
| 814 | 814 | echo "error : ".$e->getMessage(); |
| 815 | 815 | return false; |
| 816 | 816 | } |
| 817 | 817 | if ($stht->fetchColumn() == 0) { |
| 818 | 818 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 819 | 819 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
| 820 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
| 820 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
| 821 | 821 | try { |
| 822 | 822 | $sth = $this->db->prepare($query); |
| 823 | 823 | $sth->execute($query_values); |
| 824 | - } catch(PDOException $e) { |
|
| 824 | + } catch (PDOException $e) { |
|
| 825 | 825 | echo "error : ".$e->getMessage(); |
| 826 | 826 | return false; |
| 827 | 827 | } |
@@ -847,10 +847,10 @@ discard block |
||
| 847 | 847 | * @param string $decode |
| 848 | 848 | * @return string |
| 849 | 849 | */ |
| 850 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
| 850 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
| 851 | 851 | global $globalDebug; |
| 852 | 852 | date_default_timezone_set('UTC'); |
| 853 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
| 853 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
| 854 | 854 | /* |
| 855 | 855 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
| 856 | 856 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -865,11 +865,11 @@ discard block |
||
| 865 | 865 | */ |
| 866 | 866 | if ($globalDebug) echo "Add Live ACARS data..."; |
| 867 | 867 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 868 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 868 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
| 869 | 869 | try { |
| 870 | 870 | $sth = $this->db->prepare($query); |
| 871 | 871 | $sth->execute($query_values); |
| 872 | - } catch(PDOException $e) { |
|
| 872 | + } catch (PDOException $e) { |
|
| 873 | 873 | return "error : ".$e->getMessage(); |
| 874 | 874 | } |
| 875 | 875 | if ($globalDebug) echo "Done\n"; |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | try { |
| 892 | 892 | $sth = $this->db->prepare($query); |
| 893 | 893 | $sth->execute($query_values); |
| 894 | - } catch(PDOException $e) { |
|
| 894 | + } catch (PDOException $e) { |
|
| 895 | 895 | echo "error : ".$e->getMessage(); |
| 896 | 896 | return ''; |
| 897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | try { |
| 912 | 912 | $sth = $this->db->prepare($query); |
| 913 | 913 | $sth->execute($query_values); |
| 914 | - } catch(PDOException $e) { |
|
| 914 | + } catch (PDOException $e) { |
|
| 915 | 915 | echo "error : ".$e->getMessage(); |
| 916 | 916 | return array(); |
| 917 | 917 | } |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | try { |
| 933 | 933 | $sth = $this->db->prepare($query); |
| 934 | 934 | $sth->execute($query_values); |
| 935 | - } catch(PDOException $e) { |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | echo "error : ".$e->getMessage(); |
| 937 | 937 | return array(); |
| 938 | 938 | } |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @param string $label |
| 949 | 949 | * @return array Return ACARS data in array |
| 950 | 950 | */ |
| 951 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
| 951 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
| 952 | 952 | global $globalURL; |
| 953 | 953 | $Image = new Image($this->db); |
| 954 | 954 | $Spotter = new Spotter($this->db); |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | if ($limit != "") |
| 960 | 960 | { |
| 961 | 961 | $limit_array = explode(",", $limit); |
| 962 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 963 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 962 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 963 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 964 | 964 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 965 | 965 | { |
| 966 | 966 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | try { |
| 977 | 977 | $sth = $this->db->prepare($query); |
| 978 | 978 | $sth->execute($query_values); |
| 979 | - } catch(PDOException $e) { |
|
| 979 | + } catch (PDOException $e) { |
|
| 980 | 980 | echo "error : ".$e->getMessage(); |
| 981 | 981 | return array(); |
| 982 | 982 | } |
@@ -984,39 +984,39 @@ discard block |
||
| 984 | 984 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 985 | 985 | $data = array(); |
| 986 | 986 | if ($row['registration'] != '') { |
| 987 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 987 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 988 | 988 | $image_array = $Image->getSpotterImage($row['registration']); |
| 989 | - 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'])); |
|
| 990 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 991 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 989 | + 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'])); |
|
| 990 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 991 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 992 | 992 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 993 | 993 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 994 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 994 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 995 | 995 | if (isset($identicao[0])) { |
| 996 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 997 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 998 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 999 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1000 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 996 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 997 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 998 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 999 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1000 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1001 | 1001 | } else $icao = $row['ident']; |
| 1002 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 1003 | - $decode = json_decode($row['decode'],true); |
|
| 1002 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 1003 | + $decode = json_decode($row['decode'], true); |
|
| 1004 | 1004 | $found = false; |
| 1005 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1005 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1006 | 1006 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1007 | 1007 | if (isset($airport_info[0]['icao'])) { |
| 1008 | 1008 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1009 | 1009 | $found = true; |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1012 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1013 | 1013 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1014 | 1014 | if (isset($airport_info[0]['icao'])) { |
| 1015 | 1015 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1016 | 1016 | $found = true; |
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1019 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1020 | 1020 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1021 | 1021 | if (isset($airport_info[0]['icao'])) { |
| 1022 | 1022 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | if ($found) $row['decode'] = json_encode($decode); |
| 1027 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1027 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1028 | 1028 | $result[] = $data; |
| 1029 | 1029 | $i++; |
| 1030 | 1030 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | * @param string $label |
| 1043 | 1043 | * @return array Return ACARS data in array |
| 1044 | 1044 | */ |
| 1045 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
| 1045 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
| 1046 | 1046 | global $globalURL; |
| 1047 | 1047 | $Image = new Image($this->db); |
| 1048 | 1048 | $Spotter = new Spotter($this->db); |
@@ -1052,8 +1052,8 @@ discard block |
||
| 1052 | 1052 | if ($limit != "") |
| 1053 | 1053 | { |
| 1054 | 1054 | $limit_array = explode(",", $limit); |
| 1055 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1056 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1055 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1056 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1057 | 1057 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1058 | 1058 | { |
| 1059 | 1059 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1074,45 +1074,45 @@ discard block |
||
| 1074 | 1074 | try { |
| 1075 | 1075 | $sth = $this->db->prepare($query); |
| 1076 | 1076 | $sth->execute($query_values); |
| 1077 | - } catch(PDOException $e) { |
|
| 1077 | + } catch (PDOException $e) { |
|
| 1078 | 1078 | echo "error : ".$e->getMessage(); |
| 1079 | 1079 | return array(); |
| 1080 | 1080 | } |
| 1081 | - $i=0; |
|
| 1081 | + $i = 0; |
|
| 1082 | 1082 | $result = array(); |
| 1083 | 1083 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 1084 | 1084 | $data = array(); |
| 1085 | 1085 | if ($row['registration'] != '') { |
| 1086 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
| 1086 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
| 1087 | 1087 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1088 | - if (count($image_array) > 0) $data = array_merge($data,array('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'])); |
|
| 1089 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1090 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1088 | + if (count($image_array) > 0) $data = array_merge($data, array('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'])); |
|
| 1089 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1090 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 1091 | 1091 | $icao = ''; |
| 1092 | 1092 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 1093 | 1093 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 1094 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
| 1094 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
| 1095 | 1095 | if (isset($identicao[0])) { |
| 1096 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 1097 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1098 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1099 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1100 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 1096 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 1097 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1098 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 1099 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 1100 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 1101 | 1101 | } else $icao = $row['ident']; |
| 1102 | 1102 | $icao = $Translation->checkTranslation($icao); |
| 1103 | - $decode = json_decode($row['decode'],true); |
|
| 1103 | + $decode = json_decode($row['decode'], true); |
|
| 1104 | 1104 | $found = false; |
| 1105 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
| 1105 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
| 1106 | 1106 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1107 | 1107 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1108 | 1108 | $found = true; |
| 1109 | 1109 | } |
| 1110 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
| 1110 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
| 1111 | 1111 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1112 | 1112 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
| 1113 | 1113 | $found = true; |
| 1114 | 1114 | } |
| 1115 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
| 1115 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
| 1116 | 1116 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
| 1117 | 1117 | if (isset($airport_info[0]['icao'])) { |
| 1118 | 1118 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | } |
| 1121 | 1121 | } |
| 1122 | 1122 | if ($found) $row['decode'] = json_encode($decode); |
| 1123 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1123 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
| 1124 | 1124 | $result[] = $data; |
| 1125 | 1125 | $i++; |
| 1126 | 1126 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @param string $longitude |
| 1142 | 1142 | * @return string |
| 1143 | 1143 | */ |
| 1144 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
| 1144 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
| 1145 | 1145 | global $globalDebug, $globalDBdriver; |
| 1146 | 1146 | $ident = trim($ident); |
| 1147 | 1147 | $Translation = new Translation($this->db); |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
| 1155 | 1155 | return ''; |
| 1156 | 1156 | } |
| 1157 | - $registration = str_replace('.','',$registration); |
|
| 1157 | + $registration = str_replace('.', '', $registration); |
|
| 1158 | 1158 | $ident = $Translation->ident2icao($ident); |
| 1159 | 1159 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1160 | 1160 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1163,7 +1163,7 @@ discard block |
||
| 1163 | 1163 | try { |
| 1164 | 1164 | $sthsi = $this->db->prepare($querysi); |
| 1165 | 1165 | $sthsi->execute($querysi_values); |
| 1166 | - } catch(PDOException $e) { |
|
| 1166 | + } catch (PDOException $e) { |
|
| 1167 | 1167 | if ($globalDebug) echo $e->getMessage(); |
| 1168 | 1168 | return "error : ".$e->getMessage(); |
| 1169 | 1169 | } |
@@ -1173,8 +1173,8 @@ discard block |
||
| 1173 | 1173 | $Translation = new Translation($this->db); |
| 1174 | 1174 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1175 | 1175 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
| 1176 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1177 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1176 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1177 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
| 1178 | 1178 | } else { |
| 1179 | 1179 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1180 | 1180 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | try { |
| 1183 | 1183 | $sth = $this->db->prepare($query); |
| 1184 | 1184 | $sth->execute($query_values); |
| 1185 | - } catch(PDOException $e) { |
|
| 1185 | + } catch (PDOException $e) { |
|
| 1186 | 1186 | if ($globalDebug) echo $e->getMessage(); |
| 1187 | 1187 | return "error : ".$e->getMessage(); |
| 1188 | 1188 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $sth->closeCursor(); |
| 1191 | 1191 | if (isset($result['modes'])) $hex = $result['modes']; |
| 1192 | 1192 | else $hex = ''; |
| 1193 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
| 1193 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
| 1194 | 1194 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
| 1195 | 1195 | } |
| 1196 | 1196 | } |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | try { |
| 1201 | 1201 | $sth = $this->db->prepare($query); |
| 1202 | 1202 | $sth->execute($query_values); |
| 1203 | - } catch(PDOException $e) { |
|
| 1203 | + } catch (PDOException $e) { |
|
| 1204 | 1204 | if ($globalDebug) echo $e->getMessage(); |
| 1205 | 1205 | return "error : ".$e->getMessage(); |
| 1206 | 1206 | } |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
| 1211 | 1211 | else $ModeS = ''; |
| 1212 | 1212 | if ($ModeS == '') { |
| 1213 | - $id = explode('-',$result['flightaware_id']); |
|
| 1213 | + $id = explode('-', $result['flightaware_id']); |
|
| 1214 | 1214 | $ModeS = $id[0]; |
| 1215 | 1215 | } |
| 1216 | 1216 | if ($ModeS != '') { |
@@ -1220,20 +1220,20 @@ discard block |
||
| 1220 | 1220 | try { |
| 1221 | 1221 | $sthc = $this->db->prepare($queryc); |
| 1222 | 1222 | $sthc->execute($queryc_values); |
| 1223 | - } catch(PDOException $e) { |
|
| 1223 | + } catch (PDOException $e) { |
|
| 1224 | 1224 | if ($globalDebug) echo $e->getMessage(); |
| 1225 | 1225 | return "error : ".$e->getMessage(); |
| 1226 | 1226 | } |
| 1227 | 1227 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1228 | 1228 | $sthc->closeCursor(); |
| 1229 | - if (count($row) == 0) { |
|
| 1229 | + if (count($row) == 0) { |
|
| 1230 | 1230 | if ($globalDebug) echo " Add to ModeS table - "; |
| 1231 | 1231 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1232 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1232 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1233 | 1233 | try { |
| 1234 | 1234 | $sthi = $this->db->prepare($queryi); |
| 1235 | 1235 | $sthi->execute($queryi_values); |
| 1236 | - } catch(PDOException $e) { |
|
| 1236 | + } catch (PDOException $e) { |
|
| 1237 | 1237 | if ($globalDebug) echo $e->getMessage(); |
| 1238 | 1238 | return "error : ".$e->getMessage(); |
| 1239 | 1239 | } |
@@ -1241,15 +1241,15 @@ discard block |
||
| 1241 | 1241 | if ($globalDebug) echo " Update ModeS table - "; |
| 1242 | 1242 | if ($ICAOTypeCode != '') { |
| 1243 | 1243 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1244 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1244 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
| 1245 | 1245 | } else { |
| 1246 | 1246 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1247 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
| 1247 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | try { |
| 1250 | 1250 | $sthi = $this->db->prepare($queryi); |
| 1251 | 1251 | $sthi->execute($queryi_values); |
| 1252 | - } catch(PDOException $e) { |
|
| 1252 | + } catch (PDOException $e) { |
|
| 1253 | 1253 | if ($globalDebug) echo $e->getMessage(); |
| 1254 | 1254 | return "error : ".$e->getMessage(); |
| 1255 | 1255 | } |
@@ -1286,12 +1286,12 @@ discard block |
||
| 1286 | 1286 | elseif ($globalDBdriver == 'pgsql') { |
| 1287 | 1287 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1288 | 1288 | } |
| 1289 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
| 1289 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | try { |
| 1292 | 1292 | $sthi = $this->db->prepare($queryi); |
| 1293 | 1293 | $sthi->execute($queryi_values); |
| 1294 | - } catch(PDOException $e) { |
|
| 1294 | + } catch (PDOException $e) { |
|
| 1295 | 1295 | if ($globalDebug) echo $e->getMessage(); |
| 1296 | 1296 | return "error : ".$e->getMessage(); |
| 1297 | 1297 | } |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $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"; |
|
| 45 | + $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"; |
|
| 46 | 46 | } else { |
| 47 | - $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"; |
|
| 47 | + $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"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $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"; |
|
| 80 | + $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"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 116 | 116 | if ($over_country == '') { |
| 117 | 117 | $Tracker = new Tracker($this->db); |
| 118 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 118 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 119 | 119 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 120 | 120 | else $country = ''; |
| 121 | 121 | } else $country = $over_country; |
| 122 | 122 | // Route is not added in tracker_archive |
| 123 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 123 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 124 | 124 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 125 | - $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' => $country,':comment' => $comment,':type' => $type); |
|
| 125 | + $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' => $country, ':comment' => $comment, ':type' => $type); |
|
| 126 | 126 | try { |
| 127 | 127 | $sth = $this->db->prepare($query); |
| 128 | 128 | $sth->execute($query_values); |
| 129 | 129 | $sth->closeCursor(); |
| 130 | - } catch(PDOException $e) { |
|
| 130 | + } catch (PDOException $e) { |
|
| 131 | 131 | return "error : ".$e->getMessage(); |
| 132 | 132 | } |
| 133 | 133 | return "success"; |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | $Tracker = new Tracker($this->db); |
| 146 | 146 | date_default_timezone_set('UTC'); |
| 147 | 147 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 148 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 148 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
| 150 | 150 | return $spotter_array; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 165 | 165 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
| 166 | 166 | //$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"; |
| 167 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | 169 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 170 | 170 | /* |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 179 | 179 | */ |
| 180 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 180 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
| 181 | 181 | |
| 182 | 182 | return $spotter_array; |
| 183 | 183 | } |
@@ -189,19 +189,19 @@ discard block |
||
| 189 | 189 | * @param string $date |
| 190 | 190 | * @return array the spotter information |
| 191 | 191 | */ |
| 192 | - public function getAllArchiveTrackerDataById($id,$date = '') |
|
| 192 | + public function getAllArchiveTrackerDataById($id, $date = '') |
|
| 193 | 193 | { |
| 194 | 194 | date_default_timezone_set('UTC'); |
| 195 | 195 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 196 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 196 | + if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | + else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date"; |
|
| 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 | } |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | date_default_timezone_set('UTC'); |
| 222 | 222 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 223 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 223 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 224 | 224 | |
| 225 | 225 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | 228 | $sth = $this->db->prepare($query); |
| 229 | 229 | $sth->execute(array(':id' => $id)); |
| 230 | - } catch(PDOException $e) { |
|
| 230 | + } catch (PDOException $e) { |
|
| 231 | 231 | echo $e->getMessage(); |
| 232 | 232 | die; |
| 233 | 233 | } |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | date_default_timezone_set('UTC'); |
| 250 | 250 | |
| 251 | 251 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 252 | - $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"; |
|
| 252 | + $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"; |
|
| 253 | 253 | |
| 254 | 254 | try { |
| 255 | 255 | $sth = $this->db->prepare($query); |
| 256 | 256 | $sth->execute(array(':ident' => $ident)); |
| 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.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 278 | + $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"; |
|
| 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 | } |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | date_default_timezone_set('UTC'); |
| 302 | 302 | |
| 303 | 303 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 304 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 304 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 305 | 305 | |
| 306 | 306 | try { |
| 307 | 307 | $sth = $this->db->prepare($query); |
| 308 | 308 | $sth->execute(array(':id' => $id)); |
| 309 | - } catch(PDOException $e) { |
|
| 309 | + } catch (PDOException $e) { |
|
| 310 | 310 | echo $e->getMessage(); |
| 311 | 311 | die; |
| 312 | 312 | } |
@@ -328,13 +328,13 @@ discard block |
||
| 328 | 328 | date_default_timezone_set('UTC'); |
| 329 | 329 | |
| 330 | 330 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 331 | - $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"; |
|
| 331 | + $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"; |
|
| 332 | 332 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 333 | 333 | |
| 334 | 334 | try { |
| 335 | 335 | $sth = $this->db->prepare($query); |
| 336 | 336 | $sth->execute(array(':ident' => $ident)); |
| 337 | - } catch(PDOException $e) { |
|
| 337 | + } catch (PDOException $e) { |
|
| 338 | 338 | echo $e->getMessage(); |
| 339 | 339 | die; |
| 340 | 340 | } |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * @param $date |
| 353 | 353 | * @return array the spotter information |
| 354 | 354 | */ |
| 355 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 355 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
| 356 | 356 | { |
| 357 | 357 | $Tracker = new Tracker($this->db); |
| 358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 359 | - $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"; |
|
| 359 | + $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"; |
|
| 360 | 360 | |
| 361 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 361 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
| 362 | 362 | |
| 363 | 363 | return $spotter_array; |
| 364 | 364 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | try { |
| 375 | 375 | $sth = $this->db->prepare($query); |
| 376 | 376 | $sth->execute(); |
| 377 | - } catch(PDOException $e) { |
|
| 377 | + } catch (PDOException $e) { |
|
| 378 | 378 | echo $e->getMessage(); |
| 379 | 379 | die; |
| 380 | 380 | } |
@@ -388,24 +388,24 @@ discard block |
||
| 388 | 388 | * @param array $filter |
| 389 | 389 | * @return array the spotter information |
| 390 | 390 | */ |
| 391 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 391 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
| 392 | 392 | { |
| 393 | 393 | global $globalDBdriver; |
| 394 | 394 | date_default_timezone_set('UTC'); |
| 395 | 395 | |
| 396 | 396 | $filter_query = ''; |
| 397 | 397 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 398 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 398 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 399 | 399 | } |
| 400 | 400 | // Use spotter_output also ? |
| 401 | 401 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 402 | - $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 "; |
|
| 402 | + $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 "; |
|
| 403 | 403 | } |
| 404 | 404 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 405 | 405 | $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 "; |
| 406 | 406 | } |
| 407 | 407 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 408 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 408 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 425 | 425 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 426 | 426 | */ |
| 427 | - $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 |
|
| 427 | + $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 |
|
| 428 | 428 | FROM tracker_archive |
| 429 | 429 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 430 | 430 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 431 | 431 | '.$filter_query.' ORDER BY famtrackid'; |
| 432 | 432 | } else { |
| 433 | 433 | //$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'; |
| 434 | - $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 |
|
| 434 | + $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 |
|
| 435 | 435 | FROM tracker_archive |
| 436 | 436 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 437 | 437 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | try { |
| 442 | 442 | $sth = $this->db->prepare($query); |
| 443 | 443 | $sth->execute(); |
| 444 | - } catch(PDOException $e) { |
|
| 444 | + } catch (PDOException $e) { |
|
| 445 | 445 | echo $e->getMessage(); |
| 446 | 446 | die; |
| 447 | 447 | } |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | * @param array $filter |
| 459 | 459 | * @return array the spotter information |
| 460 | 460 | */ |
| 461 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 461 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
| 462 | 462 | { |
| 463 | 463 | global $globalDBdriver; |
| 464 | 464 | date_default_timezone_set('UTC'); |
| 465 | 465 | |
| 466 | 466 | $filter_query = ''; |
| 467 | 467 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 468 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 468 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 469 | 469 | } |
| 470 | 470 | // Should use spotter_output also ? |
| 471 | 471 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 472 | - $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 "; |
|
| 472 | + $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 "; |
|
| 473 | 473 | } |
| 474 | 474 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 475 | 475 | $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 "; |
| 476 | 476 | } |
| 477 | 477 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 478 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 478 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | FROM tracker_archive |
| 486 | 486 | 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'; |
| 487 | 487 | */ |
| 488 | - $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 |
|
| 488 | + $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 |
|
| 489 | 489 | FROM tracker_archive_output |
| 490 | 490 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 491 | 491 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 501 | 501 | '.$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'; |
| 502 | 502 | */ |
| 503 | - $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 |
|
| 503 | + $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 |
|
| 504 | 504 | FROM tracker_archive_output |
| 505 | 505 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 506 | 506 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | try { |
| 513 | 513 | $sth = $this->db->prepare($query); |
| 514 | 514 | $sth->execute(); |
| 515 | - } catch(PDOException $e) { |
|
| 515 | + } catch (PDOException $e) { |
|
| 516 | 516 | echo $e->getMessage(); |
| 517 | 517 | die; |
| 518 | 518 | } |
@@ -529,23 +529,23 @@ discard block |
||
| 529 | 529 | * @param array $filter |
| 530 | 530 | * @return array the spotter information |
| 531 | 531 | */ |
| 532 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 532 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
| 533 | 533 | { |
| 534 | 534 | global $globalDBdriver, $globalLiveInterval; |
| 535 | 535 | date_default_timezone_set('UTC'); |
| 536 | 536 | |
| 537 | 537 | $filter_query = ''; |
| 538 | 538 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 539 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 539 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 540 | 540 | } |
| 541 | 541 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 542 | - $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 "; |
|
| 542 | + $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 "; |
|
| 543 | 543 | } |
| 544 | 544 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 545 | 545 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 546 | 546 | } |
| 547 | 547 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 548 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 548 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | try { |
| 561 | 561 | $sth = $this->db->prepare($query); |
| 562 | 562 | $sth->execute(); |
| 563 | - } catch(PDOException $e) { |
|
| 563 | + } catch (PDOException $e) { |
|
| 564 | 564 | echo $e->getMessage(); |
| 565 | 565 | die; |
| 566 | 566 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param array $filters |
| 605 | 605 | * @return array the spotter information |
| 606 | 606 | */ |
| 607 | - 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()) |
|
| 607 | + 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()) |
|
| 608 | 608 | { |
| 609 | 609 | global $globalTimezone, $globalDBdriver; |
| 610 | 610 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | $q_array = explode(" ", $q); |
| 628 | 628 | |
| 629 | - foreach ($q_array as $q_item){ |
|
| 629 | + foreach ($q_array as $q_item) { |
|
| 630 | 630 | $additional_query .= " AND ("; |
| 631 | 631 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 632 | 632 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | if ($registration != "") |
| 660 | 660 | { |
| 661 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 661 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 662 | 662 | if (!is_string($registration)) |
| 663 | 663 | { |
| 664 | 664 | return array(); |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | if ($aircraft_icao != "") |
| 671 | 671 | { |
| 672 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 672 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 673 | 673 | if (!is_string($aircraft_icao)) |
| 674 | 674 | { |
| 675 | 675 | return array(); |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | if ($aircraft_manufacturer != "") |
| 682 | 682 | { |
| 683 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 683 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 684 | 684 | if (!is_string($aircraft_manufacturer)) |
| 685 | 685 | { |
| 686 | 686 | return array(); |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | if ($airline_icao != "") |
| 703 | 703 | { |
| 704 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 704 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 705 | 705 | if (!is_string($airline_icao)) |
| 706 | 706 | { |
| 707 | 707 | return array(); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | if ($airline_country != "") |
| 714 | 714 | { |
| 715 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 715 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 716 | 716 | if (!is_string($airline_country)) |
| 717 | 717 | { |
| 718 | 718 | return array(); |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | if ($airline_type != "") |
| 725 | 725 | { |
| 726 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 726 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 727 | 727 | if (!is_string($airline_type)) |
| 728 | 728 | { |
| 729 | 729 | return array(); |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | |
| 746 | 746 | if ($airport != "") |
| 747 | 747 | { |
| 748 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 748 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 749 | 749 | if (!is_string($airport)) |
| 750 | 750 | { |
| 751 | 751 | return array(); |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | if ($airport_country != "") |
| 758 | 758 | { |
| 759 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 759 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 760 | 760 | if (!is_string($airport_country)) |
| 761 | 761 | { |
| 762 | 762 | return array(); |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | if ($callsign != "") |
| 769 | 769 | { |
| 770 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 770 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 771 | 771 | if (!is_string($callsign)) |
| 772 | 772 | { |
| 773 | 773 | return array(); |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $translate = $Translation->ident2icao($callsign); |
| 776 | 776 | if ($translate != $callsign) { |
| 777 | 777 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
| 778 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 778 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 779 | 779 | } else { |
| 780 | 780 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 781 | 781 | } |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | |
| 785 | 785 | if ($owner != "") |
| 786 | 786 | { |
| 787 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 787 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 788 | 788 | if (!is_string($owner)) |
| 789 | 789 | { |
| 790 | 790 | return array(); |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | |
| 796 | 796 | if ($pilot_name != "") |
| 797 | 797 | { |
| 798 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 798 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 799 | 799 | if (!is_string($pilot_name)) |
| 800 | 800 | { |
| 801 | 801 | return array(); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | |
| 807 | 807 | if ($pilot_id != "") |
| 808 | 808 | { |
| 809 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 809 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | 810 | if (!is_string($pilot_id)) |
| 811 | 811 | { |
| 812 | 812 | return array(); |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | |
| 818 | 818 | if ($departure_airport_route != "") |
| 819 | 819 | { |
| 820 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 820 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 821 | 821 | if (!is_string($departure_airport_route)) |
| 822 | 822 | { |
| 823 | 823 | return array(); |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | if ($arrival_airport_route != "") |
| 830 | 830 | { |
| 831 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 831 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 832 | 832 | if (!is_string($arrival_airport_route)) |
| 833 | 833 | { |
| 834 | 834 | return array(); |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | { |
| 842 | 842 | $altitude_array = explode(",", $altitude); |
| 843 | 843 | |
| 844 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 844 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 846 | 846 | |
| 847 | 847 | |
| 848 | 848 | if ($altitude_array[1] != "") |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | { |
| 861 | 861 | $date_array = explode(",", $date_posted); |
| 862 | 862 | |
| 863 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 864 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 863 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 864 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 865 | 865 | |
| 866 | 866 | if ($globalTimezone != '') { |
| 867 | 867 | date_default_timezone_set($globalTimezone); |
@@ -893,8 +893,8 @@ discard block |
||
| 893 | 893 | { |
| 894 | 894 | $limit_array = explode(",", $limit); |
| 895 | 895 | |
| 896 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 896 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 898 | 898 | |
| 899 | 899 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 900 | 900 | { |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | |
| 907 | 907 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 908 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 909 | - $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 |
|
| 908 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 909 | + $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 |
|
| 910 | 910 | 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)) |
| 911 | 911 | 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"; |
| 912 | 912 | } else { |
@@ -923,12 +923,12 @@ discard block |
||
| 923 | 923 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 926 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 927 | 927 | WHERE tracker_archive_output.ident <> '' |
| 928 | 928 | ".$additional_query." |
| 929 | 929 | ".$filter_query.$orderby_query; |
| 930 | 930 | } |
| 931 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 931 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 932 | 932 | |
| 933 | 933 | return $spotter_array; |
| 934 | 934 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | try { |
| 946 | 946 | $sth = $this->db->prepare($query); |
| 947 | 947 | $sth->execute(); |
| 948 | - } catch(PDOException $e) { |
|
| 948 | + } catch (PDOException $e) { |
|
| 949 | 949 | return "error"; |
| 950 | 950 | } |
| 951 | 951 | return ''; |
@@ -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 | { |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | $query_values = array(); |
| 1031 | 1031 | $limit_query = ''; |
| 1032 | 1032 | $additional_query = ''; |
| 1033 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1033 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1034 | 1034 | |
| 1035 | 1035 | if ($owner != "") |
| 1036 | 1036 | { |
@@ -1047,8 +1047,8 @@ discard block |
||
| 1047 | 1047 | { |
| 1048 | 1048 | $limit_array = explode(",", $limit); |
| 1049 | 1049 | |
| 1050 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1050 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1052 | 1052 | |
| 1053 | 1053 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1054 | 1054 | { |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | $query_values = array(); |
| 1092 | 1092 | $limit_query = ''; |
| 1093 | 1093 | $additional_query = ''; |
| 1094 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1094 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1095 | 1095 | |
| 1096 | 1096 | if ($pilot != "") |
| 1097 | 1097 | { |
@@ -1103,8 +1103,8 @@ discard block |
||
| 1103 | 1103 | { |
| 1104 | 1104 | $limit_array = explode(",", $limit); |
| 1105 | 1105 | |
| 1106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1108 | 1108 | |
| 1109 | 1109 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1110 | 1110 | { |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * @param string $sincedate |
| 1137 | 1137 | * @return array the airline country list |
| 1138 | 1138 | */ |
| 1139 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1139 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1140 | 1140 | { |
| 1141 | 1141 | global $globalDBdriver; |
| 1142 | 1142 | /* |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | $flight_array = array(); |
| 1166 | 1166 | $temp_array = array(); |
| 1167 | 1167 | |
| 1168 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1168 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1169 | 1169 | { |
| 1170 | 1170 | $temp_array['flight_count'] = $row['nb']; |
| 1171 | 1171 | $temp_array['flight_country'] = $row['name']; |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | * @param string $sincedate |
| 1185 | 1185 | * @return array the airline country list |
| 1186 | 1186 | */ |
| 1187 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1187 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1188 | 1188 | { |
| 1189 | 1189 | global $globalDBdriver; |
| 1190 | 1190 | /* |
@@ -1213,7 +1213,7 @@ discard block |
||
| 1213 | 1213 | $flight_array = array(); |
| 1214 | 1214 | $temp_array = array(); |
| 1215 | 1215 | |
| 1216 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1216 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1217 | 1217 | { |
| 1218 | 1218 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1219 | 1219 | $temp_array['flight_count'] = $row['nb']; |
@@ -1232,14 +1232,14 @@ discard block |
||
| 1232 | 1232 | * @param $date |
| 1233 | 1233 | * @return array the spotter information |
| 1234 | 1234 | */ |
| 1235 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1235 | + public function getDateArchiveTrackerDataById($id, $date) |
|
| 1236 | 1236 | { |
| 1237 | 1237 | $Tracker = new Tracker($this->db); |
| 1238 | 1238 | date_default_timezone_set('UTC'); |
| 1239 | 1239 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1240 | - $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'; |
|
| 1241 | - $date = date('c',$date); |
|
| 1242 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1240 | + $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'; |
|
| 1241 | + $date = date('c', $date); |
|
| 1242 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1243 | 1243 | return $spotter_array; |
| 1244 | 1244 | } |
| 1245 | 1245 | |
@@ -1250,14 +1250,14 @@ discard block |
||
| 1250 | 1250 | * @param $date |
| 1251 | 1251 | * @return array the spotter information |
| 1252 | 1252 | */ |
| 1253 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1253 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
| 1254 | 1254 | { |
| 1255 | 1255 | $Tracker = new Tracker($this->db); |
| 1256 | 1256 | date_default_timezone_set('UTC'); |
| 1257 | 1257 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1258 | - $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'; |
|
| 1259 | - $date = date('c',$date); |
|
| 1260 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1258 | + $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'; |
|
| 1259 | + $date = date('c', $date); |
|
| 1260 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1261 | 1261 | return $spotter_array; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1270,7 +1270,7 @@ discard block |
||
| 1270 | 1270 | * @param array $filters |
| 1271 | 1271 | * @return array the spotter information |
| 1272 | 1272 | */ |
| 1273 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1273 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1274 | 1274 | { |
| 1275 | 1275 | global $global_query; |
| 1276 | 1276 | $Tracker = new Tracker($this->db); |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | $query_values = array(); |
| 1279 | 1279 | $limit_query = ''; |
| 1280 | 1280 | $additional_query = ''; |
| 1281 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1281 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1282 | 1282 | |
| 1283 | 1283 | if ($airport != "") |
| 1284 | 1284 | { |
@@ -1295,8 +1295,8 @@ discard block |
||
| 1295 | 1295 | { |
| 1296 | 1296 | $limit_array = explode(",", $limit); |
| 1297 | 1297 | |
| 1298 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1298 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1300 | 1300 | |
| 1301 | 1301 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1302 | 1302 | { |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 10 | 10 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
| 11 | 11 | |
| 12 | -class Marine{ |
|
| 12 | +class Marine { |
|
| 13 | 13 | public $db; |
| 14 | 14 | |
| 15 | 15 | public function __construct($dbc = null) { |
@@ -25,33 +25,33 @@ discard block |
||
| 25 | 25 | * @param bool $and |
| 26 | 26 | * @return string the SQL part |
| 27 | 27 | */ |
| 28 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 28 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 29 | 29 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 30 | 30 | $filters = array(); |
| 31 | 31 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 32 | 32 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 33 | 33 | $filters = $globalStatsFilters[$globalFilterName]; |
| 34 | 34 | } else { |
| 35 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 35 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | if (isset($filter[0]['source'])) { |
| 39 | - $filters = array_merge($filters,$filter); |
|
| 39 | + $filters = array_merge($filters, $filter); |
|
| 40 | 40 | } |
| 41 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 42 | 42 | $filter_query_join = ''; |
| 43 | 43 | $filter_query_where = ''; |
| 44 | - foreach($filters as $flt) { |
|
| 44 | + foreach ($filters as $flt) { |
|
| 45 | 45 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 48 | 48 | } else { |
| 49 | - $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"; |
|
| 49 | + $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"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 54 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 54 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 55 | 55 | } |
| 56 | 56 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 57 | 57 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 90 | 90 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 91 | 91 | if ($filter_query_where != '') { |
| 92 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 92 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 93 | 93 | } |
| 94 | 94 | $filter_query = $filter_query_join.$filter_query_where; |
| 95 | 95 | return $filter_query; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param bool $schedules |
| 105 | 105 | * @return array the spotter information |
| 106 | 106 | */ |
| 107 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 107 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 108 | 108 | { |
| 109 | 109 | global $globalVM; |
| 110 | 110 | date_default_timezone_set('UTC'); |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | $sth = $this->db->prepare($query.$limitQuery); |
| 126 | 126 | $sth->execute($params); |
| 127 | 127 | } catch (PDOException $e) { |
| 128 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 128 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 129 | 129 | exit(); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $num_rows = 0; |
| 133 | 133 | $spotter_array = array(); |
| 134 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 134 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 135 | 135 | { |
| 136 | 136 | $num_rows++; |
| 137 | 137 | $temp_array = array(); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
| 152 | 152 | if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
| 153 | - if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES); |
|
| 153 | + if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES); |
|
| 154 | 154 | if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
| 155 | 155 | if (isset($row['status'])) $temp_array['status'] = $row['status']; |
| 156 | 156 | if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 175 | 175 | |
| 176 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 176 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 177 | 177 | { |
| 178 | 178 | $Image = new Image($this->db); |
| 179 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 179 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 180 | 180 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 181 | 181 | unset($Image); |
| 182 | 182 | if (count($image_array) > 0) { |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | $temp_array['image_source_website'] = $image_array[0]['image_source_website']; |
| 187 | 187 | $temp_array['image_copyright'] = $image_array[0]['image_copyright']; |
| 188 | 188 | } |
| 189 | - } elseif(isset($temp_array['type']) && $temp_array['type'] != "") |
|
| 189 | + } elseif (isset($temp_array['type']) && $temp_array['type'] != "") |
|
| 190 | 190 | { |
| 191 | 191 | $Image = new Image($this->db); |
| 192 | - $image_array = $Image->getMarineImage('','','',$temp_array['type']); |
|
| 192 | + $image_array = $Image->getMarineImage('', '', '', $temp_array['type']); |
|
| 193 | 193 | unset($Image); |
| 194 | 194 | if (count($image_array) > 0) { |
| 195 | 195 | $temp_array['image'] = $image_array[0]['image']; |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 226 | 226 | } else { |
| 227 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 227 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 228 | 228 | } |
| 229 | 229 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 230 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 231 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 230 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 231 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 232 | 232 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 233 | 233 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 234 | 234 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 235 | 235 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 236 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 237 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 236 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 237 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 238 | 238 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | if ($limit != "") |
| 270 | 270 | { |
| 271 | 271 | $limit_array = explode(",", $limit); |
| 272 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 273 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 272 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 273 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 274 | 274 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 275 | 275 | { |
| 276 | 276 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | } else { |
| 285 | 285 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 286 | 286 | } |
| 287 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 288 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 287 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 288 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 289 | 289 | return $spotter_array; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | if ($id == '') return array(); |
| 304 | 304 | $additional_query = "marine_output.fammarine_id = :id"; |
| 305 | 305 | $query_values = array(':id' => $id); |
| 306 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 307 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 306 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 307 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 308 | 308 | return $spotter_array; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $query_values = array(); |
| 327 | 327 | $limit_query = ''; |
| 328 | 328 | $additional_query = ''; |
| 329 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 329 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 330 | 330 | if ($ident != "") |
| 331 | 331 | { |
| 332 | 332 | if (!is_string($ident)) |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | { |
| 343 | 343 | $limit_array = explode(",", $limit); |
| 344 | 344 | |
| 345 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 346 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 345 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 346 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 347 | 347 | |
| 348 | 348 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 349 | 349 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | date_default_timezone_set('UTC'); |
| 384 | 384 | |
| 385 | 385 | $limit_query = ''; |
| 386 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 386 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 387 | 387 | if (!is_string($type)) |
| 388 | 388 | { |
| 389 | 389 | return array(); |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | { |
| 397 | 397 | $limit_array = explode(",", $limit); |
| 398 | 398 | |
| 399 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 400 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 399 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 400 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 401 | 401 | |
| 402 | 402 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 403 | 403 | { |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $limit_query = ''; |
| 437 | 437 | $additional_query = ''; |
| 438 | 438 | |
| 439 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 439 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 440 | 440 | |
| 441 | 441 | if ($date != "") |
| 442 | 442 | { |
@@ -462,8 +462,8 @@ discard block |
||
| 462 | 462 | { |
| 463 | 463 | $limit_array = explode(",", $limit); |
| 464 | 464 | |
| 465 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 466 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 465 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 466 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 467 | 467 | |
| 468 | 468 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 469 | 469 | { |
@@ -501,8 +501,8 @@ discard block |
||
| 501 | 501 | $query_values = array(); |
| 502 | 502 | $limit_query = ''; |
| 503 | 503 | $additional_query = ''; |
| 504 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 505 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 504 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 505 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 506 | 506 | if ($captain != "") |
| 507 | 507 | { |
| 508 | 508 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -511,8 +511,8 @@ discard block |
||
| 511 | 511 | if ($limit != "") |
| 512 | 512 | { |
| 513 | 513 | $limit_array = explode(",", $limit); |
| 514 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 515 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 514 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 515 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 516 | 516 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 517 | 517 | { |
| 518 | 518 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -542,13 +542,13 @@ discard block |
||
| 542 | 542 | */ |
| 543 | 543 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
| 544 | 544 | { |
| 545 | - global $global_marine_query,$globalDBdriver; |
|
| 545 | + global $global_marine_query, $globalDBdriver; |
|
| 546 | 546 | date_default_timezone_set('UTC'); |
| 547 | 547 | $query_values = array(); |
| 548 | 548 | $limit_query = ''; |
| 549 | 549 | $additional_query = ''; |
| 550 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 551 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 550 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 551 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 552 | 552 | if ($race != "") |
| 553 | 553 | { |
| 554 | 554 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -557,8 +557,8 @@ discard block |
||
| 557 | 557 | if ($limit != "") |
| 558 | 558 | { |
| 559 | 559 | $limit_array = explode(",", $limit); |
| 560 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 561 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 560 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 561 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 562 | 562 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 563 | 563 | { |
| 564 | 564 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -588,14 +588,14 @@ discard block |
||
| 588 | 588 | * @param array $filters |
| 589 | 589 | * @return Integer number of race for a captain |
| 590 | 590 | */ |
| 591 | - public function countRacesByCaptain($captain,$filters = array()) |
|
| 591 | + public function countRacesByCaptain($captain, $filters = array()) |
|
| 592 | 592 | { |
| 593 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 594 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 595 | - $query = "SELECT COUNT(*) AS nb |
|
| 593 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 594 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 595 | + $query = "SELECT COUNT(*) AS nb |
|
| 596 | 596 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
| 597 | 597 | $query_values = array(); |
| 598 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 598 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 599 | 599 | $sth = $this->db->prepare($query); |
| 600 | 600 | $sth->execute($query_values); |
| 601 | 601 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -609,14 +609,14 @@ discard block |
||
| 609 | 609 | * @param array $filters |
| 610 | 610 | * @return String Duration of all races |
| 611 | 611 | */ |
| 612 | - public function countCaptainsByRace($race,$filters = array()) |
|
| 612 | + public function countCaptainsByRace($race, $filters = array()) |
|
| 613 | 613 | { |
| 614 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 615 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 616 | - $query = "SELECT COUNT(*) AS nb |
|
| 614 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 615 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 616 | + $query = "SELECT COUNT(*) AS nb |
|
| 617 | 617 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
| 618 | 618 | $query_values = array(); |
| 619 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 619 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 620 | 620 | $sth = $this->db->prepare($query); |
| 621 | 621 | $sth->execute($query_values); |
| 622 | 622 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -633,44 +633,44 @@ discard block |
||
| 633 | 633 | * @param string $day |
| 634 | 634 | * @return array the boat list |
| 635 | 635 | */ |
| 636 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 636 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 637 | 637 | { |
| 638 | 638 | global $globalDBdriver; |
| 639 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 640 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 641 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 639 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 640 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 641 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 642 | 642 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
| 643 | 643 | $query_values = array(); |
| 644 | 644 | if ($year != '') { |
| 645 | 645 | if ($globalDBdriver == 'mysql') { |
| 646 | 646 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 647 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 647 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 648 | 648 | } else { |
| 649 | 649 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 650 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 650 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | if ($month != '') { |
| 654 | 654 | if ($globalDBdriver == 'mysql') { |
| 655 | 655 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 656 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 656 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 657 | 657 | } else { |
| 658 | 658 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 659 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 659 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | if ($day != '') { |
| 663 | 663 | if ($globalDBdriver == 'mysql') { |
| 664 | 664 | $query .= " AND DAY(marine_output.date) = :day"; |
| 665 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 665 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 666 | 666 | } else { |
| 667 | 667 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 668 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 668 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | $query .= " GROUP BY marine_output.type |
| 672 | 672 | ORDER BY type_count DESC"; |
| 673 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 673 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 674 | 674 | $sth = $this->db->prepare($query); |
| 675 | 675 | $sth->execute($query_values); |
| 676 | 676 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -686,44 +686,44 @@ discard block |
||
| 686 | 686 | * @param string $day |
| 687 | 687 | * @return array the boat list |
| 688 | 688 | */ |
| 689 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
| 689 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
| 690 | 690 | { |
| 691 | 691 | global $globalDBdriver; |
| 692 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 693 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 694 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 692 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 693 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 694 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 695 | 695 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
| 696 | 696 | $query_values = array(); |
| 697 | 697 | if ($year != '') { |
| 698 | 698 | if ($globalDBdriver == 'mysql') { |
| 699 | 699 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 700 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 700 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 701 | 701 | } else { |
| 702 | 702 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 703 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 703 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | if ($month != '') { |
| 707 | 707 | if ($globalDBdriver == 'mysql') { |
| 708 | 708 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 709 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 709 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 710 | 710 | } else { |
| 711 | 711 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 712 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 712 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 713 | 713 | } |
| 714 | 714 | } |
| 715 | 715 | if ($day != '') { |
| 716 | 716 | if ($globalDBdriver == 'mysql') { |
| 717 | 717 | $query .= " AND DAY(marine_output.date) = :day"; |
| 718 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 718 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 719 | 719 | } else { |
| 720 | 720 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 721 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 721 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | $query .= " GROUP BY marine_output.type |
| 725 | 725 | ORDER BY type_count DESC"; |
| 726 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 726 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 727 | 727 | $sth = $this->db->prepare($query); |
| 728 | 728 | $sth->execute($query_values); |
| 729 | 729 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -739,47 +739,47 @@ discard block |
||
| 739 | 739 | * @param string $day |
| 740 | 740 | * @return String Duration of all race |
| 741 | 741 | */ |
| 742 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 742 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 743 | 743 | { |
| 744 | 744 | global $globalDBdriver; |
| 745 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 746 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 747 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 745 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 746 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 747 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 748 | 748 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
| 749 | 749 | AND last_seen > date"; |
| 750 | 750 | $query_values = array(); |
| 751 | 751 | if ($year != '') { |
| 752 | 752 | if ($globalDBdriver == 'mysql') { |
| 753 | 753 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 754 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 754 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 755 | 755 | } else { |
| 756 | 756 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 757 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 757 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | if ($month != '') { |
| 761 | 761 | if ($globalDBdriver == 'mysql') { |
| 762 | 762 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 763 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 763 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 764 | 764 | } else { |
| 765 | 765 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 766 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 766 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | if ($day != '') { |
| 770 | 770 | if ($globalDBdriver == 'mysql') { |
| 771 | 771 | $query .= " AND DAY(marine_output.date) = :day"; |
| 772 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 772 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 773 | 773 | } else { |
| 774 | 774 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 775 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 775 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 778 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 779 | 779 | $sth = $this->db->prepare($query); |
| 780 | 780 | $sth->execute($query_values); |
| 781 | 781 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 782 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 782 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 783 | 783 | else return $result[0]['duration']; |
| 784 | 784 | } |
| 785 | 785 | |
@@ -793,38 +793,38 @@ discard block |
||
| 793 | 793 | * @param string $day |
| 794 | 794 | * @return array Duration of all race |
| 795 | 795 | */ |
| 796 | - public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
|
| 796 | + public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
|
| 797 | 797 | { |
| 798 | 798 | global $globalDBdriver; |
| 799 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 800 | - $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
| 799 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 800 | + $query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name |
|
| 801 | 801 | FROM marine_output".$filter_query." last_seen > date"; |
| 802 | 802 | $query_values = array(); |
| 803 | 803 | if ($year != '') { |
| 804 | 804 | if ($globalDBdriver == 'mysql') { |
| 805 | 805 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 806 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 806 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 807 | 807 | } else { |
| 808 | 808 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 809 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 809 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 810 | 810 | } |
| 811 | 811 | } |
| 812 | 812 | if ($month != '') { |
| 813 | 813 | if ($globalDBdriver == 'mysql') { |
| 814 | 814 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 815 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 815 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 816 | 816 | } else { |
| 817 | 817 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 818 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 818 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | if ($day != '') { |
| 822 | 822 | if ($globalDBdriver == 'mysql') { |
| 823 | 823 | $query .= " AND DAY(marine_output.date) = :day"; |
| 824 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 824 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 825 | 825 | } else { |
| 826 | 826 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 827 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 827 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | $query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC"; |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | $duration_array = array(); |
| 837 | 837 | $temp_array = array(); |
| 838 | 838 | |
| 839 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 839 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 840 | 840 | { |
| 841 | 841 | if ($row['duration'] != '') { |
| 842 | 842 | $temp_array['marine_duration_days'] = $row['duration']; |
@@ -858,8 +858,8 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function getAllCaptainNames($filters = array()) |
| 860 | 860 | { |
| 861 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 862 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 861 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 862 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 863 | 863 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
| 864 | 864 | ORDER BY marine_output.captain_name ASC"; |
| 865 | 865 | |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | */ |
| 877 | 877 | public function getAllRaceNames($filters = array()) |
| 878 | 878 | { |
| 879 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 880 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 879 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 880 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 881 | 881 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
| 882 | 882 | ORDER BY marine_output.race_name ASC"; |
| 883 | 883 | |
@@ -894,11 +894,11 @@ discard block |
||
| 894 | 894 | * @param array $filters |
| 895 | 895 | * @return array list of source name |
| 896 | 896 | */ |
| 897 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 897 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 898 | 898 | { |
| 899 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 899 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 900 | 900 | $query_values = array(); |
| 901 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 901 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 902 | 902 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 903 | 903 | if ($type != '') { |
| 904 | 904 | $query_values = array(':type' => $type); |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | $source_array = array(); |
| 914 | 914 | $temp_array = array(); |
| 915 | 915 | |
| 916 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 916 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 917 | 917 | { |
| 918 | 918 | $temp_array['source_name'] = $row['source_name']; |
| 919 | 919 | $source_array[] = $temp_array; |
@@ -930,8 +930,8 @@ discard block |
||
| 930 | 930 | */ |
| 931 | 931 | public function getAllIdents($filters = array()) |
| 932 | 932 | { |
| 933 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 934 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 933 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 934 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 935 | 935 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 936 | 936 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 937 | 937 | |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | $ident_array = array(); |
| 942 | 942 | $temp_array = array(); |
| 943 | 943 | |
| 944 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 944 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 945 | 945 | { |
| 946 | 946 | $temp_array['ident'] = $row['ident']; |
| 947 | 947 | $ident_array[] = $temp_array; |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | */ |
| 959 | 959 | public function getIdentity($mmsi) |
| 960 | 960 | { |
| 961 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 961 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 962 | 962 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 963 | 963 | $sth = $this->db->prepare($query); |
| 964 | 964 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -975,23 +975,23 @@ discard block |
||
| 975 | 975 | * @param $callsign |
| 976 | 976 | * @param $type |
| 977 | 977 | */ |
| 978 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
| 978 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
| 979 | 979 | { |
| 980 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 980 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 981 | 981 | if ($mmsi != '') { |
| 982 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 983 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 984 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 985 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 982 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 983 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 984 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 985 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 986 | 986 | $identinfo = $this->getIdentity($mmsi); |
| 987 | 987 | if (empty($identinfo)) { |
| 988 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 988 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 989 | 989 | $sth = $this->db->prepare($query); |
| 990 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 990 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 991 | 991 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 992 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 992 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 993 | 993 | $sth = $this->db->prepare($query); |
| 994 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 994 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | } |
@@ -1012,12 +1012,12 @@ discard block |
||
| 1012 | 1012 | } else $offset = '+00:00'; |
| 1013 | 1013 | |
| 1014 | 1014 | if ($globalDBdriver == 'mysql') { |
| 1015 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 1015 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 1016 | 1016 | FROM marine_output |
| 1017 | 1017 | WHERE marine_output.date <> '' |
| 1018 | 1018 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 1019 | 1019 | } else { |
| 1020 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 1020 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 1021 | 1021 | FROM marine_output |
| 1022 | 1022 | WHERE marine_output.date <> '' |
| 1023 | 1023 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | $date_array = array(); |
| 1030 | 1030 | $temp_array = array(); |
| 1031 | 1031 | |
| 1032 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1032 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1033 | 1033 | { |
| 1034 | 1034 | $temp_array['date'] = $row['date']; |
| 1035 | 1035 | |
@@ -1047,10 +1047,10 @@ discard block |
||
| 1047 | 1047 | * @return String success or false |
| 1048 | 1048 | * |
| 1049 | 1049 | */ |
| 1050 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 1050 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 1051 | 1051 | { |
| 1052 | 1052 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 1053 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 1053 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $this->db->prepare($query); |
| 1056 | 1056 | $sth->execute($query_values); |
@@ -1068,10 +1068,10 @@ discard block |
||
| 1068 | 1068 | * @return String success or false |
| 1069 | 1069 | * |
| 1070 | 1070 | */ |
| 1071 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 1071 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 1072 | 1072 | { |
| 1073 | 1073 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 1074 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 1074 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 1075 | 1075 | try { |
| 1076 | 1076 | $sth = $this->db->prepare($query); |
| 1077 | 1077 | $sth->execute($query_values); |
@@ -1090,11 +1090,11 @@ discard block |
||
| 1090 | 1090 | * @return String success or false |
| 1091 | 1091 | * |
| 1092 | 1092 | */ |
| 1093 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 1093 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 1094 | 1094 | { |
| 1095 | 1095 | |
| 1096 | 1096 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 1097 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 1097 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 1098 | 1098 | |
| 1099 | 1099 | try { |
| 1100 | 1100 | $sth = $this->db->prepare($query); |
@@ -1123,17 +1123,17 @@ discard block |
||
| 1123 | 1123 | * @param string $race_begin |
| 1124 | 1124 | * @return String success or false |
| 1125 | 1125 | */ |
| 1126 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1126 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 1127 | 1127 | { |
| 1128 | 1128 | if ($latitude == '') $latitude = NULL; |
| 1129 | 1129 | if ($longitude == '') $longitude = NULL; |
| 1130 | 1130 | $groundspeed = round($groundspeed); |
| 1131 | 1131 | if ($race_begin != '') { |
| 1132 | 1132 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
| 1133 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin); |
|
| 1133 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin); |
|
| 1134 | 1134 | } else { |
| 1135 | 1135 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id'; |
| 1136 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status); |
|
| 1136 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | try { |
| 1139 | 1139 | $sth = $this->db->prepare($query); |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | * @param string $race_time |
| 1178 | 1178 | * @return String success or false |
| 1179 | 1179 | */ |
| 1180 | - 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 = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
|
| 1180 | + 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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
| 1181 | 1181 | { |
| 1182 | 1182 | global $globalMarineImageFetch; |
| 1183 | 1183 | |
@@ -1249,34 +1249,34 @@ discard block |
||
| 1249 | 1249 | $date = date("Y-m-d H:i:s", time()); |
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1253 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1254 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1255 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1256 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1257 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1258 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1259 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1260 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 1261 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 1262 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1263 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1264 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1265 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1266 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 1267 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 1268 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 1269 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 1270 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 1271 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 1272 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
| 1273 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1274 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1252 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1253 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1254 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1255 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1256 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1257 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1258 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1259 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1260 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 1261 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 1262 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1263 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1264 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1265 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1266 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 1267 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 1268 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 1269 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 1270 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 1271 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 1272 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
| 1273 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1274 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1275 | 1275 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 1276 | 1276 | $Image = new Image($this->db); |
| 1277 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 1277 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 1278 | 1278 | if (!isset($image_array[0]['mmsi'])) { |
| 1279 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 1279 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | unset($Image); |
| 1282 | 1282 | } |
@@ -1292,10 +1292,10 @@ discard block |
||
| 1292 | 1292 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 1293 | 1293 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1294 | 1294 | if ($arrival_date == '') $arrival_date = NULL; |
| 1295 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1295 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1296 | 1296 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1297 | 1297 | |
| 1298 | - $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,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 1298 | + $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, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 1299 | 1299 | try { |
| 1300 | 1300 | $sth = $this->db->prepare($query); |
| 1301 | 1301 | $sth->execute($query_values); |
@@ -1319,13 +1319,13 @@ discard block |
||
| 1319 | 1319 | { |
| 1320 | 1320 | global $globalDBdriver, $globalTimezone; |
| 1321 | 1321 | if ($globalDBdriver == 'mysql') { |
| 1322 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1322 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1323 | 1323 | WHERE marine_output.ident = :ident |
| 1324 | 1324 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 1325 | 1325 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1326 | 1326 | $query_data = array(':ident' => $ident); |
| 1327 | 1327 | } else { |
| 1328 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1328 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1329 | 1329 | WHERE marine_output.ident = :ident |
| 1330 | 1330 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1331 | 1331 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | |
| 1335 | 1335 | $sth = $this->db->prepare($query); |
| 1336 | 1336 | $sth->execute($query_data); |
| 1337 | - $ident_result=''; |
|
| 1338 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1337 | + $ident_result = ''; |
|
| 1338 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1339 | 1339 | { |
| 1340 | 1340 | $ident_result = $row['ident']; |
| 1341 | 1341 | } |
@@ -1361,8 +1361,8 @@ discard block |
||
| 1361 | 1361 | return false; |
| 1362 | 1362 | } else { |
| 1363 | 1363 | $q_array = explode(" ", $q); |
| 1364 | - foreach ($q_array as $q_item){ |
|
| 1365 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1364 | + foreach ($q_array as $q_item) { |
|
| 1365 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1366 | 1366 | $additional_query .= " AND ("; |
| 1367 | 1367 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 1368 | 1368 | $additional_query .= ")"; |
@@ -1370,11 +1370,11 @@ discard block |
||
| 1370 | 1370 | } |
| 1371 | 1371 | } |
| 1372 | 1372 | if ($globalDBdriver == 'mysql') { |
| 1373 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1373 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1374 | 1374 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1375 | 1375 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1376 | 1376 | } else { |
| 1377 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1377 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1378 | 1378 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1379 | 1379 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1380 | 1380 | } |
@@ -1394,16 +1394,16 @@ discard block |
||
| 1394 | 1394 | * @return array the airline country list |
| 1395 | 1395 | */ |
| 1396 | 1396 | |
| 1397 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1397 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1398 | 1398 | { |
| 1399 | 1399 | global $globalDBdriver, $globalArchive; |
| 1400 | 1400 | //$filter_query = $this->getFilter($filters,true,true); |
| 1401 | - $Connection= new Connection($this->db); |
|
| 1401 | + $Connection = new Connection($this->db); |
|
| 1402 | 1402 | if (!$Connection->tableExists('countries')) return array(); |
| 1403 | 1403 | require_once('class.SpotterLive.php'); |
| 1404 | 1404 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1405 | 1405 | $MarineLive = new MarineLive($this->db); |
| 1406 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 1406 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 1407 | 1407 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 1408 | 1408 | if ($olderthanmonths > 0) { |
| 1409 | 1409 | if ($globalDBdriver == 'mysql') { |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | } else { |
| 1424 | 1424 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 1425 | 1425 | $MarineArchive = new MarineArchive($this->db); |
| 1426 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 1426 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 1427 | 1427 | $filter_query .= " over_country <> ''"; |
| 1428 | 1428 | if ($olderthanmonths > 0) { |
| 1429 | 1429 | if ($globalDBdriver == 'mysql') { |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | $flight_array = array(); |
| 1452 | 1452 | $temp_array = array(); |
| 1453 | 1453 | |
| 1454 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1454 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1455 | 1455 | { |
| 1456 | 1456 | $temp_array['marine_count'] = $row['nb']; |
| 1457 | 1457 | $temp_array['marine_country'] = $row['name']; |
@@ -1475,11 +1475,11 @@ discard block |
||
| 1475 | 1475 | * @param string $day |
| 1476 | 1476 | * @return array the callsign list |
| 1477 | 1477 | */ |
| 1478 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 1478 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1479 | 1479 | { |
| 1480 | 1480 | global $globalDBdriver; |
| 1481 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1482 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1481 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1482 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1483 | 1483 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1484 | 1484 | if ($olderthanmonths > 0) { |
| 1485 | 1485 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1493,28 +1493,28 @@ discard block |
||
| 1493 | 1493 | if ($year != '') { |
| 1494 | 1494 | if ($globalDBdriver == 'mysql') { |
| 1495 | 1495 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1496 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1496 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1497 | 1497 | } else { |
| 1498 | 1498 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1499 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1499 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1500 | 1500 | } |
| 1501 | 1501 | } |
| 1502 | 1502 | if ($month != '') { |
| 1503 | 1503 | if ($globalDBdriver == 'mysql') { |
| 1504 | 1504 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1505 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1505 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1506 | 1506 | } else { |
| 1507 | 1507 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1508 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1508 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | } |
| 1511 | 1511 | if ($day != '') { |
| 1512 | 1512 | if ($globalDBdriver == 'mysql') { |
| 1513 | 1513 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1514 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1514 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1515 | 1515 | } else { |
| 1516 | 1516 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1517 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1517 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | } |
| 1520 | 1520 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | $callsign_array = array(); |
| 1527 | 1527 | $temp_array = array(); |
| 1528 | 1528 | |
| 1529 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1529 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1530 | 1530 | { |
| 1531 | 1531 | $temp_array['callsign_icao'] = $row['ident']; |
| 1532 | 1532 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | $date_array = array(); |
| 1579 | 1579 | $temp_array = array(); |
| 1580 | 1580 | |
| 1581 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1581 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1582 | 1582 | { |
| 1583 | 1583 | $temp_array['date_name'] = $row['date_name']; |
| 1584 | 1584 | $temp_array['date_count'] = $row['date_count']; |
@@ -1604,7 +1604,7 @@ discard block |
||
| 1604 | 1604 | $datetime = new DateTime(); |
| 1605 | 1605 | $offset = $datetime->format('P'); |
| 1606 | 1606 | } else $offset = '+00:00'; |
| 1607 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1607 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1608 | 1608 | if ($globalDBdriver == 'mysql') { |
| 1609 | 1609 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1610 | 1610 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | $date_array = array(); |
| 1626 | 1626 | $temp_array = array(); |
| 1627 | 1627 | |
| 1628 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1628 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1629 | 1629 | { |
| 1630 | 1630 | $temp_array['date_name'] = $row['date_name']; |
| 1631 | 1631 | $temp_array['date_count'] = $row['date_count']; |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | $datetime = new DateTime(); |
| 1651 | 1651 | $offset = $datetime->format('P'); |
| 1652 | 1652 | } else $offset = '+00:00'; |
| 1653 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1653 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1654 | 1654 | if ($globalDBdriver == 'mysql') { |
| 1655 | 1655 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1656 | 1656 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1671,7 +1671,7 @@ discard block |
||
| 1671 | 1671 | $date_array = array(); |
| 1672 | 1672 | $temp_array = array(); |
| 1673 | 1673 | |
| 1674 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1674 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1675 | 1675 | { |
| 1676 | 1676 | $temp_array['date_name'] = $row['date_name']; |
| 1677 | 1677 | $temp_array['date_count'] = $row['date_count']; |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | $date_array = array(); |
| 1718 | 1718 | $temp_array = array(); |
| 1719 | 1719 | |
| 1720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1721 | 1721 | { |
| 1722 | 1722 | $temp_array['month_name'] = $row['month_name']; |
| 1723 | 1723 | $temp_array['year_name'] = $row['year_name']; |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | $datetime = new DateTime(); |
| 1745 | 1745 | $offset = $datetime->format('P'); |
| 1746 | 1746 | } else $offset = '+00:00'; |
| 1747 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1747 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1748 | 1748 | if ($globalDBdriver == 'mysql') { |
| 1749 | 1749 | $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 |
| 1750 | 1750 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1765,7 +1765,7 @@ discard block |
||
| 1765 | 1765 | $date_array = array(); |
| 1766 | 1766 | $temp_array = array(); |
| 1767 | 1767 | |
| 1768 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1768 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1769 | 1769 | { |
| 1770 | 1770 | $temp_array['year_name'] = $row['year_name']; |
| 1771 | 1771 | $temp_array['month_name'] = $row['month_name']; |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | * @param array $filters |
| 1786 | 1786 | * @return array the hour list |
| 1787 | 1787 | */ |
| 1788 | - public function countAllHours($orderby,$filters = array()) |
|
| 1788 | + public function countAllHours($orderby, $filters = array()) |
|
| 1789 | 1789 | { |
| 1790 | 1790 | global $globalTimezone, $globalDBdriver; |
| 1791 | 1791 | if ($globalTimezone != '') { |
@@ -1833,7 +1833,7 @@ discard block |
||
| 1833 | 1833 | $hour_array = array(); |
| 1834 | 1834 | $temp_array = array(); |
| 1835 | 1835 | |
| 1836 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1836 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1837 | 1837 | { |
| 1838 | 1838 | $temp_array['hour_name'] = $row['hour_name']; |
| 1839 | 1839 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1855,8 +1855,8 @@ discard block |
||
| 1855 | 1855 | public function countAllHoursByDate($date, $filters = array()) |
| 1856 | 1856 | { |
| 1857 | 1857 | global $globalTimezone, $globalDBdriver; |
| 1858 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1859 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1858 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1859 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1860 | 1860 | if ($globalTimezone != '') { |
| 1861 | 1861 | date_default_timezone_set($globalTimezone); |
| 1862 | 1862 | $datetime = new DateTime($date); |
@@ -1864,12 +1864,12 @@ discard block |
||
| 1864 | 1864 | } else $offset = '+00:00'; |
| 1865 | 1865 | |
| 1866 | 1866 | if ($globalDBdriver == 'mysql') { |
| 1867 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1867 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1868 | 1868 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1869 | 1869 | GROUP BY hour_name |
| 1870 | 1870 | ORDER BY hour_name ASC"; |
| 1871 | 1871 | } else { |
| 1872 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1872 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1873 | 1873 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1874 | 1874 | GROUP BY hour_name |
| 1875 | 1875 | ORDER BY hour_name ASC"; |
@@ -1881,7 +1881,7 @@ discard block |
||
| 1881 | 1881 | $hour_array = array(); |
| 1882 | 1882 | $temp_array = array(); |
| 1883 | 1883 | |
| 1884 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1884 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1885 | 1885 | { |
| 1886 | 1886 | $temp_array['hour_name'] = $row['hour_name']; |
| 1887 | 1887 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1903,8 +1903,8 @@ discard block |
||
| 1903 | 1903 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1904 | 1904 | { |
| 1905 | 1905 | global $globalTimezone, $globalDBdriver; |
| 1906 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1907 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1906 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1907 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1908 | 1908 | if ($globalTimezone != '') { |
| 1909 | 1909 | date_default_timezone_set($globalTimezone); |
| 1910 | 1910 | $datetime = new DateTime(); |
@@ -1912,12 +1912,12 @@ discard block |
||
| 1912 | 1912 | } else $offset = '+00:00'; |
| 1913 | 1913 | |
| 1914 | 1914 | if ($globalDBdriver == 'mysql') { |
| 1915 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1915 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1916 | 1916 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1917 | 1917 | GROUP BY hour_name |
| 1918 | 1918 | ORDER BY hour_name ASC"; |
| 1919 | 1919 | } else { |
| 1920 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1920 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1921 | 1921 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1922 | 1922 | GROUP BY hour_name |
| 1923 | 1923 | ORDER BY hour_name ASC"; |
@@ -1925,12 +1925,12 @@ discard block |
||
| 1925 | 1925 | |
| 1926 | 1926 | |
| 1927 | 1927 | $sth = $this->db->prepare($query); |
| 1928 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1928 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1929 | 1929 | |
| 1930 | 1930 | $hour_array = array(); |
| 1931 | 1931 | $temp_array = array(); |
| 1932 | 1932 | |
| 1933 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1933 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1934 | 1934 | { |
| 1935 | 1935 | $temp_array['hour_name'] = $row['hour_name']; |
| 1936 | 1936 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1950,11 +1950,11 @@ discard block |
||
| 1950 | 1950 | * @param array $filters |
| 1951 | 1951 | * @return array the aircraft list |
| 1952 | 1952 | */ |
| 1953 | - public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1953 | + public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1954 | 1954 | { |
| 1955 | 1955 | global $globalDBdriver; |
| 1956 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1957 | - $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
| 1956 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1957 | + $query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count |
|
| 1958 | 1958 | FROM marine_output".$filter_query." race_id IS NOT NULL"; |
| 1959 | 1959 | if ($olderthanmonths > 0) { |
| 1960 | 1960 | if ($globalDBdriver == 'mysql') { |
@@ -1977,7 +1977,7 @@ discard block |
||
| 1977 | 1977 | $marine_array = array(); |
| 1978 | 1978 | $temp_array = array(); |
| 1979 | 1979 | |
| 1980 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1980 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1981 | 1981 | { |
| 1982 | 1982 | $temp_array['marine_race_id'] = $row['race_id']; |
| 1983 | 1983 | $temp_array['marine_race_name'] = $row['race_name']; |
@@ -1995,33 +1995,33 @@ discard block |
||
| 1995 | 1995 | * @param string $month |
| 1996 | 1996 | * @return Integer the number of vessels |
| 1997 | 1997 | */ |
| 1998 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1998 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1999 | 1999 | { |
| 2000 | 2000 | global $globalDBdriver; |
| 2001 | 2001 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 2002 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 2002 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 2003 | 2003 | $query_values = array(); |
| 2004 | 2004 | $query = ''; |
| 2005 | 2005 | if ($year != '') { |
| 2006 | 2006 | if ($globalDBdriver == 'mysql') { |
| 2007 | 2007 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2008 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2008 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2009 | 2009 | } else { |
| 2010 | 2010 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2011 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2011 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | } |
| 2014 | 2014 | if ($month != '') { |
| 2015 | 2015 | if ($globalDBdriver == 'mysql') { |
| 2016 | 2016 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2017 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2017 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2018 | 2018 | } else { |
| 2019 | 2019 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2020 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2020 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2021 | 2021 | } |
| 2022 | 2022 | } |
| 2023 | 2023 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2024 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2024 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2025 | 2025 | |
| 2026 | 2026 | $sth = $this->db->prepare($queryi); |
| 2027 | 2027 | $sth->execute($query_values); |
@@ -2036,32 +2036,32 @@ discard block |
||
| 2036 | 2036 | * @param string $month |
| 2037 | 2037 | * @return Integer the number of vessels |
| 2038 | 2038 | */ |
| 2039 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 2039 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 2040 | 2040 | { |
| 2041 | 2041 | global $globalDBdriver; |
| 2042 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 2042 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 2043 | 2043 | $query_values = array(); |
| 2044 | 2044 | $query = ''; |
| 2045 | 2045 | if ($year != '') { |
| 2046 | 2046 | if ($globalDBdriver == 'mysql') { |
| 2047 | 2047 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2048 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2048 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2049 | 2049 | } else { |
| 2050 | 2050 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2051 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2051 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2052 | 2052 | } |
| 2053 | 2053 | } |
| 2054 | 2054 | if ($month != '') { |
| 2055 | 2055 | if ($globalDBdriver == 'mysql') { |
| 2056 | 2056 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2057 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2057 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2058 | 2058 | } else { |
| 2059 | 2059 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2060 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2060 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2061 | 2061 | } |
| 2062 | 2062 | } |
| 2063 | 2063 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2064 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2064 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2065 | 2065 | |
| 2066 | 2066 | $sth = $this->db->prepare($queryi); |
| 2067 | 2067 | $sth->execute($query_values); |
@@ -2076,32 +2076,32 @@ discard block |
||
| 2076 | 2076 | * @param string $month |
| 2077 | 2077 | * @return Integer number of races |
| 2078 | 2078 | */ |
| 2079 | - public function countOverallMarineRaces($filters = array(),$year = '',$month = '') |
|
| 2079 | + public function countOverallMarineRaces($filters = array(), $year = '', $month = '') |
|
| 2080 | 2080 | { |
| 2081 | 2081 | global $globalDBdriver; |
| 2082 | - $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
| 2082 | + $queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output"; |
|
| 2083 | 2083 | $query_values = array(); |
| 2084 | 2084 | $query = ''; |
| 2085 | 2085 | if ($year != '') { |
| 2086 | 2086 | if ($globalDBdriver == 'mysql') { |
| 2087 | 2087 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2088 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2088 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2089 | 2089 | } else { |
| 2090 | 2090 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2091 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2091 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2092 | 2092 | } |
| 2093 | 2093 | } |
| 2094 | 2094 | if ($month != '') { |
| 2095 | 2095 | if ($globalDBdriver == 'mysql') { |
| 2096 | 2096 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2097 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2097 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2098 | 2098 | } else { |
| 2099 | 2099 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2100 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2100 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2101 | 2101 | } |
| 2102 | 2102 | } |
| 2103 | 2103 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2104 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2104 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2105 | 2105 | |
| 2106 | 2106 | $sth = $this->db->prepare($queryi); |
| 2107 | 2107 | $sth->execute($query_values); |
@@ -2116,32 +2116,32 @@ discard block |
||
| 2116 | 2116 | * @param string $month |
| 2117 | 2117 | * @return Integer number of captain |
| 2118 | 2118 | */ |
| 2119 | - public function countOverallMarineCaptains($filters = array(),$year = '',$month = '') |
|
| 2119 | + public function countOverallMarineCaptains($filters = array(), $year = '', $month = '') |
|
| 2120 | 2120 | { |
| 2121 | 2121 | global $globalDBdriver; |
| 2122 | - $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
| 2122 | + $queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output"; |
|
| 2123 | 2123 | $query_values = array(); |
| 2124 | 2124 | $query = ''; |
| 2125 | 2125 | if ($year != '') { |
| 2126 | 2126 | if ($globalDBdriver == 'mysql') { |
| 2127 | 2127 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2128 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2128 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2129 | 2129 | } else { |
| 2130 | 2130 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2131 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2131 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2132 | 2132 | } |
| 2133 | 2133 | } |
| 2134 | 2134 | if ($month != '') { |
| 2135 | 2135 | if ($globalDBdriver == 'mysql') { |
| 2136 | 2136 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2137 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2137 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2138 | 2138 | } else { |
| 2139 | 2139 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2140 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2140 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | } |
| 2143 | 2143 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 2144 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 2144 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 2145 | 2145 | |
| 2146 | 2146 | $sth = $this->db->prepare($queryi); |
| 2147 | 2147 | $sth->execute($query_values); |
@@ -2157,7 +2157,7 @@ discard block |
||
| 2157 | 2157 | public function countAllHoursFromToday($filters = array()) |
| 2158 | 2158 | { |
| 2159 | 2159 | global $globalTimezone, $globalDBdriver; |
| 2160 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2160 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2161 | 2161 | if ($globalTimezone != '') { |
| 2162 | 2162 | date_default_timezone_set($globalTimezone); |
| 2163 | 2163 | $datetime = new DateTime(); |
@@ -2165,12 +2165,12 @@ discard block |
||
| 2165 | 2165 | } else $offset = '+00:00'; |
| 2166 | 2166 | |
| 2167 | 2167 | if ($globalDBdriver == 'mysql') { |
| 2168 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 2168 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 2169 | 2169 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 2170 | 2170 | GROUP BY hour_name |
| 2171 | 2171 | ORDER BY hour_name ASC"; |
| 2172 | 2172 | } else { |
| 2173 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 2173 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 2174 | 2174 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 2175 | 2175 | GROUP BY hour_name |
| 2176 | 2176 | ORDER BY hour_name ASC"; |
@@ -2182,7 +2182,7 @@ discard block |
||
| 2182 | 2182 | $hour_array = array(); |
| 2183 | 2183 | $temp_array = array(); |
| 2184 | 2184 | |
| 2185 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2185 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2186 | 2186 | { |
| 2187 | 2187 | $temp_array['hour_name'] = $row['hour_name']; |
| 2188 | 2188 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -2201,9 +2201,9 @@ discard block |
||
| 2201 | 2201 | */ |
| 2202 | 2202 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 2203 | 2203 | { |
| 2204 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 2204 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 2205 | 2205 | |
| 2206 | - $query = "SELECT marine_output.marine_id |
|
| 2206 | + $query = "SELECT marine_output.marine_id |
|
| 2207 | 2207 | FROM marine_output |
| 2208 | 2208 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 2209 | 2209 | |
@@ -2211,7 +2211,7 @@ discard block |
||
| 2211 | 2211 | $sth = $this->db->prepare($query); |
| 2212 | 2212 | $sth->execute(); |
| 2213 | 2213 | |
| 2214 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2214 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2215 | 2215 | { |
| 2216 | 2216 | return $row['marine_id']; |
| 2217 | 2217 | } |
@@ -2236,23 +2236,23 @@ discard block |
||
| 2236 | 2236 | } |
| 2237 | 2237 | |
| 2238 | 2238 | $current_date = date("Y-m-d H:i:s"); |
| 2239 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 2239 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 2240 | 2240 | |
| 2241 | 2241 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 2242 | 2242 | |
| 2243 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 2243 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 2244 | 2244 | $years = $time_array['years']; |
| 2245 | 2245 | |
| 2246 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 2246 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 2247 | 2247 | $months = $time_array['months']; |
| 2248 | 2248 | |
| 2249 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 2249 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 2250 | 2250 | $days = $time_array['days']; |
| 2251 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 2251 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 2252 | 2252 | $hours = $time_array['hours']; |
| 2253 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 2253 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 2254 | 2254 | $minutes = $time_array['minutes']; |
| 2255 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2255 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 2256 | 2256 | |
| 2257 | 2257 | return $time_array; |
| 2258 | 2258 | } |
@@ -2275,63 +2275,63 @@ discard block |
||
| 2275 | 2275 | $temp_array['direction_degree'] = $direction; |
| 2276 | 2276 | $temp_array['direction_shortname'] = "N"; |
| 2277 | 2277 | $temp_array['direction_fullname'] = "North"; |
| 2278 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 2278 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 2279 | 2279 | $temp_array['direction_degree'] = $direction; |
| 2280 | 2280 | $temp_array['direction_shortname'] = "NNE"; |
| 2281 | 2281 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 2282 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 2282 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 2283 | 2283 | $temp_array['direction_degree'] = $direction; |
| 2284 | 2284 | $temp_array['direction_shortname'] = "NE"; |
| 2285 | 2285 | $temp_array['direction_fullname'] = "Northeast"; |
| 2286 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 2286 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 2287 | 2287 | $temp_array['direction_degree'] = $direction; |
| 2288 | 2288 | $temp_array['direction_shortname'] = "ENE"; |
| 2289 | 2289 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 2290 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 2290 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 2291 | 2291 | $temp_array['direction_degree'] = $direction; |
| 2292 | 2292 | $temp_array['direction_shortname'] = "E"; |
| 2293 | 2293 | $temp_array['direction_fullname'] = "East"; |
| 2294 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 2294 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 2295 | 2295 | $temp_array['direction_degree'] = $direction; |
| 2296 | 2296 | $temp_array['direction_shortname'] = "ESE"; |
| 2297 | 2297 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 2298 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 2298 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 2299 | 2299 | $temp_array['direction_degree'] = $direction; |
| 2300 | 2300 | $temp_array['direction_shortname'] = "SE"; |
| 2301 | 2301 | $temp_array['direction_fullname'] = "Southeast"; |
| 2302 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 2302 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 2303 | 2303 | $temp_array['direction_degree'] = $direction; |
| 2304 | 2304 | $temp_array['direction_shortname'] = "SSE"; |
| 2305 | 2305 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 2306 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 2306 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 2307 | 2307 | $temp_array['direction_degree'] = $direction; |
| 2308 | 2308 | $temp_array['direction_shortname'] = "S"; |
| 2309 | 2309 | $temp_array['direction_fullname'] = "South"; |
| 2310 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 2310 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 2311 | 2311 | $temp_array['direction_degree'] = $direction; |
| 2312 | 2312 | $temp_array['direction_shortname'] = "SSW"; |
| 2313 | 2313 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 2314 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 2314 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 2315 | 2315 | $temp_array['direction_degree'] = $direction; |
| 2316 | 2316 | $temp_array['direction_shortname'] = "SW"; |
| 2317 | 2317 | $temp_array['direction_fullname'] = "Southwest"; |
| 2318 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 2318 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 2319 | 2319 | $temp_array['direction_degree'] = $direction; |
| 2320 | 2320 | $temp_array['direction_shortname'] = "WSW"; |
| 2321 | 2321 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 2322 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 2322 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 2323 | 2323 | $temp_array['direction_degree'] = $direction; |
| 2324 | 2324 | $temp_array['direction_shortname'] = "W"; |
| 2325 | 2325 | $temp_array['direction_fullname'] = "West"; |
| 2326 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 2326 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 2327 | 2327 | $temp_array['direction_degree'] = $direction; |
| 2328 | 2328 | $temp_array['direction_shortname'] = "WNW"; |
| 2329 | 2329 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 2330 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 2330 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 2331 | 2331 | $temp_array['direction_degree'] = $direction; |
| 2332 | 2332 | $temp_array['direction_shortname'] = "NW"; |
| 2333 | 2333 | $temp_array['direction_fullname'] = "Northwest"; |
| 2334 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 2334 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 2335 | 2335 | $temp_array['direction_degree'] = $direction; |
| 2336 | 2336 | $temp_array['direction_shortname'] = "NNW"; |
| 2337 | 2337 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2348,11 +2348,11 @@ discard block |
||
| 2348 | 2348 | * @param Float $longitude longitute of the flight |
| 2349 | 2349 | * @return String the countries |
| 2350 | 2350 | */ |
| 2351 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 2351 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 2352 | 2352 | { |
| 2353 | 2353 | global $globalDebug; |
| 2354 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2355 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2354 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2355 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2356 | 2356 | |
| 2357 | 2357 | $Connection = new Connection($this->db); |
| 2358 | 2358 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2392,7 +2392,7 @@ discard block |
||
| 2392 | 2392 | public function getCountryFromISO2($iso2) |
| 2393 | 2393 | { |
| 2394 | 2394 | global $globalDebug; |
| 2395 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 2395 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 2396 | 2396 | |
| 2397 | 2397 | $Connection = new Connection($this->db); |
| 2398 | 2398 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | |
| 2441 | 2441 | $bitly_data = json_decode($bitly_data); |
| 2442 | 2442 | $bitly_url = ''; |
| 2443 | - if ($bitly_data->status_txt = "OK"){ |
|
| 2443 | + if ($bitly_data->status_txt = "OK") { |
|
| 2444 | 2444 | $bitly_url = $bitly_data->data->url; |
| 2445 | 2445 | } |
| 2446 | 2446 | |
@@ -2460,11 +2460,11 @@ discard block |
||
| 2460 | 2460 | * @param string $day |
| 2461 | 2461 | * @return array the vessel type list |
| 2462 | 2462 | */ |
| 2463 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 2463 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 2464 | 2464 | { |
| 2465 | 2465 | global $globalDBdriver; |
| 2466 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2467 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2466 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2467 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2468 | 2468 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
| 2469 | 2469 | if ($olderthanmonths > 0) { |
| 2470 | 2470 | if ($globalDBdriver == 'mysql') { |
@@ -2484,28 +2484,28 @@ discard block |
||
| 2484 | 2484 | if ($year != '') { |
| 2485 | 2485 | if ($globalDBdriver == 'mysql') { |
| 2486 | 2486 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2487 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2487 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2488 | 2488 | } else { |
| 2489 | 2489 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2490 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2490 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | } |
| 2493 | 2493 | if ($month != '') { |
| 2494 | 2494 | if ($globalDBdriver == 'mysql') { |
| 2495 | 2495 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2496 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2496 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2497 | 2497 | } else { |
| 2498 | 2498 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2499 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2499 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2500 | 2500 | } |
| 2501 | 2501 | } |
| 2502 | 2502 | if ($day != '') { |
| 2503 | 2503 | if ($globalDBdriver == 'mysql') { |
| 2504 | 2504 | $query .= " AND DAY(marine_output.date) = :day"; |
| 2505 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2505 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2506 | 2506 | } else { |
| 2507 | 2507 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 2508 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2508 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2509 | 2509 | } |
| 2510 | 2510 | } |
| 2511 | 2511 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2514,9 +2514,9 @@ discard block |
||
| 2514 | 2514 | $sth->execute($query_values); |
| 2515 | 2515 | $marine_array = array(); |
| 2516 | 2516 | $temp_array = array(); |
| 2517 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2517 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2518 | 2518 | { |
| 2519 | - $temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES); |
|
| 2519 | + $temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES); |
|
| 2520 | 2520 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
| 2521 | 2521 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
| 2522 | 2522 | $marine_array[] = $temp_array; |
@@ -2545,13 +2545,13 @@ discard block |
||
| 2545 | 2545 | * @param array $filters |
| 2546 | 2546 | * @return array the tracker information |
| 2547 | 2547 | */ |
| 2548 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array()) |
|
| 2548 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $filters = array()) |
|
| 2549 | 2549 | { |
| 2550 | 2550 | global $globalTimezone, $globalDBdriver; |
| 2551 | 2551 | date_default_timezone_set('UTC'); |
| 2552 | 2552 | $query_values = array(); |
| 2553 | 2553 | $additional_query = ''; |
| 2554 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2554 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2555 | 2555 | if ($q != "") |
| 2556 | 2556 | { |
| 2557 | 2557 | if (!is_string($q)) |
@@ -2559,8 +2559,8 @@ discard block |
||
| 2559 | 2559 | return array(); |
| 2560 | 2560 | } else { |
| 2561 | 2561 | $q_array = explode(" ", $q); |
| 2562 | - foreach ($q_array as $q_item){ |
|
| 2563 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 2562 | + foreach ($q_array as $q_item) { |
|
| 2563 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 2564 | 2564 | $additional_query .= " AND ("; |
| 2565 | 2565 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 2566 | 2566 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2576,86 +2576,86 @@ discard block |
||
| 2576 | 2576 | } |
| 2577 | 2577 | if ($callsign != "") |
| 2578 | 2578 | { |
| 2579 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2579 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2580 | 2580 | if (!is_string($callsign)) |
| 2581 | 2581 | { |
| 2582 | 2582 | return array(); |
| 2583 | 2583 | } else { |
| 2584 | 2584 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 2585 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 2585 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 2586 | 2586 | } |
| 2587 | 2587 | } |
| 2588 | 2588 | if ($mmsi != "") |
| 2589 | 2589 | { |
| 2590 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 2590 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 2591 | 2591 | if (!is_numeric($mmsi)) |
| 2592 | 2592 | { |
| 2593 | 2593 | return array(); |
| 2594 | 2594 | } else { |
| 2595 | 2595 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 2596 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 2596 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 2597 | 2597 | } |
| 2598 | 2598 | } |
| 2599 | 2599 | if ($imo != "") |
| 2600 | 2600 | { |
| 2601 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 2601 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 2602 | 2602 | if (!is_numeric($imo)) |
| 2603 | 2603 | { |
| 2604 | 2604 | return array(); |
| 2605 | 2605 | } else { |
| 2606 | 2606 | $additional_query .= " AND marine_output.imo = :imo"; |
| 2607 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 2607 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 2608 | 2608 | } |
| 2609 | 2609 | } |
| 2610 | 2610 | if ($captain_id != "") |
| 2611 | 2611 | { |
| 2612 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 2612 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 2613 | 2613 | if (!is_numeric($captain_id)) |
| 2614 | 2614 | { |
| 2615 | 2615 | return array(); |
| 2616 | 2616 | } else { |
| 2617 | 2617 | $additional_query .= " AND marine_output.captain_id = :captain_id"; |
| 2618 | - $query_values = array_merge($query_values,array(':captain_id' => $captain_id)); |
|
| 2618 | + $query_values = array_merge($query_values, array(':captain_id' => $captain_id)); |
|
| 2619 | 2619 | } |
| 2620 | 2620 | } |
| 2621 | 2621 | if ($race_id != "") |
| 2622 | 2622 | { |
| 2623 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 2623 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 2624 | 2624 | if (!is_numeric($race_id)) |
| 2625 | 2625 | { |
| 2626 | 2626 | return array(); |
| 2627 | 2627 | } else { |
| 2628 | 2628 | $additional_query .= " AND marine_output.race_id = :race_id"; |
| 2629 | - $query_values = array_merge($query_values,array(':race_id' => $race_id)); |
|
| 2629 | + $query_values = array_merge($query_values, array(':race_id' => $race_id)); |
|
| 2630 | 2630 | } |
| 2631 | 2631 | } |
| 2632 | 2632 | if ($captain_name != "") |
| 2633 | 2633 | { |
| 2634 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 2634 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 2635 | 2635 | if (!is_string($captain_name)) |
| 2636 | 2636 | { |
| 2637 | 2637 | return array(); |
| 2638 | 2638 | } else { |
| 2639 | 2639 | $additional_query .= " AND marine_output.captain_name = :captain_name"; |
| 2640 | - $query_values = array_merge($query_values,array(':captain_name' => $captain_name)); |
|
| 2640 | + $query_values = array_merge($query_values, array(':captain_name' => $captain_name)); |
|
| 2641 | 2641 | } |
| 2642 | 2642 | } |
| 2643 | 2643 | if ($race_name != "") |
| 2644 | 2644 | { |
| 2645 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2645 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2646 | 2646 | if (!is_numeric($race_name)) |
| 2647 | 2647 | { |
| 2648 | 2648 | return array(); |
| 2649 | 2649 | } else { |
| 2650 | 2650 | $additional_query .= " AND marine_output.race_name = :race_name"; |
| 2651 | - $query_values = array_merge($query_values,array(':race_name' => $race_name)); |
|
| 2651 | + $query_values = array_merge($query_values, array(':race_name' => $race_name)); |
|
| 2652 | 2652 | } |
| 2653 | 2653 | } |
| 2654 | 2654 | if ($date_posted != "") |
| 2655 | 2655 | { |
| 2656 | 2656 | $date_array = explode(",", $date_posted); |
| 2657 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 2658 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 2657 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 2658 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 2659 | 2659 | if ($globalTimezone != '') { |
| 2660 | 2660 | date_default_timezone_set($globalTimezone); |
| 2661 | 2661 | $datetime = new DateTime(); |
@@ -2682,8 +2682,8 @@ discard block |
||
| 2682 | 2682 | if ($limit != "") |
| 2683 | 2683 | { |
| 2684 | 2684 | $limit_array = explode(",", $limit); |
| 2685 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 2686 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 2685 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 2686 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 2687 | 2687 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2688 | 2688 | { |
| 2689 | 2689 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2701,22 +2701,22 @@ discard block |
||
| 2701 | 2701 | } |
| 2702 | 2702 | } |
| 2703 | 2703 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 2704 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 2704 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 2705 | 2705 | if ($globalDBdriver == 'mysql') { |
| 2706 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2706 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2707 | 2707 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2708 | 2708 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 2709 | 2709 | } else { |
| 2710 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 |
|
| 2710 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 |
|
| 2711 | 2711 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2712 | 2712 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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.$orderby_query; |
| 2713 | 2713 | } |
| 2714 | 2714 | } else { |
| 2715 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2715 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2716 | 2716 | ".$additional_query." |
| 2717 | 2717 | ".$orderby_query; |
| 2718 | 2718 | } |
| 2719 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 2719 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 2720 | 2720 | return $marine_array; |
| 2721 | 2721 | } |
| 2722 | 2722 | |
@@ -2728,12 +2728,12 @@ discard block |
||
| 2728 | 2728 | */ |
| 2729 | 2729 | public function checkId($id) |
| 2730 | 2730 | { |
| 2731 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2731 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2732 | 2732 | $query_data = array(':id' => $id); |
| 2733 | 2733 | $sth = $this->db->prepare($query); |
| 2734 | 2734 | $sth->execute($query_data); |
| 2735 | - $ident_result=''; |
|
| 2736 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2735 | + $ident_result = ''; |
|
| 2736 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2737 | 2737 | { |
| 2738 | 2738 | $ident_result = $row['fammarine_id']; |
| 2739 | 2739 | } |
@@ -2748,7 +2748,7 @@ discard block |
||
| 2748 | 2748 | */ |
| 2749 | 2749 | public function getRaceByName($race_name) |
| 2750 | 2750 | { |
| 2751 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2751 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2752 | 2752 | $query = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1"; |
| 2753 | 2753 | $sth = $this->db->prepare($query); |
| 2754 | 2754 | $sth->execute(array(':race_name' => $race_name)); |
@@ -2765,7 +2765,7 @@ discard block |
||
| 2765 | 2765 | */ |
| 2766 | 2766 | public function getRace($race_id) |
| 2767 | 2767 | { |
| 2768 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2768 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2769 | 2769 | $query = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1"; |
| 2770 | 2770 | $sth = $this->db->prepare($query); |
| 2771 | 2771 | $sth->execute(array(':race_id' => $race_id)); |
@@ -2783,24 +2783,24 @@ discard block |
||
| 2783 | 2783 | * @param $race_startdate |
| 2784 | 2784 | * @param $race_markers |
| 2785 | 2785 | */ |
| 2786 | - public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers) |
|
| 2786 | + public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers) |
|
| 2787 | 2787 | { |
| 2788 | - $race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 2788 | + $race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 2789 | 2789 | if ($race_id != '') { |
| 2790 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 2791 | - $race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING); |
|
| 2792 | - $race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING); |
|
| 2793 | - $race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING); |
|
| 2790 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 2791 | + $race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING); |
|
| 2792 | + $race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING); |
|
| 2793 | + $race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING); |
|
| 2794 | 2794 | //$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING); |
| 2795 | 2795 | $allrace = $this->getRace($race_id); |
| 2796 | 2796 | if (empty($allrace)) { |
| 2797 | 2797 | $query = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)"; |
| 2798 | 2798 | $sth = $this->db->prepare($query); |
| 2799 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
| 2799 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
| 2800 | 2800 | } elseif ($race_id != '') { |
| 2801 | - $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
| 2801 | + $query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id"; |
|
| 2802 | 2802 | $sth = $this->db->prepare($query); |
| 2803 | - $sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers)); |
|
| 2803 | + $sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers)); |
|
| 2804 | 2804 | } |
| 2805 | 2805 | } |
| 2806 | 2806 | } |
@@ -2809,7 +2809,7 @@ discard block |
||
| 2809 | 2809 | |
| 2810 | 2810 | public function getOrderBy() |
| 2811 | 2811 | { |
| 2812 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
| 2812 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
| 2813 | 2813 | return $orderby; |
| 2814 | 2814 | } |
| 2815 | 2815 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * @param String $source source of data |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
| 40 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
| 41 | 41 | date_default_timezone_set('UTC'); |
| 42 | - $date = date("Y-m-d H:i:s",time()); |
|
| 42 | + $date = date("Y-m-d H:i:s", time()); |
|
| 43 | 43 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
| 44 | 44 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
| 45 | 45 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -47,69 +47,69 @@ discard block |
||
| 47 | 47 | try { |
| 48 | 48 | $sth = $this->db->prepare($query); |
| 49 | 49 | $sth->execute($query_values); |
| 50 | - } catch(PDOException $e) { |
|
| 50 | + } catch (PDOException $e) { |
|
| 51 | 51 | return "error : ".$e->getMessage(); |
| 52 | 52 | } |
| 53 | 53 | if ($sth->fetchColumn() > 0) { |
| 54 | 54 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 55 | 55 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
| 56 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 56 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 57 | 57 | } elseif ($arrival_airport_time == '') { |
| 58 | 58 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
| 59 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 59 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 60 | 60 | } elseif ($departure_airport_time == '') { |
| 61 | 61 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 62 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 62 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 63 | 63 | } else { |
| 64 | 64 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
| 65 | 65 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 66 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 67 | 67 | } |
| 68 | 68 | try { |
| 69 | 69 | $sth = $this->db->prepare($query); |
| 70 | 70 | $sth->execute($query_values); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error : ".$e->getMessage(); |
| 73 | 73 | } |
| 74 | 74 | if ($sth->fetchColumn() == 0) { |
| 75 | 75 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 76 | 76 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 77 | 77 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 78 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 78 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 79 | 79 | } elseif ($arrival_airport_time == '') { |
| 80 | 80 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 81 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 81 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 82 | 82 | } elseif ($departure_airport_time == '') { |
| 83 | 83 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 84 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 84 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 85 | 85 | } else { |
| 86 | 86 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 87 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 87 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 88 | 88 | } |
| 89 | 89 | try { |
| 90 | 90 | $sth = $this->db->prepare($query); |
| 91 | 91 | $sth->execute($query_values); |
| 92 | - } catch(PDOException $e) { |
|
| 92 | + } catch (PDOException $e) { |
|
| 93 | 93 | return "error : ".$e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | } else { |
| 96 | 96 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
| 97 | 97 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
| 98 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
| 98 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
| 99 | 99 | try { |
| 100 | 100 | $sth = $this->db->prepare($query); |
| 101 | 101 | $sth->execute($query_values); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error : ".$e->getMessage(); |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } else { |
| 107 | 107 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
| 108 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 108 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 109 | 109 | try { |
| 110 | 110 | $sth = $this->db->prepare($query); |
| 111 | 111 | $sth->execute($query_values); |
| 112 | - } catch(PDOException $e) { |
|
| 112 | + } catch (PDOException $e) { |
|
| 113 | 113 | return "error : ".$e->getMessage(); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function getSchedule($ident) { |
| 125 | 125 | $Translation = new Translation($this->db); |
| 126 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 126 | + $operator = $Translation->checkTranslation($ident, false); |
|
| 127 | 127 | if ($ident != $operator) { |
| 128 | 128 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
| 129 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 129 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
| 130 | 130 | } else { |
| 131 | 131 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
| 132 | 132 | $query_values = array(':ident' => $ident); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | try { |
| 135 | 135 | $sth = $this->db->prepare($query); |
| 136 | 136 | $sth->execute($query_values); |
| 137 | - } catch(PDOException $e) { |
|
| 137 | + } catch (PDOException $e) { |
|
| 138 | 138 | return "error : ".$e->getMessage(); |
| 139 | 139 | } |
| 140 | 140 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | try { |
| 164 | 164 | $sth = $this->db->prepare($query); |
| 165 | 165 | $sth->execute($query_values); |
| 166 | - } catch(PDOException $e) { |
|
| 166 | + } catch (PDOException $e) { |
|
| 167 | 167 | return "error : ".$e->getMessage(); |
| 168 | 168 | } |
| 169 | 169 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -178,16 +178,16 @@ discard block |
||
| 178 | 178 | * @param String $carrier IATA code |
| 179 | 179 | * @return array departure and arrival airports and time |
| 180 | 180 | */ |
| 181 | - public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
| 181 | + public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
| 182 | 182 | $Common = new Common(); |
| 183 | 183 | $check_date = new Datetime($date); |
| 184 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 185 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 184 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 185 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 186 | 186 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 187 | 187 | $json = $Common->getData($url); |
| 188 | 188 | var_dump($json); |
| 189 | 189 | $parsed_json = json_decode($json); |
| 190 | - if (property_exists($parsed_json,'errors') === false) { |
|
| 190 | + if (property_exists($parsed_json, 'errors') === false) { |
|
| 191 | 191 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
| 192 | 192 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
| 193 | 193 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
| 198 | 198 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
| 199 | 199 | |
| 200 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
| 200 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
| 201 | 201 | $DepartureAirportIata = $originiata[1]; |
| 202 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
| 202 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
| 203 | 203 | $ArrivalAirportIata = $destinationiata[1]; |
| 204 | 204 | |
| 205 | 205 | /* |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
| 209 | 209 | */ |
| 210 | 210 | |
| 211 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
| 211 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
| 212 | 212 | } else return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | $Common = new Common(); |
| 224 | 224 | date_default_timezone_set($globalTimezone); |
| 225 | 225 | $check_date = new Datetime($date); |
| 226 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 227 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 226 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 227 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 228 | 228 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 229 | 229 | $json = $Common->getData($url); |
| 230 | 230 | $parsed_json = json_decode($json); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
| 237 | 237 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 238 | 238 | |
| 239 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
| 239 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
| 240 | 240 | } else return array(); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | private function getRyanair($callsign) { |
| 249 | 249 | $Common = new Common(); |
| 250 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 251 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 250 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 251 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 252 | 252 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 253 | 253 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 254 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
| 255 | - $json = $Common->getData($url,'post',$post,$headers); |
|
| 254 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
| 255 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
| 256 | 256 | $parsed_json = json_decode($json); |
| 257 | 257 | if (isset($parsed_json->{'flightInfo'})) { |
| 258 | 258 | $flights = $parsed_json->{'flightInfo'}; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
| 262 | 262 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 263 | 263 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 264 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 264 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 265 | 265 | } else return array(); |
| 266 | 266 | } else return array(); |
| 267 | 267 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | private function getSwiss($callsign) { |
| 275 | 275 | $Common = new Common(); |
| 276 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 277 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 276 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 277 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 278 | 278 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 279 | 279 | $json = $Common->getData($url); |
| 280 | 280 | $parsed_json = json_decode($json); |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
| 289 | 289 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
| 290 | 290 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
| 291 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
| 292 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
| 291 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
| 292 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 296 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
| 296 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
| 297 | 297 | } else return array(); |
| 298 | 298 | } else return array(); |
| 299 | 299 | } |
@@ -308,21 +308,21 @@ discard block |
||
| 308 | 308 | global $globalBritishAirwaysKey; |
| 309 | 309 | $Common = new Common(); |
| 310 | 310 | $check_date = new Datetime($date); |
| 311 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 312 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 311 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 312 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 313 | 313 | if ($globalBritishAirwaysKey == '') return array(); |
| 314 | 314 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 315 | 315 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 316 | - $json = $Common->getData($url,'get','',$headers); |
|
| 316 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 317 | 317 | if ($json == '') return array(); |
| 318 | 318 | $parsed_json = json_decode($json); |
| 319 | 319 | $flights = $parsed_json->{'FlightsResponse'}; |
| 320 | 320 | if (count($flights) > 0) { |
| 321 | 321 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
| 322 | 322 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
| 323 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 324 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 325 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
| 323 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 324 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 325 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
| 326 | 326 | } else return array(); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -336,27 +336,27 @@ discard block |
||
| 336 | 336 | global $globalLufthansaKey; |
| 337 | 337 | $Common = new Common(); |
| 338 | 338 | $check_date = new Datetime($date); |
| 339 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 340 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 339 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 340 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 341 | 341 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
| 342 | 342 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 343 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
| 344 | - $data = $Common->getData($url,'post',$post); |
|
| 343 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
| 344 | + $data = $Common->getData($url, 'post', $post); |
|
| 345 | 345 | $parsed_data = json_decode($data); |
| 346 | 346 | if (!isset($parsed_data->{'access_token'})) return array(); |
| 347 | 347 | $token = $parsed_data->{'access_token'}; |
| 348 | 348 | |
| 349 | 349 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 350 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
| 351 | - $json = $Common->getData($url,'get','',$headers); |
|
| 350 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
| 351 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 352 | 352 | if ($json == '') return array(); |
| 353 | 353 | $parsed_json = json_decode($json); |
| 354 | 354 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 355 | 355 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
| 356 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 356 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 357 | 357 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 358 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 359 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
| 358 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 359 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
| 360 | 360 | } else return array(); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -370,23 +370,23 @@ discard block |
||
| 370 | 370 | global $globalTransaviaKey; |
| 371 | 371 | $Common = new Common(); |
| 372 | 372 | $check_date = new Datetime($date); |
| 373 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 374 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 373 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 374 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 375 | 375 | if ($globalTransaviaKey == '') return array(); |
| 376 | 376 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 377 | 377 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 378 | 378 | $headers = array('apikey: '.$globalTransaviaKey); |
| 379 | - $json = $Common->getData($url,'get','',$headers); |
|
| 379 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 380 | 380 | //echo 'result : '.$json; |
| 381 | 381 | if ($json == '') return array(); |
| 382 | 382 | $parsed_json = json_decode($json); |
| 383 | 383 | |
| 384 | 384 | if (isset($parsed_json->{'data'}[0])) { |
| 385 | 385 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
| 386 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 386 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 387 | 387 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 388 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 389 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
| 388 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 389 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
| 390 | 390 | } else return array(); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function getTunisair($callsign) { |
| 399 | 399 | $Common = new Common(); |
| 400 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 401 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 400 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 401 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 402 | 402 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 403 | 403 | $data = $Common->getData($url); |
| 404 | 404 | $table = $Common->table2array($data); |
| 405 | 405 | foreach ($table as $flight) { |
| 406 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
| 407 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
| 406 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
| 407 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | return array(); |
@@ -416,21 +416,21 @@ discard block |
||
| 416 | 416 | * @param string $date |
| 417 | 417 | * @return array Flight departure and arrival airports and time |
| 418 | 418 | */ |
| 419 | - public function getVueling($callsign,$date = 'NOW') { |
|
| 419 | + public function getVueling($callsign, $date = 'NOW') { |
|
| 420 | 420 | $Common = new Common(); |
| 421 | 421 | $check_date = new Datetime($date); |
| 422 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 424 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
| 422 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 423 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 424 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
| 425 | 425 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 426 | 426 | $data = $Common->getData($url); |
| 427 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
| 427 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
| 428 | 428 | if ($data != '') { |
| 429 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
| 430 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
| 431 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
| 432 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
| 433 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 429 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
| 430 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
| 431 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
| 432 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
| 433 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
| 434 | 434 | else return array(); |
| 435 | 435 | } |
| 436 | 436 | return array(); |
@@ -444,27 +444,27 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | public function getIberia($callsign, $date = 'NOW') { |
| 446 | 446 | $Common = new Common(); |
| 447 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 447 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 448 | 448 | $check_date = new Datetime($date); |
| 449 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 449 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 450 | 450 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 451 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
| 452 | - $data = $Common->getData($url,'post',$post); |
|
| 451 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
| 452 | + $data = $Common->getData($url, 'post', $post); |
|
| 453 | 453 | if ($data != '') { |
| 454 | 454 | $table = $Common->table2array($data); |
| 455 | 455 | //print_r($table); |
| 456 | 456 | if (count($table) > 0) { |
| 457 | 457 | $flight = $table; |
| 458 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 459 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
| 458 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 459 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
| 460 | 460 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 461 | 461 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 462 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
| 463 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
| 462 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
| 463 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
| 464 | 464 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 465 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
| 466 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 467 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
| 465 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
| 466 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
| 467 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | return array(); |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | * @return array Flight departure and arrival airports and time |
| 479 | 479 | */ |
| 480 | 480 | |
| 481 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
| 481 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
| 482 | 482 | $Common = new Common(); |
| 483 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 483 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 484 | 484 | $check_date = new Datetime($date); |
| 485 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 485 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 486 | 486 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 487 | 487 | $data = $Common->getData($url); |
| 488 | 488 | if ($data != '') { |
@@ -491,13 +491,13 @@ discard block |
||
| 491 | 491 | $flight = $table; |
| 492 | 492 | //print_r($table); |
| 493 | 493 | if (isset($flight[25]) && isset($flight[29])) { |
| 494 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
| 495 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
| 494 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
| 495 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
| 496 | 496 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 497 | 497 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 498 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
| 499 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
| 500 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
| 498 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
| 499 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
| 500 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
| 501 | 501 | } else return array(); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | private function getAlitalia($callsign, $date = 'NOW') { |
| 517 | 517 | $Common = new Common(); |
| 518 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 518 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 519 | 519 | $check_date = new Datetime($date); |
| 520 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 520 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 521 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 522 | 522 | $data = $Common->getData($url); |
| 523 | 523 | if ($data != '') { |
| 524 | 524 | $table = $Common->text2array($data); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $ArrivalAirportIata = ''; |
| 527 | 527 | $departureTime = $table[4]; |
| 528 | 528 | $arrivalTime = $table[5]; |
| 529 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
| 529 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
| 530 | 530 | } |
| 531 | 531 | return array(); |
| 532 | 532 | } |
@@ -539,21 +539,21 @@ discard block |
||
| 539 | 539 | */ |
| 540 | 540 | private function getBrussels($callsign, $date = 'NOW') { |
| 541 | 541 | $Common = new Common(); |
| 542 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 542 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 543 | 543 | $check_date = new Datetime($date); |
| 544 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 544 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 545 | 545 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 546 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 546 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 547 | 547 | $data = $Common->getData($url); |
| 548 | 548 | if ($data != '') { |
| 549 | 549 | //echo $data; |
| 550 | - $parsed_json = json_decode($data,true); |
|
| 550 | + $parsed_json = json_decode($data, true); |
|
| 551 | 551 | if (isset($parsed_json[0]['FromAirportCode'])) { |
| 552 | 552 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
| 553 | 553 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
| 554 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 555 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 556 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
| 554 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 555 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 556 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | return array(); |
@@ -631,21 +631,21 @@ discard block |
||
| 631 | 631 | */ |
| 632 | 632 | private function getFlyTap($callsign) { |
| 633 | 633 | $Common = new Common(); |
| 634 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 635 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 634 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 635 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 636 | 636 | //$check_date = new Datetime($date); |
| 637 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 638 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
| 639 | - $data = $Common->getData($url,'post',$post); |
|
| 637 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 638 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
| 639 | + $data = $Common->getData($url, 'post', $post); |
|
| 640 | 640 | if ($data != '') { |
| 641 | 641 | $table = $Common->table2array($data); |
| 642 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
| 643 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
| 644 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
| 645 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
| 642 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
| 643 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
| 644 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
| 645 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
| 646 | 646 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 647 | 647 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 648 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
| 648 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
| 649 | 649 | } |
| 650 | 650 | return array(); |
| 651 | 651 | } |
@@ -667,10 +667,10 @@ discard block |
||
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | if ($airline_icao == '') return array(); |
| 670 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 671 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 670 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 671 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 672 | 672 | //$check_date = new Datetime($date); |
| 673 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 673 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 674 | 674 | $data = $Common->getData($url); |
| 675 | 675 | if ($data != '') { |
| 676 | 676 | $table = $Common->table2array($data); |
@@ -680,13 +680,13 @@ discard block |
||
| 680 | 680 | $darr = ''; |
| 681 | 681 | $ahour = ''; |
| 682 | 682 | $aarr = ''; |
| 683 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
| 683 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
| 684 | 684 | if ($n == 7) { |
| 685 | 685 | $departureTime = $dhour; |
| 686 | 686 | $arrivalTime = $ahour; |
| 687 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 688 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 689 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 687 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
| 688 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
| 689 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | $url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign; |
| 719 | 719 | $data = $Common->getData($url); |
| 720 | 720 | if ($data != '') { |
| 721 | - $result = json_decode($data,true); |
|
| 721 | + $result = json_decode($data, true); |
|
| 722 | 722 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
| 723 | 723 | if (isset($flight['origin'])) { |
| 724 | 724 | return array( |
@@ -731,18 +731,18 @@ discard block |
||
| 731 | 731 | } |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $url= "http://flightaware.com/live/flight/".$callsign; |
|
| 734 | + $url = "http://flightaware.com/live/flight/".$callsign; |
|
| 735 | 735 | $data = $Common->getData($url); |
| 736 | 736 | if ($data != '') { |
| 737 | - preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result); |
|
| 738 | - $flights = json_decode($result[1],true); |
|
| 737 | + preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result); |
|
| 738 | + $flights = json_decode($result[1], true); |
|
| 739 | 739 | $flight = reset($flights['flights']); |
| 740 | 740 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
| 741 | 741 | return array( |
| 742 | 742 | 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
| 743 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 743 | + 'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 744 | 744 | 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
| 745 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 745 | + 'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 746 | 746 | 'Source' => 'website_flightaware'); |
| 747 | 747 | } |
| 748 | 748 | } |
@@ -756,20 +756,20 @@ discard block |
||
| 756 | 756 | */ |
| 757 | 757 | public function getCostToTravel($callsign) { |
| 758 | 758 | $Common = new Common(); |
| 759 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 759 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 760 | 760 | //$check_date = new Datetime($date); |
| 761 | 761 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 762 | 762 | $data = $Common->getData($url); |
| 763 | 763 | if ($data != '') { |
| 764 | 764 | $table = $Common->table2array($data); |
| 765 | 765 | if (isset($table[11][1])) { |
| 766 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
| 766 | + if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5); |
|
| 767 | 767 | else $departureTime = ''; |
| 768 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
| 768 | + if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5); |
|
| 769 | 769 | else $arrivalTime = ''; |
| 770 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
| 771 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
| 772 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
| 770 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
| 771 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
| 772 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | return array(); |
@@ -781,14 +781,14 @@ discard block |
||
| 781 | 781 | * @param string $date date we want flight number info |
| 782 | 782 | * @return array Flight departure and arrival airports and time |
| 783 | 783 | */ |
| 784 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
| 784 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
| 785 | 785 | $Common = new Common(); |
| 786 | 786 | if (class_exists("DomDocument") === FALSE) return array(); |
| 787 | 787 | date_default_timezone_set('UTC'); |
| 788 | 788 | $check_date = new Datetime($date); |
| 789 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 790 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 791 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 789 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 790 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 791 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 792 | 792 | $data = $Common->getData($url); |
| 793 | 793 | $dom = new DomDocument(); |
| 794 | 794 | $dom->loadXML($data); |
@@ -796,11 +796,11 @@ discard block |
||
| 796 | 796 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 797 | 797 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 798 | 798 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 799 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 799 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 800 | 800 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
| 801 | 801 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 802 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 803 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
| 802 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 803 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
| 804 | 804 | } else return array(); |
| 805 | 805 | } |
| 806 | 806 | |
@@ -812,21 +812,21 @@ discard block |
||
| 812 | 812 | */ |
| 813 | 813 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 814 | 814 | $Common = new Common(); |
| 815 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 815 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 816 | 816 | $check_date = new Datetime($date); |
| 817 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 818 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 817 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 818 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 819 | 819 | $data = $Common->getData($url); |
| 820 | 820 | if ($data != '') { |
| 821 | 821 | $table = $Common->table2array($data); |
| 822 | 822 | $flight = $table; |
| 823 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 824 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
| 823 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 824 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
| 825 | 825 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 826 | 826 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 827 | 827 | $departureTime = $flight[5][1]; |
| 828 | 828 | $arrivalTime = $flight[23][1]; |
| 829 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
| 829 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
| 830 | 830 | } |
| 831 | 831 | return array(); |
| 832 | 832 | } |
@@ -838,16 +838,16 @@ discard block |
||
| 838 | 838 | * @param String $carrier airline code |
| 839 | 839 | * @return array Flight departure and arrival airports and time |
| 840 | 840 | */ |
| 841 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
| 841 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
| 842 | 842 | $Common = new Common(); |
| 843 | 843 | date_default_timezone_set('UTC'); |
| 844 | 844 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
| 845 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 845 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 846 | 846 | $check_date = new Datetime($date); |
| 847 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 848 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 849 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
| 850 | - $data = $Common->getData($url,'post',$post); |
|
| 847 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 848 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 849 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
| 850 | + $data = $Common->getData($url, 'post', $post); |
|
| 851 | 851 | //echo $data; |
| 852 | 852 | $DepartureAirportIata = ''; |
| 853 | 853 | $ArrivalAirportIata = ''; |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
| 861 | 861 | else $departureAirport = ''; |
| 862 | 862 | } else return array(); |
| 863 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
| 864 | - $data = $Common->getData($url,'post',$post); |
|
| 863 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
| 864 | + $data = $Common->getData($url, 'post', $post); |
|
| 865 | 865 | if ($data != '') { |
| 866 | 866 | $table = $Common->table2array($data); |
| 867 | 867 | $flight = $table; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | if (isset($DepartureAirportIata)) { |
| 892 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
| 892 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
| 893 | 893 | } else return array(); |
| 894 | 894 | } |
| 895 | 895 | |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | * @param String $date Date |
| 900 | 900 | * @return array Schedules info |
| 901 | 901 | */ |
| 902 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
| 902 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
| 903 | 903 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername; |
| 904 | 904 | //$Common = new Common(); |
| 905 | 905 | if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | // Brussels Airlines |
| 970 | 970 | case "BEL": |
| 971 | 971 | case "SN": |
| 972 | - return $this->getBrussels($ident,$date); |
|
| 972 | + return $this->getBrussels($ident, $date); |
|
| 973 | 973 | /* |
| 974 | 974 | // Copa Airlines |
| 975 | 975 | case "CMP": |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | case "DS": |
| 1069 | 1069 | case "EZY": |
| 1070 | 1070 | case "EZS": |
| 1071 | - return $this->getEasyJet($ident,$date); |
|
| 1071 | + return $this->getEasyJet($ident, $date); |
|
| 1072 | 1072 | // Ryanair |
| 1073 | 1073 | case "FR": |
| 1074 | 1074 | case "RYR": |
@@ -1120,19 +1120,19 @@ discard block |
||
| 1120 | 1120 | return $this->getIberia($ident); |
| 1121 | 1121 | // Vietnam Airlines |
| 1122 | 1122 | case "HVN": |
| 1123 | - return $this->getVietnamAirlines($ident,$date); |
|
| 1123 | + return $this->getVietnamAirlines($ident, $date); |
|
| 1124 | 1124 | // Air Berlin |
| 1125 | 1125 | case "AB": |
| 1126 | 1126 | case "BER": |
| 1127 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
| 1127 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
| 1128 | 1128 | // NIKI |
| 1129 | 1129 | case "HG": |
| 1130 | 1130 | case "NLY": |
| 1131 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
| 1131 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
| 1132 | 1132 | // BelAir |
| 1133 | 1133 | case "4T": |
| 1134 | 1134 | case "BHP": |
| 1135 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
| 1135 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
| 1136 | 1136 | default: |
| 1137 | 1137 | if (strlen($airline_icao) == 3) { |
| 1138 | 1138 | $Spotter = new Spotter($this->db); |
@@ -1141,9 +1141,9 @@ discard block |
||
| 1141 | 1141 | } |
| 1142 | 1142 | // Randomly use a generic function to get hours |
| 1143 | 1143 | if (strlen($airline_icao) == 2) { |
| 1144 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1144 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware'); |
|
| 1145 | 1145 | if (count($globalSchedulesSources) > 0) { |
| 1146 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
| 1146 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
| 1147 | 1147 | $source = $globalSchedulesSources[$rand]; |
| 1148 | 1148 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
| 1149 | 1149 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |