@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | $this->db = $Connection->db; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Get SQL query part for filter used |
|
| 13 | - * @param Array $filter the filter |
|
| 14 | - * @return Array the SQL part |
|
| 15 | - */ |
|
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 11 | + /** |
|
| 12 | + * Get SQL query part for filter used |
|
| 13 | + * @param Array $filter the filter |
|
| 14 | + * @return Array the SQL part |
|
| 15 | + */ |
|
| 16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 18 | 18 | $filters = array(); |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -30,88 +30,88 @@ discard block |
||
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | 32 | foreach($filters as $flt) { |
| 33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 34 | 34 | if ($flt['airlines'][0] != '') { |
| 35 | - if (isset($flt['source'])) { |
|
| 35 | + if (isset($flt['source'])) { |
|
| 36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 37 | - } else { |
|
| 37 | + } else { |
|
| 38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | + } |
|
| 40 | 41 | } |
| 41 | - } |
|
| 42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 43 | 43 | if (isset($flt['source'])) { |
| 44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | 45 | } else { |
| 46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | 47 | } |
| 48 | - } |
|
| 49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 48 | + } |
|
| 49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 50 | 50 | if (isset($flt['source'])) { |
| 51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | 52 | } else { |
| 53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + } |
|
| 54 | 55 | } |
| 55 | - } |
|
| 56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 57 | 57 | if (isset($flt['source'])) { |
| 58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | 59 | } else { |
| 60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + } |
|
| 61 | 62 | } |
| 62 | - } |
|
| 63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 64 | 64 | if (isset($flt['source'])) { |
| 65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + } |
|
| 66 | 67 | } |
| 67 | - } |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 70 | - if ($filter['airlines'][0] != '') { |
|
| 70 | + if ($filter['airlines'][0] != '') { |
|
| 71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 89 | 89 | } |
| 90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 91 | - $filter_query_date = ''; |
|
| 91 | + $filter_query_date = ''; |
|
| 92 | 92 | |
| 93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
| 93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
| 94 | 94 | if ($globalDBdriver == 'mysql') { |
| 95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 96 | 96 | } else { |
| 97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 98 | + } |
|
| 98 | 99 | } |
| 99 | - } |
|
| 100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
| 100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
| 101 | 101 | if ($globalDBdriver == 'mysql') { |
| 102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 103 | 103 | } else { |
| 104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 105 | 105 | } |
| 106 | - } |
|
| 107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
| 106 | + } |
|
| 107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
| 108 | 108 | if ($globalDBdriver == 'mysql') { |
| 109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 110 | 110 | } else { |
| 111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 112 | + } |
|
| 112 | 113 | } |
| 113 | - } |
|
| 114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | 115 | } |
| 116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
| 122 | 122 | return $filter_query; |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | // Spotter_archive |
| 126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -152,44 +152,44 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Gets all the spotter information based on a particular callsign |
|
| 157 | - * |
|
| 158 | - * @return Array the spotter information |
|
| 159 | - * |
|
| 160 | - */ |
|
| 161 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 162 | - { |
|
| 155 | + /** |
|
| 156 | + * Gets all the spotter information based on a particular callsign |
|
| 157 | + * |
|
| 158 | + * @return Array the spotter information |
|
| 159 | + * |
|
| 160 | + */ |
|
| 161 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 162 | + { |
|
| 163 | 163 | $Spotter = new Spotter($this->db); |
| 164 | - date_default_timezone_set('UTC'); |
|
| 164 | + date_default_timezone_set('UTC'); |
|
| 165 | 165 | |
| 166 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 167 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 167 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 169 | 169 | |
| 170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 170 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 171 | 171 | |
| 172 | - return $spotter_array; |
|
| 173 | - } |
|
| 172 | + return $spotter_array; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Gets last the spotter information based on a particular id |
|
| 178 | - * |
|
| 179 | - * @return Array the spotter information |
|
| 180 | - * |
|
| 181 | - */ |
|
| 182 | - public function getLastArchiveSpotterDataById($id) |
|
| 183 | - { |
|
| 184 | - $Spotter = new Spotter($this->db); |
|
| 185 | - date_default_timezone_set('UTC'); |
|
| 186 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 187 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 188 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 176 | + /** |
|
| 177 | + * Gets last the spotter information based on a particular id |
|
| 178 | + * |
|
| 179 | + * @return Array the spotter information |
|
| 180 | + * |
|
| 181 | + */ |
|
| 182 | + public function getLastArchiveSpotterDataById($id) |
|
| 183 | + { |
|
| 184 | + $Spotter = new Spotter($this->db); |
|
| 185 | + date_default_timezone_set('UTC'); |
|
| 186 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 187 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 188 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 190 | 190 | |
| 191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 192 | - /* |
|
| 192 | + /* |
|
| 193 | 193 | try { |
| 194 | 194 | $Connection = new Connection(); |
| 195 | 195 | $sth = Connection->$db->prepare($query); |
@@ -199,232 +199,232 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 201 | 201 | */ |
| 202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 203 | - |
|
| 204 | - return $spotter_array; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Gets all the spotter information based on a particular id |
|
| 209 | - * |
|
| 210 | - * @return Array the spotter information |
|
| 211 | - * |
|
| 212 | - */ |
|
| 213 | - public function getAllArchiveSpotterDataById($id) |
|
| 202 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 203 | + |
|
| 204 | + return $spotter_array; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Gets all the spotter information based on a particular id |
|
| 209 | + * |
|
| 210 | + * @return Array the spotter information |
|
| 211 | + * |
|
| 212 | + */ |
|
| 213 | + public function getAllArchiveSpotterDataById($id) |
|
| 214 | 214 | { |
| 215 | - date_default_timezone_set('UTC'); |
|
| 216 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 215 | + date_default_timezone_set('UTC'); |
|
| 216 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 218 | 218 | |
| 219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 220 | 220 | |
| 221 | - try { |
|
| 222 | - $sth = $this->db->prepare($query); |
|
| 223 | - $sth->execute(array(':id' => $id)); |
|
| 224 | - } catch(PDOException $e) { |
|
| 225 | - echo $e->getMessage(); |
|
| 226 | - die; |
|
| 227 | - } |
|
| 228 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 229 | - |
|
| 230 | - return $spotter_array; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Gets coordinate & time spotter information based on a particular id |
|
| 235 | - * |
|
| 236 | - * @return Array the spotter information |
|
| 237 | - * |
|
| 238 | - */ |
|
| 239 | - public function getCoordArchiveSpotterDataById($id) |
|
| 240 | - { |
|
| 241 | - date_default_timezone_set('UTC'); |
|
| 242 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 221 | + try { |
|
| 222 | + $sth = $this->db->prepare($query); |
|
| 223 | + $sth->execute(array(':id' => $id)); |
|
| 224 | + } catch(PDOException $e) { |
|
| 225 | + echo $e->getMessage(); |
|
| 226 | + die; |
|
| 227 | + } |
|
| 228 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 229 | + |
|
| 230 | + return $spotter_array; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Gets coordinate & time spotter information based on a particular id |
|
| 235 | + * |
|
| 236 | + * @return Array the spotter information |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | + public function getCoordArchiveSpotterDataById($id) |
|
| 240 | + { |
|
| 241 | + date_default_timezone_set('UTC'); |
|
| 242 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 244 | 244 | |
| 245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 246 | 246 | |
| 247 | - try { |
|
| 248 | - $sth = $this->db->prepare($query); |
|
| 249 | - $sth->execute(array(':id' => $id)); |
|
| 250 | - } catch(PDOException $e) { |
|
| 251 | - echo $e->getMessage(); |
|
| 252 | - die; |
|
| 253 | - } |
|
| 254 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 247 | + try { |
|
| 248 | + $sth = $this->db->prepare($query); |
|
| 249 | + $sth->execute(array(':id' => $id)); |
|
| 250 | + } catch(PDOException $e) { |
|
| 251 | + echo $e->getMessage(); |
|
| 252 | + die; |
|
| 253 | + } |
|
| 254 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 255 | 255 | |
| 256 | - return $spotter_array; |
|
| 257 | - } |
|
| 256 | + return $spotter_array; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * Gets altitude information based on a particular callsign |
|
| 262 | - * |
|
| 263 | - * @return Array the spotter information |
|
| 264 | - * |
|
| 265 | - */ |
|
| 266 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 267 | - { |
|
| 260 | + /** |
|
| 261 | + * Gets altitude information based on a particular callsign |
|
| 262 | + * |
|
| 263 | + * @return Array the spotter information |
|
| 264 | + * |
|
| 265 | + */ |
|
| 266 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 267 | + { |
|
| 268 | 268 | |
| 269 | - date_default_timezone_set('UTC'); |
|
| 269 | + date_default_timezone_set('UTC'); |
|
| 270 | 270 | |
| 271 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 273 | 273 | |
| 274 | - try { |
|
| 275 | - $sth = $this->db->prepare($query); |
|
| 276 | - $sth->execute(array(':ident' => $ident)); |
|
| 277 | - } catch(PDOException $e) { |
|
| 278 | - echo $e->getMessage(); |
|
| 279 | - die; |
|
| 280 | - } |
|
| 281 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 274 | + try { |
|
| 275 | + $sth = $this->db->prepare($query); |
|
| 276 | + $sth->execute(array(':ident' => $ident)); |
|
| 277 | + } catch(PDOException $e) { |
|
| 278 | + echo $e->getMessage(); |
|
| 279 | + die; |
|
| 280 | + } |
|
| 281 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 282 | 282 | |
| 283 | - return $spotter_array; |
|
| 284 | - } |
|
| 283 | + return $spotter_array; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Gets altitude information based on a particular id |
|
| 288 | - * |
|
| 289 | - * @return Array the spotter information |
|
| 290 | - * |
|
| 291 | - */ |
|
| 292 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 293 | - { |
|
| 286 | + /** |
|
| 287 | + * Gets altitude information based on a particular id |
|
| 288 | + * |
|
| 289 | + * @return Array the spotter information |
|
| 290 | + * |
|
| 291 | + */ |
|
| 292 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 293 | + { |
|
| 294 | 294 | |
| 295 | - date_default_timezone_set('UTC'); |
|
| 295 | + date_default_timezone_set('UTC'); |
|
| 296 | 296 | |
| 297 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 297 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 299 | 299 | |
| 300 | - try { |
|
| 301 | - $sth = $this->db->prepare($query); |
|
| 302 | - $sth->execute(array(':id' => $id)); |
|
| 303 | - } catch(PDOException $e) { |
|
| 304 | - echo $e->getMessage(); |
|
| 305 | - die; |
|
| 306 | - } |
|
| 307 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 300 | + try { |
|
| 301 | + $sth = $this->db->prepare($query); |
|
| 302 | + $sth->execute(array(':id' => $id)); |
|
| 303 | + } catch(PDOException $e) { |
|
| 304 | + echo $e->getMessage(); |
|
| 305 | + die; |
|
| 306 | + } |
|
| 307 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 308 | 308 | |
| 309 | - return $spotter_array; |
|
| 310 | - } |
|
| 309 | + return $spotter_array; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - /** |
|
| 313 | - * Gets altitude & speed information based on a particular id |
|
| 314 | - * |
|
| 315 | - * @return Array the spotter information |
|
| 316 | - * |
|
| 317 | - */ |
|
| 318 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 319 | - { |
|
| 312 | + /** |
|
| 313 | + * Gets altitude & speed information based on a particular id |
|
| 314 | + * |
|
| 315 | + * @return Array the spotter information |
|
| 316 | + * |
|
| 317 | + */ |
|
| 318 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 319 | + { |
|
| 320 | 320 | |
| 321 | - date_default_timezone_set('UTC'); |
|
| 321 | + date_default_timezone_set('UTC'); |
|
| 322 | 322 | |
| 323 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 323 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 325 | 325 | |
| 326 | - try { |
|
| 327 | - $sth = $this->db->prepare($query); |
|
| 328 | - $sth->execute(array(':id' => $id)); |
|
| 329 | - } catch(PDOException $e) { |
|
| 330 | - echo $e->getMessage(); |
|
| 331 | - die; |
|
| 332 | - } |
|
| 333 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | + try { |
|
| 327 | + $sth = $this->db->prepare($query); |
|
| 328 | + $sth->execute(array(':id' => $id)); |
|
| 329 | + } catch(PDOException $e) { |
|
| 330 | + echo $e->getMessage(); |
|
| 331 | + die; |
|
| 332 | + } |
|
| 333 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 334 | 334 | |
| 335 | - return $spotter_array; |
|
| 336 | - } |
|
| 335 | + return $spotter_array; |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | 338 | |
| 339 | - /** |
|
| 340 | - * Gets altitude information based on a particular callsign |
|
| 341 | - * |
|
| 342 | - * @return Array the spotter information |
|
| 343 | - * |
|
| 344 | - */ |
|
| 345 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 346 | - { |
|
| 339 | + /** |
|
| 340 | + * Gets altitude information based on a particular callsign |
|
| 341 | + * |
|
| 342 | + * @return Array the spotter information |
|
| 343 | + * |
|
| 344 | + */ |
|
| 345 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 346 | + { |
|
| 347 | 347 | |
| 348 | - date_default_timezone_set('UTC'); |
|
| 348 | + date_default_timezone_set('UTC'); |
|
| 349 | 349 | |
| 350 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 350 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 353 | 353 | |
| 354 | - try { |
|
| 355 | - $sth = $this->db->prepare($query); |
|
| 356 | - $sth->execute(array(':ident' => $ident)); |
|
| 357 | - } catch(PDOException $e) { |
|
| 358 | - echo $e->getMessage(); |
|
| 359 | - die; |
|
| 360 | - } |
|
| 361 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | + try { |
|
| 355 | + $sth = $this->db->prepare($query); |
|
| 356 | + $sth->execute(array(':ident' => $ident)); |
|
| 357 | + } catch(PDOException $e) { |
|
| 358 | + echo $e->getMessage(); |
|
| 359 | + die; |
|
| 360 | + } |
|
| 361 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 362 | 362 | |
| 363 | - return $spotter_array; |
|
| 364 | - } |
|
| 363 | + return $spotter_array; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * Gets all the archive spotter information |
|
| 370 | - * |
|
| 371 | - * @return Array the spotter information |
|
| 372 | - * |
|
| 373 | - */ |
|
| 374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 375 | - { |
|
| 376 | - $Spotter = new Spotter($this->db); |
|
| 377 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 368 | + /** |
|
| 369 | + * Gets all the archive spotter information |
|
| 370 | + * |
|
| 371 | + * @return Array the spotter information |
|
| 372 | + * |
|
| 373 | + */ |
|
| 374 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 375 | + { |
|
| 376 | + $Spotter = new Spotter($this->db); |
|
| 377 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 379 | 379 | |
| 380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 380 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 381 | 381 | |
| 382 | - return $spotter_array; |
|
| 383 | - } |
|
| 382 | + return $spotter_array; |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - public function deleteSpotterArchiveTrackData() |
|
| 386 | - { |
|
| 385 | + public function deleteSpotterArchiveTrackData() |
|
| 386 | + { |
|
| 387 | 387 | global $globalArchiveKeepTrackMonths; |
| 388 | - date_default_timezone_set('UTC'); |
|
| 388 | + date_default_timezone_set('UTC'); |
|
| 389 | 389 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 390 | - try { |
|
| 391 | - $sth = $this->db->prepare($query); |
|
| 392 | - $sth->execute(); |
|
| 393 | - } catch(PDOException $e) { |
|
| 394 | - echo $e->getMessage(); |
|
| 395 | - die; |
|
| 396 | - } |
|
| 390 | + try { |
|
| 391 | + $sth = $this->db->prepare($query); |
|
| 392 | + $sth->execute(); |
|
| 393 | + } catch(PDOException $e) { |
|
| 394 | + echo $e->getMessage(); |
|
| 395 | + die; |
|
| 396 | + } |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | - * Gets Minimal Live Spotter data |
|
| 401 | - * |
|
| 402 | - * @return Array the spotter information |
|
| 403 | - * |
|
| 404 | - */ |
|
| 405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 406 | - { |
|
| 407 | - global $globalDBdriver, $globalLiveInterval; |
|
| 408 | - date_default_timezone_set('UTC'); |
|
| 409 | - |
|
| 410 | - $filter_query = ''; |
|
| 411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | - } |
|
| 414 | - // Use spotter_output also ? |
|
| 415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 417 | - } |
|
| 418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | - } |
|
| 421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 427 | - /* |
|
| 400 | + * Gets Minimal Live Spotter data |
|
| 401 | + * |
|
| 402 | + * @return Array the spotter information |
|
| 403 | + * |
|
| 404 | + */ |
|
| 405 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 406 | + { |
|
| 407 | + global $globalDBdriver, $globalLiveInterval; |
|
| 408 | + date_default_timezone_set('UTC'); |
|
| 409 | + |
|
| 410 | + $filter_query = ''; |
|
| 411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | + } |
|
| 414 | + // Use spotter_output also ? |
|
| 415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 417 | + } |
|
| 418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | + } |
|
| 421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | + /* |
|
| 428 | 428 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 429 | 429 | FROM spotter_archive |
| 430 | 430 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -443,56 +443,56 @@ discard block |
||
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
| 446 | - } else { |
|
| 447 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | + } else { |
|
| 447 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM spotter_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 452 | 452 | '.$filter_query.' ORDER BY flightaware_id'; |
| 453 | - } |
|
| 454 | - //echo $query; |
|
| 455 | - try { |
|
| 456 | - $sth = $this->db->prepare($query); |
|
| 457 | - $sth->execute(); |
|
| 458 | - } catch(PDOException $e) { |
|
| 459 | - echo $e->getMessage(); |
|
| 460 | - die; |
|
| 461 | - } |
|
| 462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | - |
|
| 464 | - return $spotter_array; |
|
| 465 | - } |
|
| 453 | + } |
|
| 454 | + //echo $query; |
|
| 455 | + try { |
|
| 456 | + $sth = $this->db->prepare($query); |
|
| 457 | + $sth->execute(); |
|
| 458 | + } catch(PDOException $e) { |
|
| 459 | + echo $e->getMessage(); |
|
| 460 | + die; |
|
| 461 | + } |
|
| 462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | + |
|
| 464 | + return $spotter_array; |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | 467 | /** |
| 468 | - * Gets Minimal Live Spotter data |
|
| 469 | - * |
|
| 470 | - * @return Array the spotter information |
|
| 471 | - * |
|
| 472 | - */ |
|
| 473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 474 | - { |
|
| 475 | - global $globalDBdriver, $globalLiveInterval; |
|
| 476 | - date_default_timezone_set('UTC'); |
|
| 477 | - |
|
| 478 | - $filter_query = ''; |
|
| 479 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 481 | - } |
|
| 482 | - // Should use spotter_output also ? |
|
| 483 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 485 | - } |
|
| 486 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 487 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 488 | - } |
|
| 489 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 494 | - if ($globalDBdriver == 'mysql') { |
|
| 495 | - /* |
|
| 468 | + * Gets Minimal Live Spotter data |
|
| 469 | + * |
|
| 470 | + * @return Array the spotter information |
|
| 471 | + * |
|
| 472 | + */ |
|
| 473 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 474 | + { |
|
| 475 | + global $globalDBdriver, $globalLiveInterval; |
|
| 476 | + date_default_timezone_set('UTC'); |
|
| 477 | + |
|
| 478 | + $filter_query = ''; |
|
| 479 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 480 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 481 | + } |
|
| 482 | + // Should use spotter_output also ? |
|
| 483 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 485 | + } |
|
| 486 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 487 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 488 | + } |
|
| 489 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 494 | + if ($globalDBdriver == 'mysql') { |
|
| 495 | + /* |
|
| 496 | 496 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 497 | 497 | FROM spotter_archive |
| 498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -503,95 +503,95 @@ discard block |
||
| 503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 505 | 505 | |
| 506 | - } else { |
|
| 507 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 508 | - /* |
|
| 506 | + } else { |
|
| 507 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 508 | + /* |
|
| 509 | 509 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 510 | 510 | FROM spotter_archive_output |
| 511 | 511 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 514 | 514 | */ |
| 515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 516 | 516 | FROM spotter_archive_output |
| 517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 519 | 519 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 520 | 520 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 521 | 521 | |
| 522 | - } |
|
| 523 | - //echo $query; |
|
| 524 | - try { |
|
| 525 | - $sth = $this->db->prepare($query); |
|
| 526 | - $sth->execute(); |
|
| 527 | - } catch(PDOException $e) { |
|
| 528 | - echo $e->getMessage(); |
|
| 529 | - die; |
|
| 530 | - } |
|
| 531 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 532 | - |
|
| 533 | - return $spotter_array; |
|
| 534 | - } |
|
| 522 | + } |
|
| 523 | + //echo $query; |
|
| 524 | + try { |
|
| 525 | + $sth = $this->db->prepare($query); |
|
| 526 | + $sth->execute(); |
|
| 527 | + } catch(PDOException $e) { |
|
| 528 | + echo $e->getMessage(); |
|
| 529 | + die; |
|
| 530 | + } |
|
| 531 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 532 | + |
|
| 533 | + return $spotter_array; |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | - * Gets count Live Spotter data |
|
| 538 | - * |
|
| 539 | - * @return Array the spotter information |
|
| 540 | - * |
|
| 541 | - */ |
|
| 542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 543 | - { |
|
| 544 | - global $globalDBdriver, $globalLiveInterval; |
|
| 545 | - date_default_timezone_set('UTC'); |
|
| 546 | - |
|
| 547 | - $filter_query = ''; |
|
| 548 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 550 | - } |
|
| 551 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 553 | - } |
|
| 554 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 555 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 556 | - } |
|
| 557 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 562 | - if ($globalDBdriver == 'mysql') { |
|
| 537 | + * Gets count Live Spotter data |
|
| 538 | + * |
|
| 539 | + * @return Array the spotter information |
|
| 540 | + * |
|
| 541 | + */ |
|
| 542 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 543 | + { |
|
| 544 | + global $globalDBdriver, $globalLiveInterval; |
|
| 545 | + date_default_timezone_set('UTC'); |
|
| 546 | + |
|
| 547 | + $filter_query = ''; |
|
| 548 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 549 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 550 | + } |
|
| 551 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 553 | + } |
|
| 554 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 555 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 556 | + } |
|
| 557 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 562 | + if ($globalDBdriver == 'mysql') { |
|
| 563 | 563 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 564 | 564 | FROM spotter_archive l |
| 565 | 565 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 566 | - } else { |
|
| 566 | + } else { |
|
| 567 | 567 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 568 | - } |
|
| 569 | - //echo $query; |
|
| 570 | - try { |
|
| 571 | - $sth = $this->db->prepare($query); |
|
| 572 | - $sth->execute(); |
|
| 573 | - } catch(PDOException $e) { |
|
| 574 | - echo $e->getMessage(); |
|
| 575 | - die; |
|
| 576 | - } |
|
| 568 | + } |
|
| 569 | + //echo $query; |
|
| 570 | + try { |
|
| 571 | + $sth = $this->db->prepare($query); |
|
| 572 | + $sth->execute(); |
|
| 573 | + } catch(PDOException $e) { |
|
| 574 | + echo $e->getMessage(); |
|
| 575 | + die; |
|
| 576 | + } |
|
| 577 | 577 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 578 | 578 | $sth->closeCursor(); |
| 579 | - return $result['nb']; |
|
| 579 | + return $result['nb']; |
|
| 580 | 580 | |
| 581 | - } |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | // Spotter_Archive_output |
| 586 | 586 | |
| 587 | - /** |
|
| 588 | - * Gets all the spotter information |
|
| 589 | - * |
|
| 590 | - * @return Array the spotter information |
|
| 591 | - * |
|
| 592 | - */ |
|
| 593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 594 | - { |
|
| 587 | + /** |
|
| 588 | + * Gets all the spotter information |
|
| 589 | + * |
|
| 590 | + * @return Array the spotter information |
|
| 591 | + * |
|
| 592 | + */ |
|
| 593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 594 | + { |
|
| 595 | 595 | global $globalTimezone, $globalDBdriver; |
| 596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 597 | 597 | $Translation = new Translation(); |
@@ -605,159 +605,159 @@ discard block |
||
| 605 | 605 | $filter_query = $this->getFilter($filters); |
| 606 | 606 | if ($q != "") |
| 607 | 607 | { |
| 608 | - if (!is_string($q)) |
|
| 609 | - { |
|
| 608 | + if (!is_string($q)) |
|
| 609 | + { |
|
| 610 | 610 | return false; |
| 611 | - } else { |
|
| 611 | + } else { |
|
| 612 | 612 | |
| 613 | 613 | $q_array = explode(" ", $q); |
| 614 | 614 | |
| 615 | 615 | foreach ($q_array as $q_item){ |
| 616 | - $additional_query .= " AND ("; |
|
| 617 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 618 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 619 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 620 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 621 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 628 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 631 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 632 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 633 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 634 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 635 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 636 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 637 | - $translate = $Translation->ident2icao($q_item); |
|
| 638 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 639 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 640 | - $additional_query .= ")"; |
|
| 641 | - } |
|
| 642 | - } |
|
| 616 | + $additional_query .= " AND ("; |
|
| 617 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 618 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 619 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 620 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 621 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 628 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 631 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 632 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 633 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 634 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 635 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 636 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 637 | + $translate = $Translation->ident2icao($q_item); |
|
| 638 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 639 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 640 | + $additional_query .= ")"; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | if ($registration != "") |
| 646 | 646 | { |
| 647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 648 | - if (!is_string($registration)) |
|
| 649 | - { |
|
| 647 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 648 | + if (!is_string($registration)) |
|
| 649 | + { |
|
| 650 | 650 | return false; |
| 651 | - } else { |
|
| 651 | + } else { |
|
| 652 | 652 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 653 | - } |
|
| 653 | + } |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | if ($aircraft_icao != "") |
| 657 | 657 | { |
| 658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 659 | - if (!is_string($aircraft_icao)) |
|
| 660 | - { |
|
| 658 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 659 | + if (!is_string($aircraft_icao)) |
|
| 660 | + { |
|
| 661 | 661 | return false; |
| 662 | - } else { |
|
| 662 | + } else { |
|
| 663 | 663 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 664 | - } |
|
| 664 | + } |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | if ($aircraft_manufacturer != "") |
| 668 | 668 | { |
| 669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 670 | - if (!is_string($aircraft_manufacturer)) |
|
| 671 | - { |
|
| 669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 670 | + if (!is_string($aircraft_manufacturer)) |
|
| 671 | + { |
|
| 672 | 672 | return false; |
| 673 | - } else { |
|
| 673 | + } else { |
|
| 674 | 674 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 675 | - } |
|
| 675 | + } |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | if ($highlights == "true") |
| 679 | 679 | { |
| 680 | - if (!is_string($highlights)) |
|
| 681 | - { |
|
| 680 | + if (!is_string($highlights)) |
|
| 681 | + { |
|
| 682 | 682 | return false; |
| 683 | - } else { |
|
| 683 | + } else { |
|
| 684 | 684 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 685 | - } |
|
| 685 | + } |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | if ($airline_icao != "") |
| 689 | 689 | { |
| 690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 691 | - if (!is_string($airline_icao)) |
|
| 692 | - { |
|
| 690 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 691 | + if (!is_string($airline_icao)) |
|
| 692 | + { |
|
| 693 | 693 | return false; |
| 694 | - } else { |
|
| 694 | + } else { |
|
| 695 | 695 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 696 | - } |
|
| 696 | + } |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if ($airline_country != "") |
| 700 | 700 | { |
| 701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 702 | - if (!is_string($airline_country)) |
|
| 703 | - { |
|
| 701 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 702 | + if (!is_string($airline_country)) |
|
| 703 | + { |
|
| 704 | 704 | return false; |
| 705 | - } else { |
|
| 705 | + } else { |
|
| 706 | 706 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 707 | - } |
|
| 707 | + } |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | if ($airline_type != "") |
| 711 | 711 | { |
| 712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 713 | - if (!is_string($airline_type)) |
|
| 714 | - { |
|
| 712 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 713 | + if (!is_string($airline_type)) |
|
| 714 | + { |
|
| 715 | 715 | return false; |
| 716 | - } else { |
|
| 716 | + } else { |
|
| 717 | 717 | if ($airline_type == "passenger") |
| 718 | 718 | { |
| 719 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 719 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 720 | 720 | } |
| 721 | 721 | if ($airline_type == "cargo") |
| 722 | 722 | { |
| 723 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 723 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 724 | 724 | } |
| 725 | 725 | if ($airline_type == "military") |
| 726 | 726 | { |
| 727 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 727 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 728 | + } |
|
| 728 | 729 | } |
| 729 | - } |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | if ($airport != "") |
| 733 | 733 | { |
| 734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 735 | - if (!is_string($airport)) |
|
| 736 | - { |
|
| 734 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 735 | + if (!is_string($airport)) |
|
| 736 | + { |
|
| 737 | 737 | return false; |
| 738 | - } else { |
|
| 738 | + } else { |
|
| 739 | 739 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 740 | - } |
|
| 740 | + } |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | if ($airport_country != "") |
| 744 | 744 | { |
| 745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 746 | - if (!is_string($airport_country)) |
|
| 747 | - { |
|
| 745 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 746 | + if (!is_string($airport_country)) |
|
| 747 | + { |
|
| 748 | 748 | return false; |
| 749 | - } else { |
|
| 749 | + } else { |
|
| 750 | 750 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 751 | - } |
|
| 751 | + } |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | if ($callsign != "") |
| 755 | 755 | { |
| 756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 757 | - if (!is_string($callsign)) |
|
| 758 | - { |
|
| 756 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 757 | + if (!is_string($callsign)) |
|
| 758 | + { |
|
| 759 | 759 | return false; |
| 760 | - } else { |
|
| 760 | + } else { |
|
| 761 | 761 | $translate = $Translation->ident2icao($callsign); |
| 762 | 762 | if ($translate != $callsign) { |
| 763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -765,99 +765,99 @@ discard block |
||
| 765 | 765 | } else { |
| 766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 767 | 767 | } |
| 768 | - } |
|
| 768 | + } |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | if ($owner != "") |
| 772 | 772 | { |
| 773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 774 | - if (!is_string($owner)) |
|
| 775 | - { |
|
| 773 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 774 | + if (!is_string($owner)) |
|
| 775 | + { |
|
| 776 | 776 | return false; |
| 777 | - } else { |
|
| 777 | + } else { |
|
| 778 | 778 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 779 | - } |
|
| 779 | + } |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | if ($pilot_name != "") |
| 783 | 783 | { |
| 784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 785 | - if (!is_string($pilot_name)) |
|
| 786 | - { |
|
| 784 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 785 | + if (!is_string($pilot_name)) |
|
| 786 | + { |
|
| 787 | 787 | return false; |
| 788 | - } else { |
|
| 788 | + } else { |
|
| 789 | 789 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 790 | - } |
|
| 790 | + } |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | if ($pilot_id != "") |
| 794 | 794 | { |
| 795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 796 | - if (!is_string($pilot_id)) |
|
| 797 | - { |
|
| 795 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 796 | + if (!is_string($pilot_id)) |
|
| 797 | + { |
|
| 798 | 798 | return false; |
| 799 | - } else { |
|
| 799 | + } else { |
|
| 800 | 800 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 801 | - } |
|
| 801 | + } |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | if ($departure_airport_route != "") |
| 805 | 805 | { |
| 806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 807 | - if (!is_string($departure_airport_route)) |
|
| 808 | - { |
|
| 806 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 807 | + if (!is_string($departure_airport_route)) |
|
| 808 | + { |
|
| 809 | 809 | return false; |
| 810 | - } else { |
|
| 810 | + } else { |
|
| 811 | 811 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 812 | - } |
|
| 812 | + } |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | if ($arrival_airport_route != "") |
| 816 | 816 | { |
| 817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 818 | - if (!is_string($arrival_airport_route)) |
|
| 819 | - { |
|
| 817 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 818 | + if (!is_string($arrival_airport_route)) |
|
| 819 | + { |
|
| 820 | 820 | return false; |
| 821 | - } else { |
|
| 821 | + } else { |
|
| 822 | 822 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 823 | - } |
|
| 823 | + } |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | if ($altitude != "") |
| 827 | 827 | { |
| 828 | - $altitude_array = explode(",", $altitude); |
|
| 828 | + $altitude_array = explode(",", $altitude); |
|
| 829 | 829 | |
| 830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 832 | 832 | |
| 833 | 833 | |
| 834 | - if ($altitude_array[1] != "") |
|
| 835 | - { |
|
| 834 | + if ($altitude_array[1] != "") |
|
| 835 | + { |
|
| 836 | 836 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 837 | 837 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 838 | 838 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 839 | - } else { |
|
| 839 | + } else { |
|
| 840 | 840 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 841 | 841 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 842 | - } |
|
| 842 | + } |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | if ($date_posted != "") |
| 846 | 846 | { |
| 847 | - $date_array = explode(",", $date_posted); |
|
| 847 | + $date_array = explode(",", $date_posted); |
|
| 848 | 848 | |
| 849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 849 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 850 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 851 | 851 | |
| 852 | - if ($globalTimezone != '') { |
|
| 852 | + if ($globalTimezone != '') { |
|
| 853 | 853 | date_default_timezone_set($globalTimezone); |
| 854 | 854 | $datetime = new DateTime(); |
| 855 | 855 | $offset = $datetime->format('P'); |
| 856 | - } else $offset = '+00:00'; |
|
| 856 | + } else $offset = '+00:00'; |
|
| 857 | 857 | |
| 858 | 858 | |
| 859 | - if ($date_array[1] != "") |
|
| 860 | - { |
|
| 859 | + if ($date_array[1] != "") |
|
| 860 | + { |
|
| 861 | 861 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 862 | 862 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 863 | 863 | if ($globalDBdriver == 'mysql') { |
@@ -865,28 +865,28 @@ discard block |
||
| 865 | 865 | } else { |
| 866 | 866 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 867 | 867 | } |
| 868 | - } else { |
|
| 868 | + } else { |
|
| 869 | 869 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 870 | - if ($globalDBdriver == 'mysql') { |
|
| 870 | + if ($globalDBdriver == 'mysql') { |
|
| 871 | 871 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 872 | 872 | } else { |
| 873 | 873 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 874 | 874 | } |
| 875 | - } |
|
| 875 | + } |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | if ($limit != "") |
| 879 | 879 | { |
| 880 | - $limit_array = explode(",", $limit); |
|
| 880 | + $limit_array = explode(",", $limit); |
|
| 881 | 881 | |
| 882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 884 | 884 | |
| 885 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 886 | - { |
|
| 885 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 886 | + { |
|
| 887 | 887 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 888 | 888 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 889 | - } |
|
| 889 | + } |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | |
@@ -917,33 +917,33 @@ discard block |
||
| 917 | 917 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 918 | 918 | |
| 919 | 919 | return $spotter_array; |
| 920 | - } |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - public function deleteSpotterArchiveData() |
|
| 923 | - { |
|
| 922 | + public function deleteSpotterArchiveData() |
|
| 923 | + { |
|
| 924 | 924 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 925 | - date_default_timezone_set('UTC'); |
|
| 926 | - if ($globalDBdriver == 'mysql') { |
|
| 925 | + date_default_timezone_set('UTC'); |
|
| 926 | + if ($globalDBdriver == 'mysql') { |
|
| 927 | 927 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 928 | 928 | } else { |
| 929 | 929 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 930 | 930 | } |
| 931 | - try { |
|
| 932 | - $sth = $this->db->prepare($query); |
|
| 933 | - $sth->execute(); |
|
| 934 | - } catch(PDOException $e) { |
|
| 935 | - return "error"; |
|
| 936 | - } |
|
| 931 | + try { |
|
| 932 | + $sth = $this->db->prepare($query); |
|
| 933 | + $sth->execute(); |
|
| 934 | + } catch(PDOException $e) { |
|
| 935 | + return "error"; |
|
| 936 | + } |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - /** |
|
| 940 | - * Gets all the spotter information based on the callsign |
|
| 941 | - * |
|
| 942 | - * @return Array the spotter information |
|
| 943 | - * |
|
| 944 | - */ |
|
| 945 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 946 | - { |
|
| 939 | + /** |
|
| 940 | + * Gets all the spotter information based on the callsign |
|
| 941 | + * |
|
| 942 | + * @return Array the spotter information |
|
| 943 | + * |
|
| 944 | + */ |
|
| 945 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 946 | + { |
|
| 947 | 947 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 948 | 948 | |
| 949 | 949 | date_default_timezone_set('UTC'); |
@@ -955,35 +955,35 @@ discard block |
||
| 955 | 955 | |
| 956 | 956 | if ($ident != "") |
| 957 | 957 | { |
| 958 | - if (!is_string($ident)) |
|
| 959 | - { |
|
| 958 | + if (!is_string($ident)) |
|
| 959 | + { |
|
| 960 | 960 | return false; |
| 961 | - } else { |
|
| 961 | + } else { |
|
| 962 | 962 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 963 | 963 | $query_values = array(':ident' => $ident); |
| 964 | - } |
|
| 964 | + } |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | if ($limit != "") |
| 968 | 968 | { |
| 969 | - $limit_array = explode(",", $limit); |
|
| 969 | + $limit_array = explode(",", $limit); |
|
| 970 | 970 | |
| 971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 973 | 973 | |
| 974 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 975 | - { |
|
| 974 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 975 | + { |
|
| 976 | 976 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 977 | 977 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 978 | - } |
|
| 978 | + } |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | if ($sort != "") |
| 982 | 982 | { |
| 983 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 984 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 983 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 984 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 985 | 985 | } else { |
| 986 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 986 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -991,17 +991,17 @@ discard block |
||
| 991 | 991 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 992 | 992 | |
| 993 | 993 | return $spotter_array; |
| 994 | - } |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | |
| 997 | - /** |
|
| 998 | - * Gets all the spotter information based on the owner |
|
| 999 | - * |
|
| 1000 | - * @return Array the spotter information |
|
| 1001 | - * |
|
| 1002 | - */ |
|
| 1003 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1004 | - { |
|
| 997 | + /** |
|
| 998 | + * Gets all the spotter information based on the owner |
|
| 999 | + * |
|
| 1000 | + * @return Array the spotter information |
|
| 1001 | + * |
|
| 1002 | + */ |
|
| 1003 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1004 | + { |
|
| 1005 | 1005 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1006 | 1006 | |
| 1007 | 1007 | date_default_timezone_set('UTC'); |
@@ -1014,35 +1014,35 @@ discard block |
||
| 1014 | 1014 | |
| 1015 | 1015 | if ($owner != "") |
| 1016 | 1016 | { |
| 1017 | - if (!is_string($owner)) |
|
| 1018 | - { |
|
| 1017 | + if (!is_string($owner)) |
|
| 1018 | + { |
|
| 1019 | 1019 | return false; |
| 1020 | - } else { |
|
| 1020 | + } else { |
|
| 1021 | 1021 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1022 | 1022 | $query_values = array(':owner' => $owner); |
| 1023 | - } |
|
| 1023 | + } |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | if ($limit != "") |
| 1027 | 1027 | { |
| 1028 | - $limit_array = explode(",", $limit); |
|
| 1028 | + $limit_array = explode(",", $limit); |
|
| 1029 | 1029 | |
| 1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1032 | 1032 | |
| 1033 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1034 | - { |
|
| 1033 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1034 | + { |
|
| 1035 | 1035 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1036 | 1036 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1037 | - } |
|
| 1037 | + } |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | if ($sort != "") |
| 1041 | 1041 | { |
| 1042 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1043 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1042 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1043 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1044 | 1044 | } else { |
| 1045 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1045 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1050,16 +1050,16 @@ discard block |
||
| 1050 | 1050 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1051 | 1051 | |
| 1052 | 1052 | return $spotter_array; |
| 1053 | - } |
|
| 1054 | - |
|
| 1055 | - /** |
|
| 1056 | - * Gets all the spotter information based on the pilot |
|
| 1057 | - * |
|
| 1058 | - * @return Array the spotter information |
|
| 1059 | - * |
|
| 1060 | - */ |
|
| 1061 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1062 | - { |
|
| 1053 | + } |
|
| 1054 | + |
|
| 1055 | + /** |
|
| 1056 | + * Gets all the spotter information based on the pilot |
|
| 1057 | + * |
|
| 1058 | + * @return Array the spotter information |
|
| 1059 | + * |
|
| 1060 | + */ |
|
| 1061 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1062 | + { |
|
| 1063 | 1063 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1064 | 1064 | |
| 1065 | 1065 | date_default_timezone_set('UTC'); |
@@ -1078,24 +1078,24 @@ discard block |
||
| 1078 | 1078 | |
| 1079 | 1079 | if ($limit != "") |
| 1080 | 1080 | { |
| 1081 | - $limit_array = explode(",", $limit); |
|
| 1081 | + $limit_array = explode(",", $limit); |
|
| 1082 | 1082 | |
| 1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1085 | 1085 | |
| 1086 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1087 | - { |
|
| 1086 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1087 | + { |
|
| 1088 | 1088 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1089 | 1089 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1090 | - } |
|
| 1090 | + } |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | if ($sort != "") |
| 1094 | 1094 | { |
| 1095 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1096 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1095 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1096 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1097 | 1097 | } else { |
| 1098 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1098 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1103,16 +1103,16 @@ discard block |
||
| 1103 | 1103 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1104 | 1104 | |
| 1105 | 1105 | return $spotter_array; |
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - /** |
|
| 1109 | - * Gets all number of flight over countries |
|
| 1110 | - * |
|
| 1111 | - * @return Array the airline country list |
|
| 1112 | - * |
|
| 1113 | - */ |
|
| 1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1115 | - { |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + /** |
|
| 1109 | + * Gets all number of flight over countries |
|
| 1110 | + * |
|
| 1111 | + * @return Array the airline country list |
|
| 1112 | + * |
|
| 1113 | + */ |
|
| 1114 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1115 | + { |
|
| 1116 | 1116 | global $globalDBdriver; |
| 1117 | 1117 | /* |
| 1118 | 1118 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1122,14 +1122,14 @@ discard block |
||
| 1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1123 | 1123 | FROM countries c, spotter_archive s |
| 1124 | 1124 | WHERE c.iso2 = s.over_country "; |
| 1125 | - if ($olderthanmonths > 0) { |
|
| 1126 | - if ($globalDBdriver == 'mysql') { |
|
| 1125 | + if ($olderthanmonths > 0) { |
|
| 1126 | + if ($globalDBdriver == 'mysql') { |
|
| 1127 | 1127 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1128 | 1128 | } else { |
| 1129 | 1129 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1130 | 1130 | } |
| 1131 | 1131 | } |
| 1132 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1132 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1133 | 1133 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1134 | 1134 | if ($limit) $query .= " LIMIT 0,10"; |
| 1135 | 1135 | |
@@ -1142,23 +1142,23 @@ discard block |
||
| 1142 | 1142 | |
| 1143 | 1143 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1144 | 1144 | { |
| 1145 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1146 | - $temp_array['flight_country'] = $row['name']; |
|
| 1147 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1148 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1149 | - $flight_array[] = $temp_array; |
|
| 1145 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1146 | + $temp_array['flight_country'] = $row['name']; |
|
| 1147 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1148 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1149 | + $flight_array[] = $temp_array; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | return $flight_array; |
| 1152 | - } |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * Gets all number of flight over countries |
|
| 1156 | - * |
|
| 1157 | - * @return Array the airline country list |
|
| 1158 | - * |
|
| 1159 | - */ |
|
| 1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1161 | - { |
|
| 1152 | + } |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * Gets all number of flight over countries |
|
| 1156 | + * |
|
| 1157 | + * @return Array the airline country list |
|
| 1158 | + * |
|
| 1159 | + */ |
|
| 1160 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1161 | + { |
|
| 1162 | 1162 | global $globalDBdriver; |
| 1163 | 1163 | /* |
| 1164 | 1164 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1168,14 +1168,14 @@ discard block |
||
| 1168 | 1168 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1169 | 1169 | FROM countries c, spotter_archive s, spotter_output o |
| 1170 | 1170 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1171 | - if ($olderthanmonths > 0) { |
|
| 1172 | - if ($globalDBdriver == 'mysql') { |
|
| 1171 | + if ($olderthanmonths > 0) { |
|
| 1172 | + if ($globalDBdriver == 'mysql') { |
|
| 1173 | 1173 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1174 | 1174 | } else { |
| 1175 | 1175 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1178 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1179 | 1179 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1180 | 1180 | if ($limit) $query .= " LIMIT 0,10"; |
| 1181 | 1181 | |
@@ -1188,24 +1188,24 @@ discard block |
||
| 1188 | 1188 | |
| 1189 | 1189 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1190 | 1190 | { |
| 1191 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1192 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1193 | - $temp_array['flight_country'] = $row['name']; |
|
| 1194 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1195 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1196 | - $flight_array[] = $temp_array; |
|
| 1191 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1192 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1193 | + $temp_array['flight_country'] = $row['name']; |
|
| 1194 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1195 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1196 | + $flight_array[] = $temp_array; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | return $flight_array; |
| 1199 | - } |
|
| 1200 | - |
|
| 1201 | - /** |
|
| 1202 | - * Gets last spotter information based on a particular callsign |
|
| 1203 | - * |
|
| 1204 | - * @return Array the spotter information |
|
| 1205 | - * |
|
| 1206 | - */ |
|
| 1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1208 | - { |
|
| 1199 | + } |
|
| 1200 | + |
|
| 1201 | + /** |
|
| 1202 | + * Gets last spotter information based on a particular callsign |
|
| 1203 | + * |
|
| 1204 | + * @return Array the spotter information |
|
| 1205 | + * |
|
| 1206 | + */ |
|
| 1207 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1208 | + { |
|
| 1209 | 1209 | $Spotter = new Spotter($this->db); |
| 1210 | 1210 | date_default_timezone_set('UTC'); |
| 1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1213,16 +1213,16 @@ discard block |
||
| 1213 | 1213 | $date = date('c',$date); |
| 1214 | 1214 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1215 | 1215 | return $spotter_array; |
| 1216 | - } |
|
| 1217 | - |
|
| 1218 | - /** |
|
| 1219 | - * Gets all the spotter information based on a particular callsign |
|
| 1220 | - * |
|
| 1221 | - * @return Array the spotter information |
|
| 1222 | - * |
|
| 1223 | - */ |
|
| 1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1225 | - { |
|
| 1216 | + } |
|
| 1217 | + |
|
| 1218 | + /** |
|
| 1219 | + * Gets all the spotter information based on a particular callsign |
|
| 1220 | + * |
|
| 1221 | + * @return Array the spotter information |
|
| 1222 | + * |
|
| 1223 | + */ |
|
| 1224 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1225 | + { |
|
| 1226 | 1226 | $Spotter = new Spotter($this->db); |
| 1227 | 1227 | date_default_timezone_set('UTC'); |
| 1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1230,16 +1230,16 @@ discard block |
||
| 1230 | 1230 | $date = date('c',$date); |
| 1231 | 1231 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1232 | 1232 | return $spotter_array; |
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Gets all the spotter information based on the airport |
|
| 1237 | - * |
|
| 1238 | - * @return Array the spotter information |
|
| 1239 | - * |
|
| 1240 | - */ |
|
| 1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1242 | - { |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * Gets all the spotter information based on the airport |
|
| 1237 | + * |
|
| 1238 | + * @return Array the spotter information |
|
| 1239 | + * |
|
| 1240 | + */ |
|
| 1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1242 | + { |
|
| 1243 | 1243 | global $global_query; |
| 1244 | 1244 | $Spotter = new Spotter(); |
| 1245 | 1245 | date_default_timezone_set('UTC'); |
@@ -1250,35 +1250,35 @@ discard block |
||
| 1250 | 1250 | |
| 1251 | 1251 | if ($airport != "") |
| 1252 | 1252 | { |
| 1253 | - if (!is_string($airport)) |
|
| 1254 | - { |
|
| 1253 | + if (!is_string($airport)) |
|
| 1254 | + { |
|
| 1255 | 1255 | return false; |
| 1256 | - } else { |
|
| 1256 | + } else { |
|
| 1257 | 1257 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1258 | 1258 | $query_values = array(':airport' => $airport); |
| 1259 | - } |
|
| 1259 | + } |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | if ($limit != "") |
| 1263 | 1263 | { |
| 1264 | - $limit_array = explode(",", $limit); |
|
| 1264 | + $limit_array = explode(",", $limit); |
|
| 1265 | 1265 | |
| 1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1268 | 1268 | |
| 1269 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1270 | - { |
|
| 1269 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1270 | + { |
|
| 1271 | 1271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1272 | 1272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1273 | - } |
|
| 1273 | + } |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | if ($sort != "") |
| 1277 | 1277 | { |
| 1278 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1279 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1278 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1279 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1280 | 1280 | } else { |
| 1281 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1281 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | 1284 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1286,6 +1286,6 @@ discard block |
||
| 1286 | 1286 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1287 | 1287 | |
| 1288 | 1288 | return $spotter_array; |
| 1289 | - } |
|
| 1289 | + } |
|
| 1290 | 1290 | } |
| 1291 | 1291 | ?> |
| 1292 | 1292 | \ No newline at end of file |
@@ -13,62 +13,62 @@ discard block |
||
| 13 | 13 | * @param Array $filter the filter |
| 14 | 14 | * @return Array the SQL part |
| 15 | 15 | */ |
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 18 | 18 | $filters = array(); |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
| 22 | 22 | } else { |
| 23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | if (isset($filter[0]['source'])) { |
| 27 | - $filters = array_merge($filters,$filter); |
|
| 27 | + $filters = array_merge($filters, $filter); |
|
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | - foreach($filters as $flt) { |
|
| 32 | + foreach ($filters as $flt) { |
|
| 33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 34 | 34 | if ($flt['airlines'][0] != '') { |
| 35 | 35 | if (isset($flt['source'])) { |
| 36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 43 | 43 | if (isset($flt['source'])) { |
| 44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | 45 | } else { |
| 46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 50 | 50 | if (isset($flt['source'])) { |
| 51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | 52 | } else { |
| 53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 57 | 57 | if (isset($flt['source'])) { |
| 58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | 59 | } else { |
| 60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 64 | 64 | if (isset($flt['source'])) { |
| 65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 70 | 70 | if ($filter['airlines'][0] != '') { |
| 71 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 71 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | 80 | } |
| 81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 89 | 89 | } |
| 90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 91 | 91 | $filter_query_date = ''; |
@@ -111,41 +111,41 @@ discard block |
||
| 111 | 111 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | 115 | } |
| 116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 118 | 118 | if ($filter_query_where != '') { |
| 119 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 119 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 120 | 120 | } |
| 121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
| 122 | 122 | return $filter_query; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Spotter_archive |
| 126 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 126 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 127 | 127 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 128 | 128 | if ($over_country == '') { |
| 129 | 129 | $Spotter = new Spotter($this->db); |
| 130 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 130 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 131 | 131 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 132 | 132 | else $country = ''; |
| 133 | 133 | } else $country = $over_country; |
| 134 | - if ($airline_type === NULL) $airline_type =''; |
|
| 134 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 135 | 135 | |
| 136 | 136 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 137 | 137 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 138 | 138 | |
| 139 | 139 | // Route is not added in spotter_archive |
| 140 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 140 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
| 141 | 141 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
| 142 | 142 | |
| 143 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 143 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 144 | 144 | try { |
| 145 | 145 | $sth = $this->db->prepare($query); |
| 146 | 146 | $sth->execute($query_values); |
| 147 | 147 | $sth->closeCursor(); |
| 148 | - } catch(PDOException $e) { |
|
| 148 | + } catch (PDOException $e) { |
|
| 149 | 149 | return "error : ".$e->getMessage(); |
| 150 | 150 | } |
| 151 | 151 | return "success"; |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 167 | 167 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 169 | 169 | |
| 170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 170 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 171 | 171 | |
| 172 | 172 | return $spotter_array; |
| 173 | 173 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 187 | 187 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 188 | 188 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 190 | 190 | |
| 191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 192 | 192 | /* |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 201 | 201 | */ |
| 202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 202 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 203 | 203 | |
| 204 | 204 | return $spotter_array; |
| 205 | 205 | } |
@@ -214,14 +214,14 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | date_default_timezone_set('UTC'); |
| 216 | 216 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 218 | 218 | |
| 219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 220 | 220 | |
| 221 | 221 | try { |
| 222 | 222 | $sth = $this->db->prepare($query); |
| 223 | 223 | $sth->execute(array(':id' => $id)); |
| 224 | - } catch(PDOException $e) { |
|
| 224 | + } catch (PDOException $e) { |
|
| 225 | 225 | echo $e->getMessage(); |
| 226 | 226 | die; |
| 227 | 227 | } |
@@ -240,14 +240,14 @@ discard block |
||
| 240 | 240 | { |
| 241 | 241 | date_default_timezone_set('UTC'); |
| 242 | 242 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 244 | 244 | |
| 245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 246 | 246 | |
| 247 | 247 | try { |
| 248 | 248 | $sth = $this->db->prepare($query); |
| 249 | 249 | $sth->execute(array(':id' => $id)); |
| 250 | - } catch(PDOException $e) { |
|
| 250 | + } catch (PDOException $e) { |
|
| 251 | 251 | echo $e->getMessage(); |
| 252 | 252 | die; |
| 253 | 253 | } |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | date_default_timezone_set('UTC'); |
| 270 | 270 | |
| 271 | 271 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 273 | 273 | |
| 274 | 274 | try { |
| 275 | 275 | $sth = $this->db->prepare($query); |
| 276 | 276 | $sth->execute(array(':ident' => $ident)); |
| 277 | - } catch(PDOException $e) { |
|
| 277 | + } catch (PDOException $e) { |
|
| 278 | 278 | echo $e->getMessage(); |
| 279 | 279 | die; |
| 280 | 280 | } |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | date_default_timezone_set('UTC'); |
| 296 | 296 | |
| 297 | 297 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 299 | 299 | |
| 300 | 300 | try { |
| 301 | 301 | $sth = $this->db->prepare($query); |
| 302 | 302 | $sth->execute(array(':id' => $id)); |
| 303 | - } catch(PDOException $e) { |
|
| 303 | + } catch (PDOException $e) { |
|
| 304 | 304 | echo $e->getMessage(); |
| 305 | 305 | die; |
| 306 | 306 | } |
@@ -321,12 +321,12 @@ discard block |
||
| 321 | 321 | date_default_timezone_set('UTC'); |
| 322 | 322 | |
| 323 | 323 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 325 | 325 | |
| 326 | 326 | try { |
| 327 | 327 | $sth = $this->db->prepare($query); |
| 328 | 328 | $sth->execute(array(':id' => $id)); |
| 329 | - } catch(PDOException $e) { |
|
| 329 | + } catch (PDOException $e) { |
|
| 330 | 330 | echo $e->getMessage(); |
| 331 | 331 | die; |
| 332 | 332 | } |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | date_default_timezone_set('UTC'); |
| 349 | 349 | |
| 350 | 350 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 353 | 353 | |
| 354 | 354 | try { |
| 355 | 355 | $sth = $this->db->prepare($query); |
| 356 | 356 | $sth->execute(array(':ident' => $ident)); |
| 357 | - } catch(PDOException $e) { |
|
| 357 | + } catch (PDOException $e) { |
|
| 358 | 358 | echo $e->getMessage(); |
| 359 | 359 | die; |
| 360 | 360 | } |
@@ -371,13 +371,13 @@ discard block |
||
| 371 | 371 | * @return Array the spotter information |
| 372 | 372 | * |
| 373 | 373 | */ |
| 374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 374 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 375 | 375 | { |
| 376 | 376 | $Spotter = new Spotter($this->db); |
| 377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 379 | 379 | |
| 380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 380 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 381 | 381 | |
| 382 | 382 | return $spotter_array; |
| 383 | 383 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | try { |
| 391 | 391 | $sth = $this->db->prepare($query); |
| 392 | 392 | $sth->execute(); |
| 393 | - } catch(PDOException $e) { |
|
| 393 | + } catch (PDOException $e) { |
|
| 394 | 394 | echo $e->getMessage(); |
| 395 | 395 | die; |
| 396 | 396 | } |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @return Array the spotter information |
| 403 | 403 | * |
| 404 | 404 | */ |
| 405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 405 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 406 | 406 | { |
| 407 | 407 | global $globalDBdriver, $globalLiveInterval; |
| 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 flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 417 | 417 | } |
| 418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 419 | 419 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 420 | 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.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 439 | 439 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM spotter_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
| 446 | 446 | } else { |
| 447 | 447 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM spotter_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -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 | } |
@@ -470,24 +470,24 @@ discard block |
||
| 470 | 470 | * @return Array the spotter information |
| 471 | 471 | * |
| 472 | 472 | */ |
| 473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 473 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 474 | 474 | { |
| 475 | 475 | global $globalDBdriver, $globalLiveInterval; |
| 476 | 476 | date_default_timezone_set('UTC'); |
| 477 | 477 | |
| 478 | 478 | $filter_query = ''; |
| 479 | 479 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 480 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 481 | 481 | } |
| 482 | 482 | // Should use spotter_output also ? |
| 483 | 483 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 485 | 485 | } |
| 486 | 486 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 487 | 487 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 488 | 488 | } |
| 489 | 489 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | FROM spotter_archive |
| 498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 499 | 499 | */ |
| 500 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 500 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 501 | 501 | FROM spotter_archive_output |
| 502 | 502 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 514 | 514 | */ |
| 515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 516 | 516 | FROM spotter_archive_output |
| 517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | try { |
| 525 | 525 | $sth = $this->db->prepare($query); |
| 526 | 526 | $sth->execute(); |
| 527 | - } catch(PDOException $e) { |
|
| 527 | + } catch (PDOException $e) { |
|
| 528 | 528 | echo $e->getMessage(); |
| 529 | 529 | die; |
| 530 | 530 | } |
@@ -539,23 +539,23 @@ discard block |
||
| 539 | 539 | * @return Array the spotter information |
| 540 | 540 | * |
| 541 | 541 | */ |
| 542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 542 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 543 | 543 | { |
| 544 | 544 | global $globalDBdriver, $globalLiveInterval; |
| 545 | 545 | date_default_timezone_set('UTC'); |
| 546 | 546 | |
| 547 | 547 | $filter_query = ''; |
| 548 | 548 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 549 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 550 | 550 | } |
| 551 | 551 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 553 | 553 | } |
| 554 | 554 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 555 | 555 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 556 | 556 | } |
| 557 | 557 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | try { |
| 571 | 571 | $sth = $this->db->prepare($query); |
| 572 | 572 | $sth->execute(); |
| 573 | - } catch(PDOException $e) { |
|
| 573 | + } catch (PDOException $e) { |
|
| 574 | 574 | echo $e->getMessage(); |
| 575 | 575 | die; |
| 576 | 576 | } |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @return Array the spotter information |
| 591 | 591 | * |
| 592 | 592 | */ |
| 593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 594 | 594 | { |
| 595 | 595 | global $globalTimezone, $globalDBdriver; |
| 596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | $q_array = explode(" ", $q); |
| 614 | 614 | |
| 615 | - foreach ($q_array as $q_item){ |
|
| 615 | + foreach ($q_array as $q_item) { |
|
| 616 | 616 | $additional_query .= " AND ("; |
| 617 | 617 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 618 | 618 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | if ($registration != "") |
| 646 | 646 | { |
| 647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 647 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 648 | 648 | if (!is_string($registration)) |
| 649 | 649 | { |
| 650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | if ($aircraft_icao != "") |
| 657 | 657 | { |
| 658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 658 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 659 | 659 | if (!is_string($aircraft_icao)) |
| 660 | 660 | { |
| 661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | if ($aircraft_manufacturer != "") |
| 668 | 668 | { |
| 669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 670 | 670 | if (!is_string($aircraft_manufacturer)) |
| 671 | 671 | { |
| 672 | 672 | return false; |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | if ($airline_icao != "") |
| 689 | 689 | { |
| 690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 690 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 691 | 691 | if (!is_string($airline_icao)) |
| 692 | 692 | { |
| 693 | 693 | return false; |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | if ($airline_country != "") |
| 700 | 700 | { |
| 701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 701 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 702 | 702 | if (!is_string($airline_country)) |
| 703 | 703 | { |
| 704 | 704 | return false; |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | if ($airline_type != "") |
| 711 | 711 | { |
| 712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 712 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 713 | 713 | if (!is_string($airline_type)) |
| 714 | 714 | { |
| 715 | 715 | return false; |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | if ($airport != "") |
| 733 | 733 | { |
| 734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 734 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 735 | 735 | if (!is_string($airport)) |
| 736 | 736 | { |
| 737 | 737 | return false; |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | if ($airport_country != "") |
| 744 | 744 | { |
| 745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 745 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 746 | 746 | if (!is_string($airport_country)) |
| 747 | 747 | { |
| 748 | 748 | return false; |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | if ($callsign != "") |
| 755 | 755 | { |
| 756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 756 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 757 | 757 | if (!is_string($callsign)) |
| 758 | 758 | { |
| 759 | 759 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $translate = $Translation->ident2icao($callsign); |
| 762 | 762 | if ($translate != $callsign) { |
| 763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 764 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 764 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 765 | 765 | } else { |
| 766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 767 | 767 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | if ($owner != "") |
| 772 | 772 | { |
| 773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 773 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 774 | 774 | if (!is_string($owner)) |
| 775 | 775 | { |
| 776 | 776 | return false; |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | if ($pilot_name != "") |
| 783 | 783 | { |
| 784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 784 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 785 | 785 | if (!is_string($pilot_name)) |
| 786 | 786 | { |
| 787 | 787 | return false; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | if ($pilot_id != "") |
| 794 | 794 | { |
| 795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 795 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 796 | 796 | if (!is_string($pilot_id)) |
| 797 | 797 | { |
| 798 | 798 | return false; |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | if ($departure_airport_route != "") |
| 805 | 805 | { |
| 806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 806 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 807 | 807 | if (!is_string($departure_airport_route)) |
| 808 | 808 | { |
| 809 | 809 | return false; |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | |
| 815 | 815 | if ($arrival_airport_route != "") |
| 816 | 816 | { |
| 817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 817 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 818 | 818 | if (!is_string($arrival_airport_route)) |
| 819 | 819 | { |
| 820 | 820 | return false; |
@@ -827,8 +827,8 @@ discard block |
||
| 827 | 827 | { |
| 828 | 828 | $altitude_array = explode(",", $altitude); |
| 829 | 829 | |
| 830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 830 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 831 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 832 | 832 | |
| 833 | 833 | |
| 834 | 834 | if ($altitude_array[1] != "") |
@@ -846,8 +846,8 @@ discard block |
||
| 846 | 846 | { |
| 847 | 847 | $date_array = explode(",", $date_posted); |
| 848 | 848 | |
| 849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 849 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 850 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 851 | 851 | |
| 852 | 852 | if ($globalTimezone != '') { |
| 853 | 853 | date_default_timezone_set($globalTimezone); |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | { |
| 880 | 880 | $limit_array = explode(",", $limit); |
| 881 | 881 | |
| 882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 884 | 884 | |
| 885 | 885 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 886 | 886 | { |
@@ -891,8 +891,8 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | |
| 893 | 893 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 894 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 895 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 894 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 895 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 896 | 896 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 897 | 897 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 898 | 898 | } else { |
@@ -909,12 +909,12 @@ discard block |
||
| 909 | 909 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 912 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 913 | 913 | WHERE spotter_archive_output.ident <> '' |
| 914 | 914 | ".$additional_query." |
| 915 | 915 | ".$filter_query.$orderby_query; |
| 916 | 916 | } |
| 917 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 917 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 918 | 918 | |
| 919 | 919 | return $spotter_array; |
| 920 | 920 | } |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | try { |
| 932 | 932 | $sth = $this->db->prepare($query); |
| 933 | 933 | $sth->execute(); |
| 934 | - } catch(PDOException $e) { |
|
| 934 | + } catch (PDOException $e) { |
|
| 935 | 935 | return "error"; |
| 936 | 936 | } |
| 937 | 937 | } |
@@ -968,8 +968,8 @@ discard block |
||
| 968 | 968 | { |
| 969 | 969 | $limit_array = explode(",", $limit); |
| 970 | 970 | |
| 971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 971 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 972 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 973 | 973 | |
| 974 | 974 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 975 | 975 | { |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | $query_values = array(); |
| 1011 | 1011 | $limit_query = ''; |
| 1012 | 1012 | $additional_query = ''; |
| 1013 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1013 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1014 | 1014 | |
| 1015 | 1015 | if ($owner != "") |
| 1016 | 1016 | { |
@@ -1027,8 +1027,8 @@ discard block |
||
| 1027 | 1027 | { |
| 1028 | 1028 | $limit_array = explode(",", $limit); |
| 1029 | 1029 | |
| 1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1030 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1031 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1032 | 1032 | |
| 1033 | 1033 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1034 | 1034 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | $query_values = array(); |
| 1069 | 1069 | $limit_query = ''; |
| 1070 | 1070 | $additional_query = ''; |
| 1071 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1071 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1072 | 1072 | |
| 1073 | 1073 | if ($pilot != "") |
| 1074 | 1074 | { |
@@ -1080,8 +1080,8 @@ discard block |
||
| 1080 | 1080 | { |
| 1081 | 1081 | $limit_array = explode(",", $limit); |
| 1082 | 1082 | |
| 1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1083 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1084 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1085 | 1085 | |
| 1086 | 1086 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1087 | 1087 | { |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | * @return Array the airline country list |
| 1112 | 1112 | * |
| 1113 | 1113 | */ |
| 1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1114 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1115 | 1115 | { |
| 1116 | 1116 | global $globalDBdriver; |
| 1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | $flight_array = array(); |
| 1141 | 1141 | $temp_array = array(); |
| 1142 | 1142 | |
| 1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1144 | 1144 | { |
| 1145 | 1145 | $temp_array['flight_count'] = $row['nb']; |
| 1146 | 1146 | $temp_array['flight_country'] = $row['name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | * @return Array the airline country list |
| 1158 | 1158 | * |
| 1159 | 1159 | */ |
| 1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1160 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1161 | 1161 | { |
| 1162 | 1162 | global $globalDBdriver; |
| 1163 | 1163 | /* |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | $flight_array = array(); |
| 1187 | 1187 | $temp_array = array(); |
| 1188 | 1188 | |
| 1189 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1189 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1190 | 1190 | { |
| 1191 | 1191 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1192 | 1192 | $temp_array['flight_count'] = $row['nb']; |
@@ -1204,14 +1204,14 @@ discard block |
||
| 1204 | 1204 | * @return Array the spotter information |
| 1205 | 1205 | * |
| 1206 | 1206 | */ |
| 1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1207 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1208 | 1208 | { |
| 1209 | 1209 | $Spotter = new Spotter($this->db); |
| 1210 | 1210 | date_default_timezone_set('UTC'); |
| 1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1212 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1213 | - $date = date('c',$date); |
|
| 1214 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1212 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1213 | + $date = date('c', $date); |
|
| 1214 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1215 | 1215 | return $spotter_array; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
@@ -1221,14 +1221,14 @@ discard block |
||
| 1221 | 1221 | * @return Array the spotter information |
| 1222 | 1222 | * |
| 1223 | 1223 | */ |
| 1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1224 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1225 | 1225 | { |
| 1226 | 1226 | $Spotter = new Spotter($this->db); |
| 1227 | 1227 | date_default_timezone_set('UTC'); |
| 1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1229 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1230 | - $date = date('c',$date); |
|
| 1231 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1229 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1230 | + $date = date('c', $date); |
|
| 1231 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1232 | 1232 | return $spotter_array; |
| 1233 | 1233 | } |
| 1234 | 1234 | |
@@ -1238,7 +1238,7 @@ discard block |
||
| 1238 | 1238 | * @return Array the spotter information |
| 1239 | 1239 | * |
| 1240 | 1240 | */ |
| 1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1242 | 1242 | { |
| 1243 | 1243 | global $global_query; |
| 1244 | 1244 | $Spotter = new Spotter(); |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | $query_values = array(); |
| 1247 | 1247 | $limit_query = ''; |
| 1248 | 1248 | $additional_query = ''; |
| 1249 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1249 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1250 | 1250 | |
| 1251 | 1251 | if ($airport != "") |
| 1252 | 1252 | { |
@@ -1263,8 +1263,8 @@ discard block |
||
| 1263 | 1263 | { |
| 1264 | 1264 | $limit_array = explode(",", $limit); |
| 1265 | 1265 | |
| 1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1266 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1267 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1268 | 1268 | |
| 1269 | 1269 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1270 | 1270 | { |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class MarineImport { |
| 16 | - private $all_tracked = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_tracked = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
| 27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 28 | - $Connection = new Connection($dbc); |
|
| 29 | - $this->db = $Connection->db(); |
|
| 30 | - date_default_timezone_set('UTC'); |
|
| 28 | + $Connection = new Connection($dbc); |
|
| 29 | + $this->db = $Connection->db(); |
|
| 30 | + date_default_timezone_set('UTC'); |
|
| 31 | 31 | } |
| 32 | 32 | // Get previous source stats |
| 33 | 33 | /* |
@@ -46,55 +46,55 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | */ |
| 48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 49 | - $APRSMarine = new APRSMarine(); |
|
| 50 | - //$APRSSpotter->connect(); |
|
| 49 | + $APRSMarine = new APRSMarine(); |
|
| 50 | + //$APRSSpotter->connect(); |
|
| 51 | + } |
|
| 51 | 52 | } |
| 52 | - } |
|
| 53 | 53 | |
| 54 | - public function checkAll() { |
|
| 54 | + public function checkAll() { |
|
| 55 | 55 | global $globalDebug; |
| 56 | 56 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
| 57 | 57 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 58 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 60 | - $Marine = new Marine($this->db); |
|
| 61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 62 | - } |
|
| 60 | + $Marine = new Marine($this->db); |
|
| 61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 62 | + } |
|
| 63 | + } |
|
| 63 | 64 | } |
| 64 | - } |
|
| 65 | 65 | |
| 66 | - public function del() { |
|
| 66 | + public function del() { |
|
| 67 | 67 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 68 | // Delete old infos |
| 69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | - if (isset($flight['lastupdate'])) { |
|
| 72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 73 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 74 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 76 | - /* |
|
| 71 | + if (isset($flight['lastupdate'])) { |
|
| 72 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 73 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 74 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 75 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 76 | + /* |
|
| 77 | 77 | $MarineLive = new MarineLive(); |
| 78 | 78 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 79 | 79 | $MarineLive->db = null; |
| 80 | 80 | */ |
| 81 | - //$real_arrival = $this->arrival($key); |
|
| 82 | - $Marine = new Marine($this->db); |
|
| 83 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 81 | + //$real_arrival = $this->arrival($key); |
|
| 82 | + $Marine = new Marine($this->db); |
|
| 83 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 84 | 84 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 86 | - } |
|
| 87 | - // Put in archive |
|
| 86 | + } |
|
| 87 | + // Put in archive |
|
| 88 | 88 | // $Marine->db = null; |
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - unset($this->all_tracked[$key]); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 90 | + } |
|
| 91 | + unset($this->all_tracked[$key]); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function add($line) { |
|
| 97 | + public function add($line) { |
|
| 98 | 98 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 100 | 100 | date_default_timezone_set('UTC'); |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // SBS format is CSV format |
| 105 | 105 | if(is_array($line) && isset($line['mmsi'])) { |
| 106 | - //print_r($line); |
|
| 107 | - if (isset($line['mmsi'])) { |
|
| 106 | + //print_r($line); |
|
| 107 | + if (isset($line['mmsi'])) { |
|
| 108 | 108 | |
| 109 | 109 | /* |
| 110 | 110 | // Increment message number |
@@ -121,64 +121,64 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $Common = new Common(); |
| 123 | 123 | $AIS = new AIS(); |
| 124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | - else $id = trim($line['id']); |
|
| 124 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | + else $id = trim($line['id']); |
|
| 126 | 126 | |
| 127 | 127 | if (!isset($this->all_tracked[$id])) { |
| 128 | - $this->all_tracked[$id] = array(); |
|
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 132 | - if (!isset($line['id'])) { |
|
| 128 | + $this->all_tracked[$id] = array(); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 132 | + if (!isset($line['id'])) { |
|
| 133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 134 | 134 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 141 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 141 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 142 | 142 | $Marine = new Marine($this->db); |
| 143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
| 144 | 144 | if (!empty($identity)) { |
| 145 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 146 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 145 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 146 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 147 | 147 | } |
| 148 | 148 | //print_r($identity); |
| 149 | 149 | unset($Marine); |
| 150 | 150 | //$dataFound = true; |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 158 | 158 | } |
| 159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 161 | 161 | } |
| 162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 170 | 170 | } |
| 171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 179 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 179 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 181 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 181 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 182 | 182 | $timeelapsed = microtime(true); |
| 183 | 183 | $Marine = new Marine($this->db); |
| 184 | 184 | $fromsource = NULL; |
@@ -186,20 +186,20 @@ discard block |
||
| 186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 187 | 187 | $Marine->db = null; |
| 188 | 188 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | } |
| 191 | - } |
|
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 191 | + } |
|
| 192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 196 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 196 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 197 | 197 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 198 | - } else { |
|
| 198 | + } else { |
|
| 199 | 199 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 200 | 200 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 201 | 201 | return ''; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 204 | 204 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 205 | 205 | return ''; |
@@ -216,24 +216,24 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | if (isset($line['speed']) && $line['speed'] != '') { |
| 219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 221 | 221 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 222 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 223 | - if ($distance > 1000 && $distance < 10000) { |
|
| 222 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 223 | + if ($distance > 1000 && $distance < 10000) { |
|
| 224 | 224 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 225 | 225 | $speed = $speed*3.6; |
| 226 | 226 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 227 | 227 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 233 | - else unset($timediff); |
|
| 234 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 231 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 232 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 233 | + else unset($timediff); |
|
| 234 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 235 | 235 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 236 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 236 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 237 | 237 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 238 | 238 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 239 | 239 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -241,123 +241,123 @@ discard block |
||
| 241 | 241 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 242 | 242 | $timeelapsed = microtime(true); |
| 243 | 243 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 244 | - $Marine = new Marine($this->db); |
|
| 245 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 246 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 247 | - $Marine->db = null; |
|
| 248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 244 | + $Marine = new Marine($this->db); |
|
| 245 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 246 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 247 | + $Marine->db = null; |
|
| 248 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 249 | 249 | } |
| 250 | 250 | $this->tmd = 0; |
| 251 | 251 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 256 | 256 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 257 | 257 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 258 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 259 | - $dataFound = true; |
|
| 260 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 258 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 259 | + $dataFound = true; |
|
| 260 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 261 | 261 | } |
| 262 | 262 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 263 | 263 | } |
| 264 | 264 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 265 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 265 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 266 | 266 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 267 | 267 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 268 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 269 | - $dataFound = true; |
|
| 270 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 268 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 269 | + $dataFound = true; |
|
| 270 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 271 | 271 | } |
| 272 | 272 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - } else if ($globalDebug && $timediff > 20) { |
|
| 275 | + } else if ($globalDebug && $timediff > 20) { |
|
| 276 | 276 | $this->tmd = $this->tmd + 1; |
| 277 | 277 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 278 | 278 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 279 | 279 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 280 | 280 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 281 | - } |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 284 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 284 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 286 | 286 | } |
| 287 | 287 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 289 | 289 | } |
| 290 | 290 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 292 | 292 | } |
| 293 | 293 | if (isset($line['status']) && $line['status'] != '') { |
| 294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if (isset($line['heading']) && $line['heading'] != '') { |
| 302 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 303 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 304 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 305 | - //$dataFound = true; |
|
| 302 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 303 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 304 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 305 | + //$dataFound = true; |
|
| 306 | 306 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 307 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 308 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 309 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 310 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 307 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 308 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 309 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 310 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 311 | 311 | } |
| 312 | 312 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | |
| 316 | 316 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 317 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 318 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 319 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 320 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 317 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 318 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 319 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 320 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 321 | 321 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 322 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 323 | - $timeelapsed = microtime(true); |
|
| 324 | - $MarineLive = new MarineLive($this->db); |
|
| 325 | - if (isset($line['id'])) { |
|
| 322 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 323 | + $timeelapsed = microtime(true); |
|
| 324 | + $MarineLive = new MarineLive($this->db); |
|
| 325 | + if (isset($line['id'])) { |
|
| 326 | 326 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 327 | 327 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 328 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 328 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 329 | 329 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 330 | 330 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 331 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 331 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 332 | 332 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 333 | 333 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 334 | - } else $recent_ident = ''; |
|
| 335 | - $MarineLive->db=null; |
|
| 336 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 337 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 334 | + } else $recent_ident = ''; |
|
| 335 | + $MarineLive->db=null; |
|
| 336 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 337 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 338 | 338 | } else $recent_ident = ''; |
| 339 | - } else { |
|
| 339 | + } else { |
|
| 340 | 340 | $recent_ident = ''; |
| 341 | 341 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 342 | - } |
|
| 343 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 344 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 345 | - { |
|
| 342 | + } |
|
| 343 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 344 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 345 | + { |
|
| 346 | 346 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 347 | 347 | //adds the spotter data for the archive |
| 348 | - $highlight = ''; |
|
| 349 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 350 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 348 | + $highlight = ''; |
|
| 349 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 350 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 351 | 351 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 352 | - $timeelapsed = microtime(true); |
|
| 353 | - $Marine = new Marine($this->db); |
|
| 354 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 355 | - $Marine->db = null; |
|
| 356 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 357 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 352 | + $timeelapsed = microtime(true); |
|
| 353 | + $Marine = new Marine($this->db); |
|
| 354 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 355 | + $Marine->db = null; |
|
| 356 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 358 | 358 | } |
| 359 | - } |
|
| 360 | - /* |
|
| 359 | + } |
|
| 360 | + /* |
|
| 361 | 361 | // Add source stat in DB |
| 362 | 362 | $Stats = new Stats($this->db); |
| 363 | 363 | if (!empty($this->stats)) { |
@@ -384,56 +384,56 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | $Stats->db = null; |
| 386 | 386 | */ |
| 387 | - $this->del(); |
|
| 387 | + $this->del(); |
|
| 388 | 388 | //$ignoreImport = false; |
| 389 | 389 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 390 | 390 | //print_r($this->all_tracked[$id]); |
| 391 | 391 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 392 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 393 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 394 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 392 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 393 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 394 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 395 | 395 | $MarineLive = new MarineLive($this->db); |
| 396 | 396 | $MarineLive->deleteLiveMarineData(); |
| 397 | 397 | $MarineLive->db=null; |
| 398 | 398 | if ($globalDebug) echo " Done\n"; |
| 399 | - } |
|
| 400 | - $this->last_delete = time(); |
|
| 399 | + } |
|
| 400 | + $this->last_delete = time(); |
|
| 401 | 401 | } |
| 402 | - } elseif ($recent_ident != '') { |
|
| 402 | + } elseif ($recent_ident != '') { |
|
| 403 | 403 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 404 | 404 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 405 | 405 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 406 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
| 406 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
| 407 | 407 | $Marine = new Marine($this->db); |
| 408 | 408 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
| 409 | 409 | $Marine->db = null; |
| 410 | - } |
|
| 410 | + } |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | } |
| 415 | - } |
|
| 416 | - //adds the spotter LIVE data |
|
| 417 | - if ($globalDebug) { |
|
| 415 | + } |
|
| 416 | + //adds the spotter LIVE data |
|
| 417 | + if ($globalDebug) { |
|
| 418 | 418 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 419 | - } |
|
| 420 | - $ignoreImport = false; |
|
| 419 | + } |
|
| 420 | + $ignoreImport = false; |
|
| 421 | 421 | |
| 422 | - if (!$ignoreImport) { |
|
| 422 | + if (!$ignoreImport) { |
|
| 423 | 423 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 424 | 424 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 425 | 425 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 426 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 426 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 427 | 427 | $timeelapsed = microtime(true); |
| 428 | 428 | $MarineLive = new MarineLive($this->db); |
| 429 | 429 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 430 | 430 | $MarineLive->db = null; |
| 431 | 431 | if ($globalDebug) echo $result."\n"; |
| 432 | 432 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 433 | - } |
|
| 433 | + } |
|
| 434 | 434 | } |
| 435 | 435 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 436 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 436 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 437 | 437 | } |
| 438 | 438 | $this->all_tracked[$id]['putinarchive'] = false; |
| 439 | 439 | |
@@ -498,24 +498,24 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | |
| 500 | 500 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 501 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 501 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 502 | 502 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 503 | 503 | $MarineLive = new MarineLive($this->db); |
| 504 | 504 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 505 | 505 | $MarineLive->db = null; |
| 506 | 506 | //MarineLive->deleteLiveMarineData(); |
| 507 | 507 | if ($globalDebug) echo " Done\n"; |
| 508 | - } |
|
| 509 | - $this->last_delete_hourly = time(); |
|
| 508 | + } |
|
| 509 | + $this->last_delete_hourly = time(); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - } |
|
| 513 | - //$ignoreImport = false; |
|
| 512 | + } |
|
| 513 | + //$ignoreImport = false; |
|
| 514 | 514 | } |
| 515 | 515 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 516 | 516 | if ($send) return $this->all_tracked[$id]; |
| 517 | - } |
|
| 517 | + } |
|
| 518 | + } |
|
| 518 | 519 | } |
| 519 | - } |
|
| 520 | 520 | } |
| 521 | 521 | ?> |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 60 | 60 | $Marine = new Marine($this->db); |
| 61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 71 | if (isset($flight['lastupdate'])) { |
| 72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 72 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 73 | 73 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 74 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | 75 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | //$real_arrival = $this->arrival($key); |
| 82 | 82 | $Marine = new Marine($this->db); |
| 83 | 83 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 84 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 86 | 86 | } |
| 87 | 87 | // Put in archive |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function add($line) { |
| 98 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
| 98 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
| 99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 100 | 100 | date_default_timezone_set('UTC'); |
| 101 | 101 | $dataFound = false; |
| 102 | 102 | $send = false; |
| 103 | 103 | |
| 104 | 104 | // SBS format is CSV format |
| 105 | - if(is_array($line) && isset($line['mmsi'])) { |
|
| 105 | + if (is_array($line) && isset($line['mmsi'])) { |
|
| 106 | 106 | //print_r($line); |
| 107 | 107 | if (isset($line['mmsi'])) { |
| 108 | 108 | |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | if (!isset($this->all_tracked[$id])) { |
| 128 | 128 | $this->all_tracked[$id] = array(); |
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
| 131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 132 | 132 | if (!isset($line['id'])) { |
| 133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 136 | 136 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 141 | 141 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 142 | 142 | $Marine = new Marine($this->db); |
| 143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -151,64 +151,64 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 158 | 158 | } |
| 159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
| 161 | 161 | } |
| 162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 170 | 170 | } |
| 171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 179 | 179 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 181 | 181 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 182 | 182 | $timeelapsed = microtime(true); |
| 183 | 183 | $Marine = new Marine($this->db); |
| 184 | 184 | $fromsource = NULL; |
| 185 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 185 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 187 | 187 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 188 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 195 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 196 | 196 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 198 | 198 | } else { |
| 199 | 199 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 200 | 200 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 201 | 201 | return ''; |
| 202 | 202 | } |
| 203 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 203 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 204 | 204 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 205 | 205 | return ''; |
| 206 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 206 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 207 | 207 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 208 | 208 | return ''; |
| 209 | 209 | } elseif (!isset($line['datetime'])) { |
| 210 | 210 | date_default_timezone_set('UTC'); |
| 211 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 211 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 212 | 212 | } else { |
| 213 | 213 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 214 | 214 | return ''; |
@@ -216,24 +216,24 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | if (isset($line['speed']) && $line['speed'] != '') { |
| 219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 221 | 221 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 222 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 222 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 223 | 223 | if ($distance > 1000 && $distance < 10000) { |
| 224 | 224 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 225 | 225 | $speed = $speed*3.6; |
| 226 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 226 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 227 | 227 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 232 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 233 | 233 | else unset($timediff); |
| 234 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 234 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
| 235 | 235 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 236 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 236 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 237 | 237 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 238 | 238 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 239 | 239 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | $timeelapsed = microtime(true); |
| 243 | 243 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 244 | 244 | $Marine = new Marine($this->db); |
| 245 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 245 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 246 | 246 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 247 | 247 | $Marine->db = null; |
| 248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 248 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 249 | 249 | } |
| 250 | 250 | $this->tmd = 0; |
| 251 | 251 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -254,59 +254,59 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 256 | 256 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 257 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 257 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 258 | 258 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 259 | 259 | $dataFound = true; |
| 260 | 260 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 261 | 261 | } |
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 263 | 263 | } |
| 264 | 264 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 265 | 265 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 266 | 266 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 267 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 267 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 268 | 268 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 269 | 269 | $dataFound = true; |
| 270 | 270 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 271 | 271 | } |
| 272 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | } else if ($globalDebug && $timediff > 20) { |
| 276 | 276 | $this->tmd = $this->tmd + 1; |
| 277 | 277 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 278 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 279 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 278 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 279 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 280 | 280 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 284 | 284 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 286 | 286 | } |
| 287 | 287 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 289 | 289 | } |
| 290 | 290 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 292 | 292 | } |
| 293 | 293 | if (isset($line['status']) && $line['status'] != '') { |
| 294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if (isset($line['heading']) && $line['heading'] != '') { |
| 302 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 303 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 304 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 302 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 303 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 304 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 305 | 305 | //$dataFound = true; |
| 306 | 306 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 307 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 308 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 309 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 307 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 308 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 309 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 310 | 310 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 311 | 311 | } |
| 312 | 312 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 317 | 317 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 318 | 318 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 319 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 319 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 320 | 320 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 321 | 321 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 322 | 322 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -324,37 +324,37 @@ discard block |
||
| 324 | 324 | $MarineLive = new MarineLive($this->db); |
| 325 | 325 | if (isset($line['id'])) { |
| 326 | 326 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 327 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 327 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 328 | 328 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 329 | 329 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 330 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 330 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 331 | 331 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 332 | 332 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 333 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 333 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 334 | 334 | } else $recent_ident = ''; |
| 335 | - $MarineLive->db=null; |
|
| 335 | + $MarineLive->db = null; |
|
| 336 | 336 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 337 | 337 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 338 | 338 | } else $recent_ident = ''; |
| 339 | 339 | } else { |
| 340 | 340 | $recent_ident = ''; |
| 341 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 341 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 342 | 342 | } |
| 343 | 343 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 344 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 344 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 345 | 345 | { |
| 346 | 346 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 347 | 347 | //adds the spotter data for the archive |
| 348 | 348 | $highlight = ''; |
| 349 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 349 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 350 | 350 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 351 | 351 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 352 | 352 | $timeelapsed = microtime(true); |
| 353 | 353 | $Marine = new Marine($this->db); |
| 354 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 354 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 355 | 355 | $Marine->db = null; |
| 356 | 356 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 357 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | /* |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 395 | $MarineLive = new MarineLive($this->db); |
| 396 | 396 | $MarineLive->deleteLiveMarineData(); |
| 397 | - $MarineLive->db=null; |
|
| 397 | + $MarineLive->db = null; |
|
| 398 | 398 | if ($globalDebug) echo " Done\n"; |
| 399 | 399 | } |
| 400 | 400 | $this->last_delete = time(); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 406 | 406 | if (isset($globalDaemon) && !$globalDaemon) { |
| 407 | 407 | $Marine = new Marine($this->db); |
| 408 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 408 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 409 | 409 | $Marine->db = null; |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -420,20 +420,20 @@ discard block |
||
| 420 | 420 | $ignoreImport = false; |
| 421 | 421 | |
| 422 | 422 | if (!$ignoreImport) { |
| 423 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 423 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 424 | 424 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 425 | 425 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 426 | 426 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 427 | 427 | $timeelapsed = microtime(true); |
| 428 | 428 | $MarineLive = new MarineLive($this->db); |
| 429 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 429 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 430 | 430 | $MarineLive->db = null; |
| 431 | 431 | if ($globalDebug) echo $result."\n"; |
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 432 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 436 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 436 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 437 | 437 | } |
| 438 | 438 | $this->all_tracked[$id]['putinarchive'] = false; |
| 439 | 439 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 495 | 495 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 496 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 496 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 497 | 497 | //$this->del(); |
| 498 | 498 | |
| 499 | 499 | |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function checkAll() { |
| 55 | 55 | global $globalDebug; |
| 56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo "Update last seen tracked data...\n"; |
|
| 58 | + } |
|
| 57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
| 66 | 68 | public function del() { |
| 67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 70 | // Delete old infos |
| 69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 71 | + if ($globalDebug) { |
|
| 72 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 73 | + } |
|
| 70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 75 | if (isset($flight['lastupdate'])) { |
| 72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
| 73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 81 | + } |
|
| 76 | 82 | /* |
| 77 | 83 | $MarineLive = new MarineLive(); |
| 78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
| 82 | 88 | $Marine = new Marine($this->db); |
| 83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 91 | + if ($globalDebug && $result != 'success') { |
|
| 92 | + echo '!!! ERROR : '.$result."\n"; |
|
| 93 | + } |
|
| 86 | 94 | } |
| 87 | 95 | // Put in archive |
| 88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
| 96 | 104 | |
| 97 | 105 | public function add($line) { |
| 98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 108 | + $globalCoordMinChange = '0.02'; |
|
| 109 | + } |
|
| 100 | 110 | date_default_timezone_set('UTC'); |
| 101 | 111 | $dataFound = false; |
| 102 | 112 | $send = false; |
@@ -121,8 +131,11 @@ discard block |
||
| 121 | 131 | |
| 122 | 132 | $Common = new Common(); |
| 123 | 133 | $AIS = new AIS(); |
| 124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | - else $id = trim($line['id']); |
|
| 134 | + if (!isset($line['id'])) { |
|
| 135 | + $id = trim($line['mmsi']); |
|
| 136 | + } else { |
|
| 137 | + $id = trim($line['id']); |
|
| 138 | + } |
|
| 126 | 139 | |
| 127 | 140 | if (!isset($this->all_tracked[$id])) { |
| 128 | 141 | $this->all_tracked[$id] = array(); |
@@ -130,10 +143,16 @@ discard block |
||
| 130 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
| 131 | 144 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 132 | 145 | if (!isset($line['id'])) { |
| 133 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 146 | + if (!isset($globalDaemon)) { |
|
| 147 | + $globalDaemon = TRUE; |
|
| 148 | + } |
|
| 134 | 149 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 150 | + } else { |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 152 | + } |
|
| 153 | + if ($globalAllTracked !== FALSE) { |
|
| 154 | + $dataFound = true; |
|
| 155 | + } |
|
| 137 | 156 | } |
| 138 | 157 | |
| 139 | 158 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -183,34 +202,49 @@ discard block |
||
| 183 | 202 | $Marine = new Marine($this->db); |
| 184 | 203 | $fromsource = NULL; |
| 185 | 204 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 186 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 205 | + if ($globalDebug && $result != 'success') { |
|
| 206 | + echo '!!! ERROR : '.$result."\n"; |
|
| 207 | + } |
|
| 187 | 208 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 209 | + if ($globalDebugTimeElapsed) { |
|
| 210 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 211 | + } |
|
| 189 | 212 | } |
| 190 | 213 | } |
| 191 | 214 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 215 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 217 | + } |
|
| 193 | 218 | } |
| 194 | 219 | |
| 195 | 220 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 196 | 221 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 197 | 222 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 198 | 223 | } else { |
| 199 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 200 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 224 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 225 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 226 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 227 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 228 | + } |
|
| 201 | 229 | return ''; |
| 202 | 230 | } |
| 203 | 231 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 204 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 234 | + } |
|
| 205 | 235 | return ''; |
| 206 | 236 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 207 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 237 | + if ($globalDebug) { |
|
| 238 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 239 | + } |
|
| 208 | 240 | return ''; |
| 209 | 241 | } elseif (!isset($line['datetime'])) { |
| 210 | 242 | date_default_timezone_set('UTC'); |
| 211 | 243 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 212 | 244 | } else { |
| 213 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 247 | + } |
|
| 214 | 248 | return ''; |
| 215 | 249 | } |
| 216 | 250 | |
@@ -223,14 +257,21 @@ discard block |
||
| 223 | 257 | if ($distance > 1000 && $distance < 10000) { |
| 224 | 258 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 225 | 259 | $speed = $speed*3.6; |
| 226 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 227 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 260 | + if ($speed < 1000) { |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 262 | + } |
|
| 263 | + if ($globalDebug) { |
|
| 264 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 265 | + } |
|
| 228 | 266 | } |
| 229 | 267 | } |
| 230 | 268 | |
| 231 | 269 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 233 | - else unset($timediff); |
|
| 270 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 271 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 272 | + } else { |
|
| 273 | + unset($timediff); |
|
| 274 | + } |
|
| 234 | 275 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 235 | 276 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 236 | 277 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -238,22 +279,32 @@ discard block |
||
| 238 | 279 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 239 | 280 | $this->all_tracked[$id]['putinarchive'] = true; |
| 240 | 281 | |
| 241 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 282 | + if ($globalDebug) { |
|
| 283 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 284 | + } |
|
| 242 | 285 | $timeelapsed = microtime(true); |
| 243 | 286 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 244 | 287 | $Marine = new Marine($this->db); |
| 245 | 288 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 246 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 289 | + if (!empty($all_country)) { |
|
| 290 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 291 | + } |
|
| 247 | 292 | $Marine->db = null; |
| 248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 293 | + if ($globalDebugTimeElapsed) { |
|
| 294 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 295 | + } |
|
| 249 | 296 | } |
| 250 | 297 | $this->tmd = 0; |
| 251 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 298 | + if ($globalDebug) { |
|
| 299 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 300 | + } |
|
| 252 | 301 | } |
| 253 | 302 | } |
| 254 | 303 | |
| 255 | 304 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 256 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 305 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 306 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 307 | + } |
|
| 257 | 308 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 258 | 309 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 259 | 310 | $dataFound = true; |
@@ -262,8 +313,12 @@ discard block |
||
| 262 | 313 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 263 | 314 | } |
| 264 | 315 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 265 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 266 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 316 | + if ($line['longitude'] > 180) { |
|
| 317 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 318 | + } |
|
| 319 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 320 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 321 | + } |
|
| 267 | 322 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 268 | 323 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 269 | 324 | $dataFound = true; |
@@ -281,7 +336,9 @@ discard block |
||
| 281 | 336 | } |
| 282 | 337 | } |
| 283 | 338 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 284 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 339 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 340 | + $dataFound = true; |
|
| 341 | + } |
|
| 285 | 342 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 286 | 343 | } |
| 287 | 344 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -299,15 +356,21 @@ discard block |
||
| 299 | 356 | } |
| 300 | 357 | |
| 301 | 358 | if (isset($line['heading']) && $line['heading'] != '') { |
| 302 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 359 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 360 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 361 | + } |
|
| 303 | 362 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 304 | 363 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 305 | 364 | //$dataFound = true; |
| 306 | 365 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 307 | 366 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 308 | 367 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 309 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 310 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 368 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 369 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 370 | + } |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 373 | + } |
|
| 311 | 374 | } |
| 312 | 375 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 313 | 376 | |
@@ -319,23 +382,38 @@ discard block |
||
| 319 | 382 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 320 | 383 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 321 | 384 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 322 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 385 | + if ($globalDebug) { |
|
| 386 | + echo "Check if aircraft is already in DB..."; |
|
| 387 | + } |
|
| 323 | 388 | $timeelapsed = microtime(true); |
| 324 | 389 | $MarineLive = new MarineLive($this->db); |
| 325 | 390 | if (isset($line['id'])) { |
| 326 | 391 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 327 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 392 | + if ($globalDebugTimeElapsed) { |
|
| 393 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 394 | + } |
|
| 328 | 395 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 329 | 396 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 330 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 397 | + if ($globalDebugTimeElapsed) { |
|
| 398 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 399 | + } |
|
| 331 | 400 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 332 | 401 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 333 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 334 | - } else $recent_ident = ''; |
|
| 402 | + if ($globalDebugTimeElapsed) { |
|
| 403 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 404 | + } |
|
| 405 | + } else { |
|
| 406 | + $recent_ident = ''; |
|
| 407 | + } |
|
| 335 | 408 | $MarineLive->db=null; |
| 336 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 337 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 338 | - } else $recent_ident = ''; |
|
| 409 | + if ($globalDebug && $recent_ident == '') { |
|
| 410 | + echo " Not in DB.\n"; |
|
| 411 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 412 | + echo " Already in DB.\n"; |
|
| 413 | + } |
|
| 414 | + } else { |
|
| 415 | + $recent_ident = ''; |
|
| 416 | + } |
|
| 339 | 417 | } else { |
| 340 | 418 | $recent_ident = ''; |
| 341 | 419 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -343,18 +421,26 @@ discard block |
||
| 343 | 421 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 344 | 422 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 345 | 423 | { |
| 346 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 424 | + if ($globalDebug) { |
|
| 425 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 426 | + } |
|
| 347 | 427 | //adds the spotter data for the archive |
| 348 | 428 | $highlight = ''; |
| 349 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 429 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 430 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 431 | + } |
|
| 350 | 432 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 351 | 433 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 352 | 434 | $timeelapsed = microtime(true); |
| 353 | 435 | $Marine = new Marine($this->db); |
| 354 | 436 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 355 | 437 | $Marine->db = null; |
| 356 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 357 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 438 | + if ($globalDebug && isset($result)) { |
|
| 439 | + echo $result."\n"; |
|
| 440 | + } |
|
| 441 | + if ($globalDebugTimeElapsed) { |
|
| 442 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 443 | + } |
|
| 358 | 444 | } |
| 359 | 445 | } |
| 360 | 446 | /* |
@@ -389,13 +475,17 @@ discard block |
||
| 389 | 475 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 390 | 476 | //print_r($this->all_tracked[$id]); |
| 391 | 477 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 392 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 478 | + if ($globalDebug) { |
|
| 479 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 480 | + } |
|
| 393 | 481 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 394 | 482 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 483 | $MarineLive = new MarineLive($this->db); |
| 396 | 484 | $MarineLive->deleteLiveMarineData(); |
| 397 | 485 | $MarineLive->db=null; |
| 398 | - if ($globalDebug) echo " Done\n"; |
|
| 486 | + if ($globalDebug) { |
|
| 487 | + echo " Done\n"; |
|
| 488 | + } |
|
| 399 | 489 | } |
| 400 | 490 | $this->last_delete = time(); |
| 401 | 491 | } |
@@ -421,15 +511,21 @@ discard block |
||
| 421 | 511 | |
| 422 | 512 | if (!$ignoreImport) { |
| 423 | 513 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 424 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 514 | + if ($globalDebug) { |
|
| 515 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 516 | + } |
|
| 425 | 517 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 426 | 518 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 427 | 519 | $timeelapsed = microtime(true); |
| 428 | 520 | $MarineLive = new MarineLive($this->db); |
| 429 | 521 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 430 | 522 | $MarineLive->db = null; |
| 431 | - if ($globalDebug) echo $result."\n"; |
|
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 523 | + if ($globalDebug) { |
|
| 524 | + echo $result."\n"; |
|
| 525 | + } |
|
| 526 | + if ($globalDebugTimeElapsed) { |
|
| 527 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 528 | + } |
|
| 433 | 529 | } |
| 434 | 530 | } |
| 435 | 531 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -492,19 +588,27 @@ discard block |
||
| 492 | 588 | */ |
| 493 | 589 | |
| 494 | 590 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 495 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 496 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 591 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 592 | + $send = true; |
|
| 593 | + } |
|
| 594 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 595 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 596 | + } |
|
| 497 | 597 | //$this->del(); |
| 498 | 598 | |
| 499 | 599 | |
| 500 | 600 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 501 | 601 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 502 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 602 | + if ($globalDebug) { |
|
| 603 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 604 | + } |
|
| 503 | 605 | $MarineLive = new MarineLive($this->db); |
| 504 | 606 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 505 | 607 | $MarineLive->db = null; |
| 506 | 608 | //MarineLive->deleteLiveMarineData(); |
| 507 | - if ($globalDebug) echo " Done\n"; |
|
| 609 | + if ($globalDebug) { |
|
| 610 | + echo " Done\n"; |
|
| 611 | + } |
|
| 508 | 612 | } |
| 509 | 613 | $this->last_delete_hourly = time(); |
| 510 | 614 | } |
@@ -513,7 +617,9 @@ discard block |
||
| 513 | 617 | //$ignoreImport = false; |
| 514 | 618 | } |
| 515 | 619 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 516 | - if ($send) return $this->all_tracked[$id]; |
|
| 620 | + if ($send) { |
|
| 621 | + return $this->all_tracked[$id]; |
|
| 622 | + } |
|
| 517 | 623 | } |
| 518 | 624 | } |
| 519 | 625 | } |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | |
| 11 | 11 | class TrackerImport { |
| 12 | - private $all_tracked = array(); |
|
| 13 | - private $last_delete_hourly = 0; |
|
| 14 | - private $last_delete = 0; |
|
| 15 | - private $stats = array(); |
|
| 16 | - private $tmd = 0; |
|
| 17 | - private $source_location = array(); |
|
| 18 | - public $db = null; |
|
| 19 | - public $nb = 0; |
|
| 12 | + private $all_tracked = array(); |
|
| 13 | + private $last_delete_hourly = 0; |
|
| 14 | + private $last_delete = 0; |
|
| 15 | + private $stats = array(); |
|
| 16 | + private $tmd = 0; |
|
| 17 | + private $source_location = array(); |
|
| 18 | + public $db = null; |
|
| 19 | + public $nb = 0; |
|
| 20 | 20 | |
| 21 | - public function __construct($dbc = null) { |
|
| 21 | + public function __construct($dbc = null) { |
|
| 22 | 22 | global $globalBeta; |
| 23 | 23 | $Connection = new Connection($dbc); |
| 24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | */ |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function checkAll() { |
|
| 45 | + public function checkAll() { |
|
| 46 | 46 | global $globalDebug; |
| 47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
| 48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 51 | - $Tracker = new Tracker($this->db); |
|
| 52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 53 | - } |
|
| 51 | + $Tracker = new Tracker($this->db); |
|
| 52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 53 | + } |
|
| 54 | + } |
|
| 54 | 55 | } |
| 55 | - } |
|
| 56 | 56 | |
| 57 | - public function del() { |
|
| 57 | + public function del() { |
|
| 58 | 58 | global $globalDebug; |
| 59 | 59 | // Delete old infos |
| 60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | - if (isset($flight['lastupdate'])) { |
|
| 63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 62 | + if (isset($flight['lastupdate'])) { |
|
| 63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 66 | 66 | /* |
| 67 | 67 | $TrackerLive = new TrackerLive(); |
| 68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
| 69 | 69 | $TrackerLive->db = null; |
| 70 | 70 | */ |
| 71 | - //$real_arrival = $this->arrival($key); |
|
| 72 | - $Tracker = new Tracker($this->db); |
|
| 73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 71 | + //$real_arrival = $this->arrival($key); |
|
| 72 | + $Tracker = new Tracker($this->db); |
|
| 73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 76 | 76 | } |
| 77 | 77 | // Put in archive |
| 78 | 78 | // $Tracker->db = null; |
| 79 | - } |
|
| 80 | - unset($this->all_tracked[$key]); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - } |
|
| 79 | + } |
|
| 80 | + unset($this->all_tracked[$key]); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function add($line) { |
|
| 86 | + public function add($line) { |
|
| 87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // SBS format is CSV format |
| 94 | 94 | if(is_array($line) && isset($line['ident'])) { |
| 95 | - //print_r($line); |
|
| 96 | - if (isset($line['ident'])) { |
|
| 95 | + //print_r($line); |
|
| 96 | + if (isset($line['ident'])) { |
|
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | |
| 111 | 111 | $Common = new Common(); |
| 112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | - else $id = trim($line['id']); |
|
| 112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | + else $id = trim($line['id']); |
|
| 114 | 114 | |
| 115 | 115 | if (!isset($this->all_tracked[$id])) { |
| 116 | - $this->all_tracked[$id] = array(); |
|
| 117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
| 118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
| 119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 120 | - if (!isset($line['id'])) { |
|
| 116 | + $this->all_tracked[$id] = array(); |
|
| 117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
| 118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
| 119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 120 | + if (!isset($line['id'])) { |
|
| 121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
| 128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 130 | - } else { |
|
| 130 | + } else { |
|
| 131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 133 | 133 | return ''; |
| 134 | - } |
|
| 134 | + } |
|
| 135 | 135 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 137 | 137 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 152 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 152 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
| 153 | 153 | $timeelapsed = microtime(true); |
| 154 | - $Tracker = new Tracker($this->db); |
|
| 155 | - $fromsource = NULL; |
|
| 156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 154 | + $Tracker = new Tracker($this->db); |
|
| 155 | + $fromsource = NULL; |
|
| 156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 158 | 158 | $Tracker->db = null; |
| 159 | 159 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 160 | - } |
|
| 161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 160 | + } |
|
| 161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
| 165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 169 | - if ($distance > 1000 && $distance < 10000) { |
|
| 168 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 169 | + if ($distance > 1000 && $distance < 10000) { |
|
| 170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 171 | 171 | $speed = $speed*3.6; |
| 172 | 172 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | - else unset($timediff); |
|
| 180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 177 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | + else unset($timediff); |
|
| 180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -193,120 +193,120 @@ discard block |
||
| 193 | 193 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 194 | 194 | $this->tmd = 0; |
| 195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 201 | 201 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 202 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 203 | - $dataFound = true; |
|
| 204 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 202 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 203 | + $dataFound = true; |
|
| 204 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 205 | 205 | } |
| 206 | 206 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 207 | 207 | } |
| 208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 211 | 211 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 212 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 213 | - $dataFound = true; |
|
| 214 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 212 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 213 | + $dataFound = true; |
|
| 214 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 215 | 215 | } |
| 216 | 216 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - } else if ($globalDebug && $timediff > 20) { |
|
| 219 | + } else if ($globalDebug && $timediff > 20) { |
|
| 220 | 220 | $this->tmd = $this->tmd + 1; |
| 221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 222 | 222 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 228 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 230 | 230 | } |
| 231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 233 | 233 | } |
| 234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 236 | 236 | } |
| 237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
| 238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
| 239 | - //$dataFound = true; |
|
| 238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
| 239 | + //$dataFound = true; |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 243 | - //$dataFound = true; |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 243 | + //$dataFound = true; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 247 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 248 | 248 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
| 249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
| 250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 251 | 251 | //$dataFound = true; |
| 252 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 252 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
| 260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 263 | - //$dataFound = true; |
|
| 260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 263 | + //$dataFound = true; |
|
| 264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 267 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 269 | 269 | } |
| 270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 271 | 271 | |
| 272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
| 273 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 274 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
| 275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 276 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 273 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 274 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
| 275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 276 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 278 | 278 | $timeelapsed = microtime(true); |
| 279 | 279 | $TrackerLive = new TrackerLive($this->db); |
| 280 | 280 | if (isset($line['id'])) { |
| 281 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 281 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
| 282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 284 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
| 285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 284 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
| 285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 286 | 286 | } else $recent_ident = ''; |
| 287 | 287 | $TrackerLive->db=null; |
| 288 | 288 | |
| 289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 291 | - } else { |
|
| 291 | + } else { |
|
| 292 | 292 | $recent_ident = ''; |
| 293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 294 | - } |
|
| 295 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 296 | - if($recent_ident == "") |
|
| 297 | - { |
|
| 294 | + } |
|
| 295 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 296 | + if($recent_ident == "") |
|
| 297 | + { |
|
| 298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 299 | 299 | //adds the spotter data for the archive |
| 300 | - $highlight = ''; |
|
| 301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 302 | - $timeelapsed = microtime(true); |
|
| 303 | - $Tracker = new Tracker($this->db); |
|
| 304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 305 | - $Tracker->db = null; |
|
| 306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 300 | + $highlight = ''; |
|
| 301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 302 | + $timeelapsed = microtime(true); |
|
| 303 | + $Tracker = new Tracker($this->db); |
|
| 304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 305 | + $Tracker->db = null; |
|
| 306 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 308 | 308 | |
| 309 | - /* |
|
| 309 | + /* |
|
| 310 | 310 | // Add source stat in DB |
| 311 | 311 | $Stats = new Stats($this->db); |
| 312 | 312 | if (!empty($this->stats)) { |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | $Stats->db = null; |
| 335 | 335 | */ |
| 336 | - $this->del(); |
|
| 336 | + $this->del(); |
|
| 337 | 337 | //$ignoreImport = false; |
| 338 | 338 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 339 | 339 | //print_r($this->all_tracked[$id]); |
| 340 | 340 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 342 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 343 | - $TrackerLive = new TrackerLive($this->db); |
|
| 344 | - $TrackerLive->deleteLiveTrackerData(); |
|
| 345 | - $TrackerLive->db=null; |
|
| 346 | - if ($globalDebug) echo " Done\n"; |
|
| 347 | - $this->last_delete = time(); |
|
| 341 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 342 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 343 | + $TrackerLive = new TrackerLive($this->db); |
|
| 344 | + $TrackerLive->deleteLiveTrackerData(); |
|
| 345 | + $TrackerLive->db=null; |
|
| 346 | + if ($globalDebug) echo " Done\n"; |
|
| 347 | + $this->last_delete = time(); |
|
| 348 | 348 | } |
| 349 | - } else { |
|
| 349 | + } else { |
|
| 350 | 350 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | $Tracker->db = null; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - } |
|
| 358 | + } |
|
| 359 | + } |
|
| 359 | 360 | } |
| 360 | - } |
|
| 361 | - //adds the spotter LIVE data |
|
| 362 | - if ($globalDebug) { |
|
| 361 | + //adds the spotter LIVE data |
|
| 362 | + if ($globalDebug) { |
|
| 363 | 363 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 364 | - } |
|
| 365 | - $ignoreImport = false; |
|
| 364 | + } |
|
| 365 | + $ignoreImport = false; |
|
| 366 | 366 | |
| 367 | - if (!$ignoreImport) { |
|
| 367 | + if (!$ignoreImport) { |
|
| 368 | 368 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 370 | 370 | $timeelapsed = microtime(true); |
@@ -436,22 +436,22 @@ discard block |
||
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 440 | - $TrackerLive = new TrackerLive($this->db); |
|
| 441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 442 | - $TrackerLive->db = null; |
|
| 443 | - //TrackerLive->deleteLiveTrackerData(); |
|
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 445 | - $this->last_delete_hourly = time(); |
|
| 439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 440 | + $TrackerLive = new TrackerLive($this->db); |
|
| 441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
| 442 | + $TrackerLive->db = null; |
|
| 443 | + //TrackerLive->deleteLiveTrackerData(); |
|
| 444 | + if ($globalDebug) echo " Done\n"; |
|
| 445 | + $this->last_delete_hourly = time(); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - } |
|
| 449 | - //$ignoreImport = false; |
|
| 448 | + } |
|
| 449 | + //$ignoreImport = false; |
|
| 450 | 450 | } |
| 451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | 452 | if ($send) return $this->all_tracked[$id]; |
| 453 | - } |
|
| 453 | + } |
|
| 454 | + } |
|
| 454 | 455 | } |
| 455 | - } |
|
| 456 | 456 | } |
| 457 | 457 | ?> |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 51 | 51 | $Tracker = new Tracker($this->db); |
| 52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | 62 | if (isset($flight['lastupdate'])) { |
| 63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
| 65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
| 66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | //$real_arrival = $this->arrival($key); |
| 72 | 72 | $Tracker = new Tracker($this->db); |
| 73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 74 | - $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
|
| 74 | + $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']); |
|
| 75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 76 | 76 | } |
| 77 | 77 | // Put in archive |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $send = false; |
| 92 | 92 | |
| 93 | 93 | // SBS format is CSV format |
| 94 | - if(is_array($line) && isset($line['ident'])) { |
|
| 94 | + if (is_array($line) && isset($line['ident'])) { |
|
| 95 | 95 | //print_r($line); |
| 96 | 96 | if (isset($line['ident'])) { |
| 97 | 97 | |
@@ -114,33 +114,33 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (!isset($this->all_tracked[$id])) { |
| 116 | 116 | $this->all_tracked[$id] = array(); |
| 117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
| 118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
| 119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
| 118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '')); |
|
| 119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 120 | 120 | if (!isset($line['id'])) { |
| 121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 122 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 122 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 124 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
| 127 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
| 128 | 128 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 130 | 130 | } else { |
| 131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 133 | 133 | return ''; |
| 134 | 134 | } |
| 135 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 135 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 137 | 137 | return ''; |
| 138 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 138 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 139 | 139 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 140 | 140 | return ''; |
| 141 | 141 | } elseif (!isset($line['datetime'])) { |
| 142 | 142 | date_default_timezone_set('UTC'); |
| 143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 144 | 144 | } else { |
| 145 | 145 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 146 | 146 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 152 | 152 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
| 153 | 153 | $timeelapsed = microtime(true); |
| 154 | 154 | $Tracker = new Tracker($this->db); |
| 155 | 155 | $fromsource = NULL; |
| 156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 158 | 158 | $Tracker->db = null; |
| 159 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 159 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 160 | 160 | } |
| 161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
| 165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 168 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 169 | 169 | if ($distance > 1000 && $distance < 10000) { |
| 170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 171 | 171 | $speed = $speed*3.6; |
| 172 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 172 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 179 | 179 | else unset($timediff); |
| 180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
| 181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 188 | 188 | $timeelapsed = microtime(true); |
| 189 | 189 | $Tracker = new Tracker($this->db); |
| 190 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 190 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 191 | 191 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 192 | 192 | $Tracker->db = null; |
| 193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 193 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 194 | 194 | $this->tmd = 0; |
| 195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 196 | 196 | } |
@@ -198,73 +198,73 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 201 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 201 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 202 | 202 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 203 | 203 | $dataFound = true; |
| 204 | 204 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 205 | 205 | } |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 207 | 207 | } |
| 208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 209 | 209 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 211 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 211 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 212 | 212 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 213 | 213 | $dataFound = true; |
| 214 | 214 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 215 | 215 | } |
| 216 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | } else if ($globalDebug && $timediff > 20) { |
| 220 | 220 | $this->tmd = $this->tmd + 1; |
| 221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 222 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 223 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 222 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 223 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 228 | 228 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 230 | 230 | } |
| 231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 233 | 233 | } |
| 234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 236 | 236 | } |
| 237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
| 238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
| 238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
| 239 | 239 | //$dataFound = true; |
| 240 | 240 | } |
| 241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 243 | 243 | //$dataFound = true; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | 247 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 248 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 249 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
|
| 250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
| 248 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100))); |
|
| 250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
| 251 | 251 | //$dataFound = true; |
| 252 | 252 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
| 260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 263 | 263 | //$dataFound = true; |
| 264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 267 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | 268 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 269 | 269 | } |
| 270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -272,39 +272,39 @@ discard block |
||
| 272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
| 273 | 273 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 274 | 274 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 276 | 276 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 278 | 278 | $timeelapsed = microtime(true); |
| 279 | 279 | $TrackerLive = new TrackerLive($this->db); |
| 280 | 280 | if (isset($line['id'])) { |
| 281 | 281 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 284 | 284 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 286 | 286 | } else $recent_ident = ''; |
| 287 | - $TrackerLive->db=null; |
|
| 287 | + $TrackerLive->db = null; |
|
| 288 | 288 | |
| 289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 291 | 291 | } else { |
| 292 | 292 | $recent_ident = ''; |
| 293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 294 | 294 | } |
| 295 | 295 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 296 | - if($recent_ident == "") |
|
| 296 | + if ($recent_ident == "") |
|
| 297 | 297 | { |
| 298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 299 | 299 | //adds the spotter data for the archive |
| 300 | 300 | $highlight = ''; |
| 301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 302 | 302 | $timeelapsed = microtime(true); |
| 303 | 303 | $Tracker = new Tracker($this->db); |
| 304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 305 | 305 | $Tracker->db = null; |
| 306 | 306 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 308 | 308 | |
| 309 | 309 | /* |
| 310 | 310 | // Add source stat in DB |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 343 | 343 | $TrackerLive = new TrackerLive($this->db); |
| 344 | 344 | $TrackerLive->deleteLiveTrackerData(); |
| 345 | - $TrackerLive->db=null; |
|
| 345 | + $TrackerLive->db = null; |
|
| 346 | 346 | if ($globalDebug) echo " Done\n"; |
| 347 | 347 | $this->last_delete = time(); |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
| 353 | 353 | $Tracker = new Tracker($this->db); |
| 354 | - $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 354 | + $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 355 | 355 | $Tracker->db = null; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -365,14 +365,14 @@ discard block |
||
| 365 | 365 | $ignoreImport = false; |
| 366 | 366 | |
| 367 | 367 | if (!$ignoreImport) { |
| 368 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 368 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 370 | 370 | $timeelapsed = microtime(true); |
| 371 | 371 | $TrackerLive = new TrackerLive($this->db); |
| 372 | - $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 372 | + $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 373 | 373 | $TrackerLive->db = null; |
| 374 | 374 | $this->all_tracked[$id]['putinarchive'] = false; |
| 375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 376 | 376 | |
| 377 | 377 | // Put statistics in $this->stats variable |
| 378 | 378 | /* |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 433 | 433 | if ($globalDebug) echo $result."\n"; |
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 434 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 435 | 435 | //$this->del(); |
| 436 | 436 | |
| 437 | 437 | |
@@ -44,7 +44,9 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function checkAll() { |
| 46 | 46 | global $globalDebug; |
| 47 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 47 | + if ($globalDebug) { |
|
| 48 | + echo "Update last seen tracked data...\n"; |
|
| 49 | + } |
|
| 48 | 50 | foreach ($this->all_tracked as $key => $flight) { |
| 49 | 51 | if (isset($this->all_tracked[$key]['id'])) { |
| 50 | 52 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -57,12 +59,16 @@ discard block |
||
| 57 | 59 | public function del() { |
| 58 | 60 | global $globalDebug; |
| 59 | 61 | // Delete old infos |
| 60 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + if ($globalDebug) { |
|
| 63 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 64 | + } |
|
| 61 | 65 | foreach ($this->all_tracked as $key => $flight) { |
| 62 | 66 | if (isset($flight['lastupdate'])) { |
| 63 | 67 | if ($flight['lastupdate'] < (time()-3000)) { |
| 64 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
| 65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + if ($globalDebug) { |
|
| 70 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 71 | + } |
|
| 66 | 72 | /* |
| 67 | 73 | $TrackerLive = new TrackerLive(); |
| 68 | 74 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -72,7 +78,9 @@ discard block |
||
| 72 | 78 | $Tracker = new Tracker($this->db); |
| 73 | 79 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 74 | 80 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 75 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + if ($globalDebug && $result != 'success') { |
|
| 82 | + echo '!!! ERROR : '.$result."\n"; |
|
| 83 | + } |
|
| 76 | 84 | } |
| 77 | 85 | // Put in archive |
| 78 | 86 | // $Tracker->db = null; |
@@ -85,7 +93,9 @@ discard block |
||
| 85 | 93 | |
| 86 | 94 | public function add($line) { |
| 87 | 95 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 88 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 96 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 97 | + $globalCoordMinChange = '0.02'; |
|
| 98 | + } |
|
| 89 | 99 | date_default_timezone_set('UTC'); |
| 90 | 100 | $dataFound = false; |
| 91 | 101 | $send = false; |
@@ -109,8 +119,11 @@ discard block |
||
| 109 | 119 | */ |
| 110 | 120 | |
| 111 | 121 | $Common = new Common(); |
| 112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 113 | - else $id = trim($line['id']); |
|
| 122 | + if (!isset($line['id'])) { |
|
| 123 | + $id = trim($line['ident']); |
|
| 124 | + } else { |
|
| 125 | + $id = trim($line['id']); |
|
| 126 | + } |
|
| 114 | 127 | |
| 115 | 128 | if (!isset($this->all_tracked[$id])) { |
| 116 | 129 | $this->all_tracked[$id] = array(); |
@@ -118,31 +131,46 @@ discard block |
||
| 118 | 131 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
| 119 | 132 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 120 | 133 | if (!isset($line['id'])) { |
| 121 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 134 | + if (!isset($globalDaemon)) { |
|
| 135 | + $globalDaemon = TRUE; |
|
| 136 | + } |
|
| 122 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 138 | + } else { |
|
| 139 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 140 | + } |
|
| 141 | + if ($globalAllTracked !== FALSE) { |
|
| 142 | + $dataFound = true; |
|
| 143 | + } |
|
| 125 | 144 | } |
| 126 | 145 | |
| 127 | 146 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
| 128 | 147 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 129 | 148 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 130 | 149 | } else { |
| 131 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 132 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 150 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 151 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 152 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 153 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 154 | + } |
|
| 133 | 155 | return ''; |
| 134 | 156 | } |
| 135 | 157 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 136 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 158 | + if ($globalDebug) { |
|
| 159 | + echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 160 | + } |
|
| 137 | 161 | return ''; |
| 138 | 162 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 139 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 163 | + if ($globalDebug) { |
|
| 164 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 165 | + } |
|
| 140 | 166 | return ''; |
| 141 | 167 | } elseif (!isset($line['datetime'])) { |
| 142 | 168 | date_default_timezone_set('UTC'); |
| 143 | 169 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 144 | 170 | } else { |
| 145 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 171 | + if ($globalDebug) { |
|
| 172 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 173 | + } |
|
| 146 | 174 | return ''; |
| 147 | 175 | } |
| 148 | 176 | |
@@ -154,11 +182,17 @@ discard block |
||
| 154 | 182 | $Tracker = new Tracker($this->db); |
| 155 | 183 | $fromsource = NULL; |
| 156 | 184 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 157 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 185 | + if ($globalDebug && $result != 'success') { |
|
| 186 | + echo '!!! ERROR : '.$result."\n"; |
|
| 187 | + } |
|
| 158 | 188 | $Tracker->db = null; |
| 159 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 189 | + if ($globalDebugTimeElapsed) { |
|
| 190 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 194 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 160 | 195 | } |
| 161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 162 | 196 | } |
| 163 | 197 | |
| 164 | 198 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -169,14 +203,21 @@ discard block |
||
| 169 | 203 | if ($distance > 1000 && $distance < 10000) { |
| 170 | 204 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 171 | 205 | $speed = $speed*3.6; |
| 172 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 173 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 206 | + if ($speed < 1000) { |
|
| 207 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 208 | + } |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 211 | + } |
|
| 174 | 212 | } |
| 175 | 213 | } |
| 176 | 214 | |
| 177 | 215 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 179 | - else unset($timediff); |
|
| 216 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 217 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 218 | + } else { |
|
| 219 | + unset($timediff); |
|
| 220 | + } |
|
| 180 | 221 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 181 | 222 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 182 | 223 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -184,20 +225,30 @@ discard block |
||
| 184 | 225 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 185 | 226 | $this->all_tracked[$id]['putinarchive'] = true; |
| 186 | 227 | |
| 187 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 230 | + } |
|
| 188 | 231 | $timeelapsed = microtime(true); |
| 189 | 232 | $Tracker = new Tracker($this->db); |
| 190 | 233 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 191 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 234 | + if (!empty($all_country)) { |
|
| 235 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 236 | + } |
|
| 192 | 237 | $Tracker->db = null; |
| 193 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 238 | + if ($globalDebugTimeElapsed) { |
|
| 239 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 240 | + } |
|
| 194 | 241 | $this->tmd = 0; |
| 195 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 244 | + } |
|
| 196 | 245 | } |
| 197 | 246 | } |
| 198 | 247 | |
| 199 | 248 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 200 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 249 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 250 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 251 | + } |
|
| 201 | 252 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 202 | 253 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 203 | 254 | $dataFound = true; |
@@ -206,8 +257,12 @@ discard block |
||
| 206 | 257 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 207 | 258 | } |
| 208 | 259 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 210 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 260 | + if ($line['longitude'] > 180) { |
|
| 261 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 262 | + } |
|
| 263 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 264 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 265 | + } |
|
| 211 | 266 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 212 | 267 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 213 | 268 | $dataFound = true; |
@@ -225,7 +280,9 @@ discard block |
||
| 225 | 280 | } |
| 226 | 281 | } |
| 227 | 282 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 283 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 284 | + $dataFound = true; |
|
| 285 | + } |
|
| 229 | 286 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 230 | 287 | } |
| 231 | 288 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -245,7 +302,9 @@ discard block |
||
| 245 | 302 | |
| 246 | 303 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 247 | 304 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 248 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 305 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 306 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 307 | + } |
|
| 249 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
| 250 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 251 | 310 | //$dataFound = true; |
@@ -257,15 +316,21 @@ discard block |
||
| 257 | 316 | } |
| 258 | 317 | |
| 259 | 318 | if (isset($line['heading']) && $line['heading'] != '') { |
| 260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 319 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 320 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 321 | + } |
|
| 261 | 322 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 262 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 263 | 324 | //$dataFound = true; |
| 264 | 325 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 265 | 326 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 266 | 327 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 328 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 329 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 330 | + } |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 333 | + } |
|
| 269 | 334 | } |
| 270 | 335 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 271 | 336 | |
@@ -274,20 +339,31 @@ discard block |
||
| 274 | 339 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 275 | 340 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 276 | 341 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 277 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "Check if aircraft is already in DB..."; |
|
| 344 | + } |
|
| 278 | 345 | $timeelapsed = microtime(true); |
| 279 | 346 | $TrackerLive = new TrackerLive($this->db); |
| 280 | 347 | if (isset($line['id'])) { |
| 281 | 348 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 349 | + if ($globalDebugTimeElapsed) { |
|
| 350 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 351 | + } |
|
| 283 | 352 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 284 | 353 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 286 | - } else $recent_ident = ''; |
|
| 354 | + if ($globalDebugTimeElapsed) { |
|
| 355 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | + $recent_ident = ''; |
|
| 359 | + } |
|
| 287 | 360 | $TrackerLive->db=null; |
| 288 | 361 | |
| 289 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 290 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 362 | + if ($globalDebug && $recent_ident == '') { |
|
| 363 | + echo " Not in DB.\n"; |
|
| 364 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 365 | + echo " Already in DB.\n"; |
|
| 366 | + } |
|
| 291 | 367 | } else { |
| 292 | 368 | $recent_ident = ''; |
| 293 | 369 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -295,16 +371,24 @@ discard block |
||
| 295 | 371 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 296 | 372 | if($recent_ident == "") |
| 297 | 373 | { |
| 298 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 374 | + if ($globalDebug) { |
|
| 375 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 376 | + } |
|
| 299 | 377 | //adds the spotter data for the archive |
| 300 | 378 | $highlight = ''; |
| 301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 379 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 380 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 381 | + } |
|
| 302 | 382 | $timeelapsed = microtime(true); |
| 303 | 383 | $Tracker = new Tracker($this->db); |
| 304 | 384 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 305 | 385 | $Tracker->db = null; |
| 306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 386 | + if ($globalDebug && isset($result)) { |
|
| 387 | + echo $result."\n"; |
|
| 388 | + } |
|
| 389 | + if ($globalDebugTimeElapsed) { |
|
| 390 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 391 | + } |
|
| 308 | 392 | |
| 309 | 393 | /* |
| 310 | 394 | // Add source stat in DB |
@@ -338,12 +422,16 @@ discard block |
||
| 338 | 422 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 339 | 423 | //print_r($this->all_tracked[$id]); |
| 340 | 424 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 425 | + if ($globalDebug) { |
|
| 426 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 427 | + } |
|
| 342 | 428 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 343 | 429 | $TrackerLive = new TrackerLive($this->db); |
| 344 | 430 | $TrackerLive->deleteLiveTrackerData(); |
| 345 | 431 | $TrackerLive->db=null; |
| 346 | - if ($globalDebug) echo " Done\n"; |
|
| 432 | + if ($globalDebug) { |
|
| 433 | + echo " Done\n"; |
|
| 434 | + } |
|
| 347 | 435 | $this->last_delete = time(); |
| 348 | 436 | } |
| 349 | 437 | } else { |
@@ -366,13 +454,17 @@ discard block |
||
| 366 | 454 | |
| 367 | 455 | if (!$ignoreImport) { |
| 368 | 456 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 369 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 457 | + if ($globalDebug) { |
|
| 458 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 459 | + } |
|
| 370 | 460 | $timeelapsed = microtime(true); |
| 371 | 461 | $TrackerLive = new TrackerLive($this->db); |
| 372 | 462 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 373 | 463 | $TrackerLive->db = null; |
| 374 | 464 | $this->all_tracked[$id]['putinarchive'] = false; |
| 375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 465 | + if ($globalDebugTimeElapsed) { |
|
| 466 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 467 | + } |
|
| 376 | 468 | |
| 377 | 469 | // Put statistics in $this->stats variable |
| 378 | 470 | /* |
@@ -429,19 +521,29 @@ discard block |
||
| 429 | 521 | */ |
| 430 | 522 | |
| 431 | 523 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 524 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 525 | + $send = true; |
|
| 526 | + } |
|
| 527 | + if ($globalDebug) { |
|
| 528 | + echo $result."\n"; |
|
| 529 | + } |
|
| 530 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 531 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 532 | + } |
|
| 435 | 533 | //$this->del(); |
| 436 | 534 | |
| 437 | 535 | |
| 438 | 536 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 537 | + if ($globalDebug) { |
|
| 538 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 539 | + } |
|
| 440 | 540 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 541 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 542 | $TrackerLive->db = null; |
| 443 | 543 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 544 | + if ($globalDebug) { |
|
| 545 | + echo " Done\n"; |
|
| 546 | + } |
|
| 445 | 547 | $this->last_delete_hourly = time(); |
| 446 | 548 | } |
| 447 | 549 | |
@@ -449,7 +551,9 @@ discard block |
||
| 449 | 551 | //$ignoreImport = false; |
| 450 | 552 | } |
| 451 | 553 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 554 | + if ($send) { |
|
| 555 | + return $this->all_tracked[$id]; |
|
| 556 | + } |
|
| 453 | 557 | } |
| 454 | 558 | } |
| 455 | 559 | } |