@@ -16,62 +16,62 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | 85 | } |
| 86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | 117 | } |
| 118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 120 | 120 | } |
| 121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 123 | 123 | if ($filter_query_where != '') { |
| 124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 125 | 125 | } |
| 126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
| 127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | if ($limit != '') |
| 145 | 145 | { |
| 146 | 146 | $limit_array = explode(',', $limit); |
| 147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 150 | 150 | { |
| 151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } else { |
| 170 | 170 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 171 | 171 | } |
| 172 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 172 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 173 | 173 | |
| 174 | 174 | return $spotter_array; |
| 175 | 175 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 186 | 186 | date_default_timezone_set('UTC'); |
| 187 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 187 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 188 | 188 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 189 | 189 | if ($globalDBdriver == 'mysql') { |
| 190 | 190 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | $sth = $this->db->prepare($query); |
| 209 | 209 | $sth->execute(); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | echo $e->getMessage(); |
| 212 | 212 | die; |
| 213 | 213 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 227 | 227 | date_default_timezone_set('UTC'); |
| 228 | 228 | |
| 229 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 229 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 230 | 230 | |
| 231 | 231 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 232 | 232 | if ($globalDBdriver == 'mysql') { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 238 | 238 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 239 | 239 | */ |
| 240 | - $query = 'SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
|
| 240 | + $query = 'SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
|
| 241 | 241 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id |
| 242 | 242 | UNION |
| 243 | 243 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | WHERE latitude <> '0' AND longitude <> '0' |
| 246 | 246 | ORDER BY flightaware_id, date"; |
| 247 | 247 | } else { |
| 248 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 248 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 249 | 249 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date |
| 250 | 250 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
| 259 | 259 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
| 260 | 260 | */ |
| 261 | - $query = "SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
|
| 261 | + $query = "SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
|
| 262 | 262 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id |
| 263 | 263 | UNION |
| 264 | 264 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | ORDER BY flightaware_id, date"; |
| 269 | 269 | //AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".round($globalLiveInterval*1000)." SECONDS' <= spotter_archive.date |
| 270 | 270 | } else { |
| 271 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 271 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 272 | 272 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 273 | 273 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 274 | 274 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | try { |
| 278 | 278 | $sth = $this->db->prepare($query); |
| 279 | 279 | $sth->execute(); |
| 280 | - } catch(PDOException $e) { |
|
| 280 | + } catch (PDOException $e) { |
|
| 281 | 281 | echo $e->getMessage(); |
| 282 | 282 | die; |
| 283 | 283 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | public function getLiveSpotterCount($filter = array()) |
| 295 | 295 | { |
| 296 | 296 | global $globalDBdriver, $globalLiveInterval; |
| 297 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 297 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 298 | 298 | |
| 299 | 299 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 300 | 300 | if ($globalDBdriver == 'mysql') { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | try { |
| 308 | 308 | $sth = $this->db->prepare($query); |
| 309 | 309 | $sth->execute(); |
| 310 | - } catch(PDOException $e) { |
|
| 310 | + } catch (PDOException $e) { |
|
| 311 | 311 | echo $e->getMessage(); |
| 312 | 312 | die; |
| 313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | $filter_query = $this->getFilter($filter); |
| 331 | 331 | |
| 332 | 332 | if (is_array($coord)) { |
| 333 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 334 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 335 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 336 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 333 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 334 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 335 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 336 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 337 | 337 | } else return array(); |
| 338 | 338 | if ($globalDBdriver == 'mysql') { |
| 339 | 339 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -356,23 +356,23 @@ discard block |
||
| 356 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 357 | 357 | $Spotter = new Spotter($this->db); |
| 358 | 358 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 359 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 359 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 360 | 360 | |
| 361 | 361 | if (is_array($coord)) { |
| 362 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 363 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 364 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 365 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 362 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 363 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 364 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 365 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 366 | 366 | } else return array(); |
| 367 | 367 | if ($globalDBdriver == 'mysql') { |
| 368 | 368 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 369 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 369 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 370 | 370 | FROM spotter_live |
| 371 | 371 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 372 | 372 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 373 | 373 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 374 | 374 | } else { |
| 375 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 375 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 376 | 376 | FROM spotter_live |
| 377 | 377 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 378 | 378 | FROM spotter_live l |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | } else { |
| 386 | 386 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 387 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 387 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 388 | 388 | FROM spotter_live |
| 389 | 389 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 390 | 390 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 391 | 391 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 392 | 392 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 393 | 393 | } else { |
| 394 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 394 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 395 | 395 | FROM spotter_live |
| 396 | 396 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 397 | 397 | FROM spotter_live l |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | try { |
| 407 | 407 | $sth = $this->db->prepare($query); |
| 408 | 408 | $sth->execute(); |
| 409 | - } catch(PDOException $e) { |
|
| 409 | + } catch (PDOException $e) { |
|
| 410 | 410 | echo $e->getMessage(); |
| 411 | 411 | die; |
| 412 | 412 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | if ($interval == '1m') |
| 456 | 456 | { |
| 457 | 457 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 458 | - } else if ($interval == '15m'){ |
|
| 458 | + } else if ($interval == '15m') { |
|
| 459 | 459 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 466 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 467 | 467 | WHERE spotter_live.latitude <> '' |
| 468 | 468 | AND spotter_live.longitude <> '' |
| 469 | 469 | ".$additional_query." |
| 470 | 470 | HAVING distance < :radius |
| 471 | 471 | ORDER BY distance"; |
| 472 | 472 | |
| 473 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 474 | 474 | |
| 475 | 475 | return $spotter_array; |
| 476 | 476 | } |
@@ -488,9 +488,9 @@ discard block |
||
| 488 | 488 | date_default_timezone_set('UTC'); |
| 489 | 489 | |
| 490 | 490 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 491 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 491 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 492 | 492 | |
| 493 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 493 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 494 | 494 | |
| 495 | 495 | return $spotter_array; |
| 496 | 496 | } |
@@ -501,16 +501,16 @@ discard block |
||
| 501 | 501 | * @return Array the spotter information |
| 502 | 502 | * |
| 503 | 503 | */ |
| 504 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 504 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 505 | 505 | { |
| 506 | 506 | $Spotter = new Spotter($this->db); |
| 507 | 507 | date_default_timezone_set('UTC'); |
| 508 | 508 | |
| 509 | 509 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 510 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 510 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 511 | 511 | |
| 512 | - $date = date('c',$date); |
|
| 513 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 512 | + $date = date('c', $date); |
|
| 513 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 514 | 514 | |
| 515 | 515 | return $spotter_array; |
| 516 | 516 | } |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | $Spotter = new Spotter($this->db); |
| 527 | 527 | date_default_timezone_set('UTC'); |
| 528 | 528 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 529 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 530 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 529 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 530 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 531 | 531 | return $spotter_array; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -537,15 +537,15 @@ discard block |
||
| 537 | 537 | * @return Array the spotter information |
| 538 | 538 | * |
| 539 | 539 | */ |
| 540 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 540 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 541 | 541 | { |
| 542 | 542 | $Spotter = new Spotter($this->db); |
| 543 | 543 | date_default_timezone_set('UTC'); |
| 544 | 544 | |
| 545 | 545 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 546 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 547 | - $date = date('c',$date); |
|
| 548 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 546 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 547 | + $date = date('c', $date); |
|
| 548 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 549 | 549 | return $spotter_array; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -561,13 +561,13 @@ discard block |
||
| 561 | 561 | date_default_timezone_set('UTC'); |
| 562 | 562 | |
| 563 | 563 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 564 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 564 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 565 | 565 | |
| 566 | 566 | try { |
| 567 | 567 | |
| 568 | 568 | $sth = $this->db->prepare($query); |
| 569 | 569 | $sth->execute(array(':ident' => $ident)); |
| 570 | - } catch(PDOException $e) { |
|
| 570 | + } catch (PDOException $e) { |
|
| 571 | 571 | echo $e->getMessage(); |
| 572 | 572 | die; |
| 573 | 573 | } |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @return Array the spotter information |
| 583 | 583 | * |
| 584 | 584 | */ |
| 585 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 585 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 586 | 586 | { |
| 587 | 587 | global $globalDBdriver, $globalLiveInterval; |
| 588 | 588 | date_default_timezone_set('UTC'); |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | try { |
| 602 | 602 | $sth = $this->db->prepare($query); |
| 603 | 603 | $sth->execute(array(':id' => $id)); |
| 604 | - } catch(PDOException $e) { |
|
| 604 | + } catch (PDOException $e) { |
|
| 605 | 605 | echo $e->getMessage(); |
| 606 | 606 | die; |
| 607 | 607 | } |
@@ -619,12 +619,12 @@ discard block |
||
| 619 | 619 | { |
| 620 | 620 | date_default_timezone_set('UTC'); |
| 621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 622 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 622 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 623 | 623 | try { |
| 624 | 624 | |
| 625 | 625 | $sth = $this->db->prepare($query); |
| 626 | 626 | $sth->execute(array(':ident' => $ident)); |
| 627 | - } catch(PDOException $e) { |
|
| 627 | + } catch (PDOException $e) { |
|
| 628 | 628 | echo $e->getMessage(); |
| 629 | 629 | die; |
| 630 | 630 | } |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | $sth = $this->db->prepare($query); |
| 656 | 656 | $sth->execute(); |
| 657 | - } catch(PDOException $e) { |
|
| 657 | + } catch (PDOException $e) { |
|
| 658 | 658 | return "error"; |
| 659 | 659 | } |
| 660 | 660 | |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $sth = $this->db->prepare($query); |
| 679 | 679 | $sth->execute(); |
| 680 | - } catch(PDOException $e) { |
|
| 680 | + } catch (PDOException $e) { |
|
| 681 | 681 | return "error"; |
| 682 | 682 | } |
| 683 | 683 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 684 | 684 | $i = 0; |
| 685 | - $j =0; |
|
| 685 | + $j = 0; |
|
| 686 | 686 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 687 | - foreach($all as $row) |
|
| 687 | + foreach ($all as $row) |
|
| 688 | 688 | { |
| 689 | 689 | $i++; |
| 690 | 690 | $j++; |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | if ($globalDebug) echo "."; |
| 693 | 693 | try { |
| 694 | 694 | |
| 695 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 695 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 696 | 696 | $sth->execute(); |
| 697 | - } catch(PDOException $e) { |
|
| 697 | + } catch (PDOException $e) { |
|
| 698 | 698 | return "error"; |
| 699 | 699 | } |
| 700 | 700 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -705,9 +705,9 @@ discard block |
||
| 705 | 705 | if ($i > 0) { |
| 706 | 706 | try { |
| 707 | 707 | |
| 708 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 708 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 709 | 709 | $sth->execute(); |
| 710 | - } catch(PDOException $e) { |
|
| 710 | + } catch (PDOException $e) { |
|
| 711 | 711 | return "error"; |
| 712 | 712 | } |
| 713 | 713 | } |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | |
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute(); |
| 723 | - } catch(PDOException $e) { |
|
| 723 | + } catch (PDOException $e) { |
|
| 724 | 724 | return "error"; |
| 725 | 725 | } |
| 726 | 726 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -768,13 +768,13 @@ discard block |
||
| 768 | 768 | public function deleteLiveSpotterDataByIdent($ident) |
| 769 | 769 | { |
| 770 | 770 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 771 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 771 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 772 | 772 | |
| 773 | 773 | try { |
| 774 | 774 | |
| 775 | 775 | $sth = $this->db->prepare($query); |
| 776 | 776 | $sth->execute(array(':ident' => $ident)); |
| 777 | - } catch(PDOException $e) { |
|
| 777 | + } catch (PDOException $e) { |
|
| 778 | 778 | return "error"; |
| 779 | 779 | } |
| 780 | 780 | |
@@ -790,13 +790,13 @@ discard block |
||
| 790 | 790 | public function deleteLiveSpotterDataById($id) |
| 791 | 791 | { |
| 792 | 792 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 793 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 793 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 794 | 794 | |
| 795 | 795 | try { |
| 796 | 796 | |
| 797 | 797 | $sth = $this->db->prepare($query); |
| 798 | 798 | $sth->execute(array(':id' => $id)); |
| 799 | - } catch(PDOException $e) { |
|
| 799 | + } catch (PDOException $e) { |
|
| 800 | 800 | return "error"; |
| 801 | 801 | } |
| 802 | 802 | |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | { |
| 815 | 815 | global $globalDBdriver, $globalTimezone; |
| 816 | 816 | if ($globalDBdriver == 'mysql') { |
| 817 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 817 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 818 | 818 | WHERE spotter_live.ident = :ident |
| 819 | 819 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 820 | 820 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 821 | 821 | $query_data = array(':ident' => $ident); |
| 822 | 822 | } else { |
| 823 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 823 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 824 | 824 | WHERE spotter_live.ident = :ident |
| 825 | 825 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 826 | 826 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -829,8 +829,8 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | $sth = $this->db->prepare($query); |
| 831 | 831 | $sth->execute($query_data); |
| 832 | - $ident_result=''; |
|
| 833 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 832 | + $ident_result = ''; |
|
| 833 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 834 | 834 | { |
| 835 | 835 | $ident_result = $row['ident']; |
| 836 | 836 | } |
@@ -847,13 +847,13 @@ discard block |
||
| 847 | 847 | { |
| 848 | 848 | global $globalDBdriver, $globalTimezone; |
| 849 | 849 | if ($globalDBdriver == 'mysql') { |
| 850 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 850 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 851 | 851 | WHERE spotter_live.ident = :ident |
| 852 | 852 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 853 | 853 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 854 | 854 | $query_data = array(':ident' => $ident); |
| 855 | 855 | } else { |
| 856 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 856 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 857 | 857 | WHERE spotter_live.ident = :ident |
| 858 | 858 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 859 | 859 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -862,8 +862,8 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $sth = $this->db->prepare($query); |
| 864 | 864 | $sth->execute($query_data); |
| 865 | - $ident_result=''; |
|
| 866 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 865 | + $ident_result = ''; |
|
| 866 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 867 | 867 | { |
| 868 | 868 | $ident_result = $row['flightaware_id']; |
| 869 | 869 | } |
@@ -880,13 +880,13 @@ discard block |
||
| 880 | 880 | { |
| 881 | 881 | global $globalDBdriver, $globalTimezone; |
| 882 | 882 | if ($globalDBdriver == 'mysql') { |
| 883 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 883 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 884 | 884 | WHERE spotter_live.flightaware_id = :id |
| 885 | 885 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 886 | 886 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 887 | 887 | $query_data = array(':id' => $id); |
| 888 | 888 | } else { |
| 889 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 889 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 890 | 890 | WHERE spotter_live.flightaware_id = :id |
| 891 | 891 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 892 | 892 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | $sth = $this->db->prepare($query); |
| 897 | 897 | $sth->execute($query_data); |
| 898 | - $ident_result=''; |
|
| 899 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 898 | + $ident_result = ''; |
|
| 899 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 900 | 900 | { |
| 901 | 901 | $ident_result = $row['flightaware_id']; |
| 902 | 902 | } |
@@ -913,13 +913,13 @@ discard block |
||
| 913 | 913 | { |
| 914 | 914 | global $globalDBdriver, $globalTimezone; |
| 915 | 915 | if ($globalDBdriver == 'mysql') { |
| 916 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 916 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 917 | 917 | WHERE spotter_live.ModeS = :modes |
| 918 | 918 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 919 | 919 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 920 | 920 | $query_data = array(':modes' => $modes); |
| 921 | 921 | } else { |
| 922 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 922 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 923 | 923 | WHERE spotter_live.ModeS = :modes |
| 924 | 924 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 925 | 925 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -928,8 +928,8 @@ discard block |
||
| 928 | 928 | |
| 929 | 929 | $sth = $this->db->prepare($query); |
| 930 | 930 | $sth->execute($query_data); |
| 931 | - $ident_result=''; |
|
| 932 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 931 | + $ident_result = ''; |
|
| 932 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 933 | 933 | { |
| 934 | 934 | //$ident_result = $row['spotter_live_id']; |
| 935 | 935 | $ident_result = $row['flightaware_id']; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @return String success or false |
| 949 | 949 | * |
| 950 | 950 | */ |
| 951 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 951 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 952 | 952 | { |
| 953 | 953 | global $globalURL, $globalArchive, $globalDebug; |
| 954 | 954 | $Common = new Common(); |
@@ -1048,27 +1048,27 @@ discard block |
||
| 1048 | 1048 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1049 | 1049 | |
| 1050 | 1050 | |
| 1051 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1052 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1053 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1054 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1055 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1056 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1057 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1058 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1059 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1065 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1066 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1067 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1068 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1069 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1070 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1071 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1052 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1053 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1054 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1055 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1056 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1057 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1058 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1059 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1065 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1066 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1067 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1068 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1069 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1070 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1071 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1072 | 1072 | |
| 1073 | 1073 | $airline_name = ''; |
| 1074 | 1074 | $airline_icao = ''; |
@@ -1090,10 +1090,10 @@ discard block |
||
| 1090 | 1090 | $arrival_airport_country = ''; |
| 1091 | 1091 | |
| 1092 | 1092 | |
| 1093 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1094 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1095 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1096 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1093 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1094 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1095 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1096 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1097 | 1097 | |
| 1098 | 1098 | $query = ''; |
| 1099 | 1099 | if ($globalArchive) { |
@@ -1104,19 +1104,19 @@ discard block |
||
| 1104 | 1104 | $query .= 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
| 1105 | 1105 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
| 1106 | 1106 | |
| 1107 | - $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_type' => $aircraft_type,':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,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
| 1107 | + $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_type' => $aircraft_type, ':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, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
| 1108 | 1108 | try { |
| 1109 | 1109 | |
| 1110 | 1110 | $sth = $this->db->prepare($query); |
| 1111 | 1111 | $sth->execute($query_values); |
| 1112 | 1112 | $sth->closeCursor(); |
| 1113 | - } catch(PDOException $e) { |
|
| 1113 | + } catch (PDOException $e) { |
|
| 1114 | 1114 | return "error : ".$e->getMessage(); |
| 1115 | 1115 | } |
| 1116 | 1116 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1117 | 1117 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1118 | 1118 | $SpotterArchive = new SpotterArchive($this->db); |
| 1119 | - $result = $SpotterArchive->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, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1119 | + $result = $SpotterArchive->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, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1120 | 1120 | if ($globalDebug) echo $result.')'; |
| 1121 | 1121 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1122 | 1122 | echo '(Not adding to archive)'; |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | |
| 1130 | 1130 | public function getOrderBy() |
| 1131 | 1131 | { |
| 1132 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1132 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1133 | 1133 | return $orderby; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $currentdate = date('Y-m-d'); |
| 34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 35 | 35 | if (!empty($sourcestat)) { |
| 36 | - foreach($sourcestat as $srcst) { |
|
| 36 | + foreach ($sourcestat as $srcst) { |
|
| 37 | 37 | $type = $srcst['stats_type']; |
| 38 | 38 | if ($type == 'polar' || $type == 'hist') { |
| 39 | 39 | $source = $srcst['source_name']; |
| 40 | 40 | $data = $srcst['source_data']; |
| 41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 41 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function get_Schedule($id,$ident) { |
|
| 53 | + public function get_Schedule($id, $ident) { |
|
| 54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 55 | 55 | // Get schedule here, so it's done only one time |
| 56 | 56 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
| 76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 77 | 77 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 80 | 80 | // Should also check if route schedule = route from DB |
| 81 | 81 | if ($schedule['DepartureAirportIATA'] != '') { |
| 82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 99 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
| 100 | 100 | } |
| 101 | 101 | } else $scheduleexist = true; |
| 102 | 102 | } else $scheduleexist = true; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if ($scheduleexist) { |
| 105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 106 | 106 | $sch = $Schedule->getSchedule($operator); |
| 107 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 107 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 108 | 108 | } |
| 109 | 109 | $Spotter->db = null; |
| 110 | 110 | $Schedule->db = null; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 132 | 132 | $Spotter = new Spotter($this->db); |
| 133 | 133 | $real_arrival = $this->arrival($key); |
| 134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 134 | + if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $airport_time = ''; |
| 146 | 146 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 149 | 149 | if (isset($closestAirports[0])) { |
| 150 | 150 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 151 | 151 | $airport_icao = $closestAirports[0]['icao']; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
| 164 | 164 | $airport_icao = $closestAirports[0]['icao']; |
| 165 | 165 | $airport_time = $this->all_flights[$key]['datetime']; |
| 166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } else { |
| 174 | 174 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 175 | 175 | } |
| 176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 176 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 185 | 185 | foreach ($this->all_flights as $key => $flight) { |
| 186 | 186 | if (isset($flight['lastupdate'])) { |
| 187 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
| 187 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
| 188 | 188 | $this->delKey($key); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $real_arrival = $this->arrival($key); |
| 201 | 201 | $Spotter = new Spotter($this->db); |
| 202 | 202 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 203 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 203 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 204 | 204 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $send = false; |
| 234 | 234 | |
| 235 | 235 | // SBS format is CSV format |
| 236 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 236 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 237 | 237 | //print_r($line); |
| 238 | 238 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
| 239 | 239 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -269,25 +269,25 @@ discard block |
||
| 269 | 269 | if (!isset($this->all_flights[$id])) { |
| 270 | 270 | if ($globalDebug) echo 'New flight...'."\n"; |
| 271 | 271 | $this->all_flights[$id] = array(); |
| 272 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 273 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
| 274 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 272 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 273 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
| 274 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 275 | 275 | if (!isset($line['id'])) { |
| 276 | 276 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 277 | 277 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 278 | 278 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 279 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 279 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 280 | 280 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 281 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 281 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 282 | 282 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 283 | 283 | } |
| 284 | 284 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | //print_r($this->all_flights); |
| 289 | 289 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 290 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 290 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 291 | 291 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 292 | 292 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 293 | 293 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -296,27 +296,27 @@ discard block |
||
| 296 | 296 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 297 | 297 | $Spotter = new Spotter($this->db); |
| 298 | 298 | if (isset($this->all_flights[$id]['source_type'])) { |
| 299 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 299 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 300 | 300 | } else { |
| 301 | 301 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 302 | 302 | } |
| 303 | 303 | $Spotter->db = null; |
| 304 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 305 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 304 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 305 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 309 | 309 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 310 | 310 | } |
| 311 | 311 | if (isset($line['id']) && !isset($line['hex'])) { |
| 312 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
| 312 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
| 313 | 313 | } |
| 314 | 314 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 315 | 315 | $icao = $line['aircraft_icao']; |
| 316 | 316 | $Spotter = new Spotter($this->db); |
| 317 | 317 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
| 318 | 318 | $Spotter->db = null; |
| 319 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
| 319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
| 320 | 320 | } |
| 321 | 321 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 322 | 322 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $Spotter = new Spotter($this->db); |
| 325 | 325 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 326 | 326 | $Spotter->db = null; |
| 327 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 327 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 333 | 333 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 334 | 334 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 335 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 335 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 336 | 336 | } |
| 337 | 337 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 339 | 339 | } |
| 340 | 340 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 341 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 341 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 342 | 342 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 343 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 343 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 344 | 344 | } else { |
| 345 | 345 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 346 | 346 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -351,32 +351,32 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | return ''; |
| 353 | 353 | } |
| 354 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 354 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 355 | 355 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
| 356 | 356 | return ''; |
| 357 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 357 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 358 | 358 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n |
| 359 | 359 | "; |
| 360 | 360 | return ''; |
| 361 | 361 | } elseif (!isset($line['datetime'])) { |
| 362 | 362 | date_default_timezone_set('UTC'); |
| 363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 364 | 364 | } else { |
| 365 | 365 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
| 366 | 366 | return ''; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 371 | 371 | } |
| 372 | 372 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 373 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 373 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 374 | 374 | } |
| 375 | 375 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
| 376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
| 377 | 377 | } |
| 378 | 378 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
| 379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -384,13 +384,13 @@ discard block |
||
| 384 | 384 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 385 | 385 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 386 | 386 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
| 387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 389 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 390 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 391 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 389 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 390 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 391 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 392 | 392 | } else { |
| 393 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 393 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 395 | 395 | $timeelapsed = microtime(true); |
| 396 | 396 | $Spotter = new Spotter($this->db); |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 401 | 401 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 402 | 402 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 403 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 403 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 404 | 404 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 405 | 405 | $Spotter->db = null; |
| 406 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 406 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 409 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 410 | 410 | |
| 411 | 411 | /* |
| 412 | 412 | if (!isset($line['id'])) { |
@@ -416,25 +416,25 @@ discard block |
||
| 416 | 416 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 417 | 417 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 418 | 418 | */ |
| 419 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 419 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 420 | 420 | |
| 421 | 421 | //$putinarchive = true; |
| 422 | 422 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 423 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 423 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 424 | 424 | } |
| 425 | 425 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 426 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 426 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 427 | 427 | } |
| 428 | 428 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 429 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 430 | 430 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 431 | 431 | $timeelapsed = microtime(true); |
| 432 | 432 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 433 | 433 | $Spotter = new Spotter($this->db); |
| 434 | 434 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 435 | 435 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 437 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 437 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 438 | 438 | } |
| 439 | 439 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 440 | 440 | $timeelapsed = microtime(true); |
@@ -448,35 +448,35 @@ discard block |
||
| 448 | 448 | $Translation->db = null; |
| 449 | 449 | } |
| 450 | 450 | $Spotter->db = null; |
| 451 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 451 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 452 | 452 | } |
| 453 | 453 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 454 | 454 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 455 | 455 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 456 | 456 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 457 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 457 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | if (!isset($globalFork)) $globalFork = TRUE; |
| 461 | 461 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 462 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 462 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
| 468 | 468 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 469 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 470 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 469 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 470 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 471 | 471 | //$dataFound = true; |
| 472 | 472 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 473 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 473 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 474 | 474 | if ($distance > 1000 && $distance < 10000) { |
| 475 | 475 | // use datetime |
| 476 | 476 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 477 | 477 | $speed = $speed*3.6; |
| 478 | 478 | if ($speed < 1000) { |
| 479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 480 | 480 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
| 481 | 481 | } else { |
| 482 | 482 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
| 492 | 492 | return false; |
| 493 | 493 | } |
| 494 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 494 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 495 | 495 | else unset($timediff); |
| 496 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 496 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
| 497 | 497 | else unset($timediff_archive); |
| 498 | 498 | if ($this->tmd > 5 |
| 499 | 499 | || (isset($line['format_source']) |
@@ -517,14 +517,14 @@ discard block |
||
| 517 | 517 | || ($timediff > 30 |
| 518 | 518 | && isset($this->all_flights[$id]['latitude']) |
| 519 | 519 | && isset($this->all_flights[$id]['longitude']) |
| 520 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
| 520 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
| 521 | 521 | ) |
| 522 | 522 | ) { |
| 523 | 523 | |
| 524 | 524 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
| 525 | 525 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
| 526 | 526 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
| 527 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 527 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 528 | 528 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 529 | 529 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 530 | 530 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -534,11 +534,11 @@ discard block |
||
| 534 | 534 | $timeelapsed = microtime(true); |
| 535 | 535 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 536 | 536 | $Spotter = new Spotter($this->db); |
| 537 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 537 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 538 | 538 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 539 | 539 | else $this->all_flights[$id]['over_country'] = ''; |
| 540 | 540 | $Spotter->db = null; |
| 541 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 541 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 542 | 542 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 543 | 543 | } |
| 544 | 544 | } |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 565 | 565 | } |
| 566 | 566 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
| 567 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
| 567 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
| 568 | 568 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 569 | 569 | $dataFound = true; |
| 570 | 570 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 571 | 571 | } |
| 572 | 572 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 573 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 573 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 574 | 574 | /* |
| 575 | 575 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 576 | 576 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 593 | 593 | } |
| 594 | 594 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
| 595 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
| 595 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
| 596 | 596 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 597 | 597 | $dataFound = true; |
| 598 | 598 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 599 | 599 | } |
| 600 | 600 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 601 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 601 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 602 | 602 | /* |
| 603 | 603 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 604 | 604 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -616,46 +616,46 @@ discard block |
||
| 616 | 616 | } else if ($globalDebug && $timediff > 30) { |
| 617 | 617 | $this->tmd = $this->tmd + 1; |
| 618 | 618 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 619 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 620 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 619 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 620 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 621 | 621 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 625 | 625 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 626 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 626 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 627 | 627 | } |
| 628 | 628 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 629 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 629 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 630 | 630 | //$dataFound = true; |
| 631 | 631 | } |
| 632 | 632 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 634 | 634 | } |
| 635 | 635 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 637 | 637 | } |
| 638 | 638 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 639 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 639 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 640 | 640 | //$dataFound = true; |
| 641 | 641 | } |
| 642 | 642 | if (isset($line['ground']) && $line['ground'] != '') { |
| 643 | 643 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 644 | 644 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 647 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 648 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 649 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 647 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 648 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 649 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 650 | 650 | } |
| 651 | 651 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 653 | 653 | //$dataFound = true; |
| 654 | 654 | } |
| 655 | 655 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 656 | 656 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 657 | 657 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 658 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 658 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 659 | 659 | $highlight = ''; |
| 660 | 660 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 661 | 661 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -664,59 +664,59 @@ discard block |
||
| 664 | 664 | $timeelapsed = microtime(true); |
| 665 | 665 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 666 | 666 | $Spotter = new Spotter($this->db); |
| 667 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 667 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 668 | 668 | $Spotter->db = null; |
| 669 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 669 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 670 | 670 | } |
| 671 | 671 | //$putinarchive = true; |
| 672 | 672 | //$highlight = ''; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 675 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 676 | 676 | //$dataFound = true; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 680 | 680 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 681 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 682 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 683 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 681 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 682 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 683 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 684 | 684 | //$dataFound = true; |
| 685 | 685 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 686 | 686 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 687 | 687 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 688 | 688 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
| 689 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 690 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 691 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 692 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 693 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 689 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 690 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 691 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 692 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 693 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
| 696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 700 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 700 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | if (isset($line['heading']) && $line['heading'] != '') { |
| 704 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 705 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 704 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 705 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 707 | 707 | //$dataFound = true; |
| 708 | 708 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 709 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 711 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 709 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 711 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 712 | 712 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
| 713 | 713 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 714 | 714 | // If not enough messages and ACARS set heading to 0 |
| 715 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 715 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 716 | 716 | } |
| 717 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 718 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 719 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 717 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 718 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 719 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
| 720 | 720 | |
| 721 | 721 | // print_r($this->all_flights[$id]); |
| 722 | 722 | //gets the callsign from the last hour |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
| 728 | 728 | $this->all_flights[$id]['lastupdate'] = time(); |
| 729 | 729 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
| 730 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 730 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 731 | 731 | //print_r($this->all_flights); |
| 732 | 732 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 733 | 733 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -738,61 +738,61 @@ discard block |
||
| 738 | 738 | $SpotterLive = new SpotterLive($this->db); |
| 739 | 739 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 740 | 740 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 741 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 741 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 742 | 742 | } elseif (isset($line['id'])) { |
| 743 | 743 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 744 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 744 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 745 | 745 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 746 | 746 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 747 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 747 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 748 | 748 | } else $recent_ident = ''; |
| 749 | - $SpotterLive->db=null; |
|
| 749 | + $SpotterLive->db = null; |
|
| 750 | 750 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 751 | 751 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 752 | 752 | } else $recent_ident = ''; |
| 753 | 753 | } else { |
| 754 | 754 | $recent_ident = ''; |
| 755 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 755 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 756 | 756 | } |
| 757 | 757 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 758 | - if($recent_ident == "") |
|
| 758 | + if ($recent_ident == "") |
|
| 759 | 759 | { |
| 760 | 760 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 761 | 761 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 762 | 762 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 763 | 763 | //adds the spotter data for the archive |
| 764 | 764 | $ignoreImport = false; |
| 765 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 765 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 766 | 766 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 767 | 767 | $ignoreImport = true; |
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | if (count($globalAirportAccept) > 0) { |
| 771 | 771 | $ignoreImport = true; |
| 772 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 772 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 773 | 773 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 774 | 774 | $ignoreImport = false; |
| 775 | 775 | } |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 779 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 780 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 779 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 780 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 781 | 781 | $ignoreImport = true; |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 786 | 786 | $ignoreImport = true; |
| 787 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 788 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 787 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 788 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 789 | 789 | $ignoreImport = false; |
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 794 | 794 | $ignoreImport = true; |
| 795 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 795 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 796 | 796 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 797 | 797 | $ignoreImport = false; |
| 798 | 798 | } |
@@ -804,32 +804,32 @@ discard block |
||
| 804 | 804 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 805 | 805 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 806 | 806 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 807 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 807 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 808 | 808 | $timeelapsed = microtime(true); |
| 809 | 809 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 810 | 810 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 811 | 811 | $Spotter = new Spotter($this->db); |
| 812 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
| 812 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
| 813 | 813 | $Spotter->db = null; |
| 814 | 814 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 815 | 815 | } |
| 816 | 816 | } |
| 817 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 817 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 818 | 818 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 819 | 819 | |
| 820 | 820 | // Add source stat in DB |
| 821 | 821 | $Stats = new Stats($this->db); |
| 822 | 822 | if (!empty($this->stats)) { |
| 823 | 823 | if ($globalDebug) echo 'Add source stats : '; |
| 824 | - foreach($this->stats as $date => $data) { |
|
| 825 | - foreach($data as $source => $sourced) { |
|
| 824 | + foreach ($this->stats as $date => $data) { |
|
| 825 | + foreach ($data as $source => $sourced) { |
|
| 826 | 826 | //print_r($sourced); |
| 827 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 828 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 827 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 828 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 829 | 829 | if (isset($sourced['msg'])) { |
| 830 | 830 | if (time() - $sourced['msg']['date'] > 10) { |
| 831 | 831 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 832 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 832 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 833 | 833 | unset($this->stats[$date][$source]['msg']); |
| 834 | 834 | } |
| 835 | 835 | } |
@@ -867,14 +867,14 @@ discard block |
||
| 867 | 867 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 868 | 868 | $SpotterLive = new SpotterLive($this->db); |
| 869 | 869 | $SpotterLive->deleteLiveSpotterData(); |
| 870 | - $SpotterLive->db=null; |
|
| 870 | + $SpotterLive->db = null; |
|
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | if ($globalDebug) echo " Done\n"; |
| 874 | 874 | $this->last_delete = time(); |
| 875 | 875 | } |
| 876 | 876 | } else { |
| 877 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 877 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
| 878 | 878 | $this->all_flights[$id]['id'] = $recent_ident; |
| 879 | 879 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 880 | 880 | } |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 884 | 884 | $Spotter = new Spotter($this->db); |
| 885 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 885 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
| 886 | 886 | $Spotter->db = null; |
| 887 | 887 | } |
| 888 | 888 | } |
@@ -908,37 +908,37 @@ discard block |
||
| 908 | 908 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 909 | 909 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 910 | 910 | |
| 911 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 911 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 912 | 912 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 913 | 913 | $ignoreImport = true; |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | if (count($globalAirportAccept) > 0) { |
| 917 | 917 | $ignoreImport = true; |
| 918 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 918 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 919 | 919 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 920 | 920 | $ignoreImport = false; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | } |
| 924 | 924 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 925 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 926 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 925 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 926 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 927 | 927 | $ignoreImport = true; |
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | } |
| 931 | 931 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 932 | 932 | $ignoreImport = true; |
| 933 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 934 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 933 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 934 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 935 | 935 | $ignoreImport = false; |
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 940 | 940 | $ignoreImport = true; |
| 941 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 941 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 942 | 942 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 943 | 943 | $ignoreImport = false; |
| 944 | 944 | } |
@@ -946,23 +946,23 @@ discard block |
||
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | if (!$ignoreImport) { |
| 949 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 950 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 949 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 950 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 951 | 951 | $timeelapsed = microtime(true); |
| 952 | 952 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 953 | 953 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 954 | 954 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 955 | 955 | $SpotterLive = new SpotterLive($this->db); |
| 956 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 956 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 957 | 957 | $SpotterLive->db = null; |
| 958 | 958 | if ($globalDebug) echo $result."\n"; |
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 962 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 962 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 963 | 963 | } |
| 964 | 964 | $this->all_flights[$id]['putinarchive'] = false; |
| 965 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 965 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 966 | 966 | |
| 967 | 967 | // Put statistics in $this->stats variable |
| 968 | 968 | //if ($line['format_source'] != 'aprs') { |
@@ -981,19 +981,19 @@ discard block |
||
| 981 | 981 | $latitude = $globalCenterLatitude; |
| 982 | 982 | $longitude = $globalCenterLongitude; |
| 983 | 983 | } |
| 984 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 984 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 985 | 985 | } else { |
| 986 | 986 | $latitude = $this->source_location[$source]['latitude']; |
| 987 | 987 | $longitude = $this->source_location[$source]['longitude']; |
| 988 | 988 | } |
| 989 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 989 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 990 | 990 | //$stats_heading = $stats_heading%22.5; |
| 991 | 991 | $stats_heading = round($stats_heading/22.5); |
| 992 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 992 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 993 | 993 | $current_date = date('Y-m-d'); |
| 994 | 994 | if ($stats_heading == 16) $stats_heading = 0; |
| 995 | 995 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 996 | - for ($i=0;$i<=15;$i++) { |
|
| 996 | + for ($i = 0; $i <= 15; $i++) { |
|
| 997 | 997 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 998 | 998 | } |
| 999 | 999 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1008,9 +1008,9 @@ discard block |
||
| 1008 | 1008 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 1009 | 1009 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1010 | 1010 | end($this->stats[$current_date][$source]['hist']); |
| 1011 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 1011 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 1012 | 1012 | } else $mini = 0; |
| 1013 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 1013 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 1014 | 1014 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1015 | 1015 | } |
| 1016 | 1016 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1024 | 1024 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 1025 | 1025 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1026 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1026 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 1027 | 1027 | //$this->del(); |
| 1028 | 1028 | |
| 1029 | 1029 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | $s3 = sin($bank/2); |
| 49 | 49 | $c1c2 = $c1*$c2; |
| 50 | 50 | $s1s2 = $s1*$s2; |
| 51 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
| 52 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
| 53 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
| 51 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
| 52 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
| 53 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
| 54 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
| 55 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
| 56 | 56 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
| 57 | 57 | |
| 58 | 58 | } |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | $min = false; |
| 74 | 74 | $allhistory = false; |
| 75 | 75 | $filter['source'] = array(); |
| 76 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 77 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 78 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 79 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 80 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 81 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 82 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 83 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 84 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 85 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 76 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 77 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 79 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 80 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 81 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 82 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 83 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 84 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 85 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 86 | 86 | /* |
| 87 | 87 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 88 | 88 | $min = true; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | $from_archive = true; |
| 130 | 130 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 131 | 131 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 132 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 136 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 137 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
| 132 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 133 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 134 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 135 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 136 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 137 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
| 138 | 138 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
| 139 | 139 | $from_archive = true; |
| 140 | 140 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | $begindate = $_COOKIE['archive_begin']; |
| 145 | 145 | $enddate = $_COOKIE['archive_end']; |
| 146 | 146 | |
| 147 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 149 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 147 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 149 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 150 | 150 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
| 151 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 151 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 152 | 152 | } elseif ($tracker) { |
| 153 | 153 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter); |
| 154 | 154 | } elseif ($marine) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | //print_r($spotter_array); |
| 160 | 160 | if (!empty($spotter_array)) { |
| 161 | 161 | if (isset($_GET['archive'])) { |
| 162 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 162 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 163 | 163 | } elseif ($tracker) { |
| 164 | 164 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
| 165 | 165 | } elseif ($marine) { |
@@ -170,16 +170,16 @@ discard block |
||
| 170 | 170 | if ($flightcnt == '') $flightcnt = 0; |
| 171 | 171 | } else $flightcnt = 0; |
| 172 | 172 | |
| 173 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 173 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 174 | 174 | $minitime = time(); |
| 175 | 175 | $maxitime = 0; |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | $modelsdb = array(); |
| 179 | 179 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
| 180 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
| 181 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
| 182 | - if (isset($row[1]) ){ |
|
| 180 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
| 181 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
| 182 | + if (isset($row[1])) { |
|
| 183 | 183 | $model = $row[0]; |
| 184 | 184 | $modelsdb[$model] = $row[1]; |
| 185 | 185 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $output .= '},'; |
| 216 | 216 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 217 | 217 | { |
| 218 | - foreach($spotter_array as $spotter_item) |
|
| 218 | + foreach ($spotter_array as $spotter_item) |
|
| 219 | 219 | { |
| 220 | 220 | $j++; |
| 221 | 221 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $output .= '"cartographicDegrees": ['; |
| 541 | 541 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
| 542 | 542 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 543 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 543 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 544 | 544 | $output .= $spotter_item['longitude'].', '; |
| 545 | 545 | $output .= $spotter_item['latitude']; |
| 546 | 546 | $prevlong = $spotter_item['longitude']; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
| 560 | 560 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
| 561 | 561 | } else { |
| 562 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
| 562 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
| 563 | 563 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
| 564 | 564 | if ($spotter_item['ground_speed'] == 0) { |
| 565 | 565 | $output .= $prevlong.', '; |
@@ -593,9 +593,9 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | $output .= ']'; |
| 595 | 595 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 596 | - if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
| 597 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 598 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
| 599 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
| 596 | + if ((time() - $globalLiveInterval) > $minitime) $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
| 597 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 598 | +} else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
| 599 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
| 600 | 600 | print $output; |
| 601 | 601 | ?> |