@@ -1,21 +1,21 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class SpotterArchive { |
| 3 | - public $global_query = "SELECT spotter_archive.* FROM spotter_archive"; |
|
| 4 | - public $db; |
|
| 3 | + public $global_query = "SELECT spotter_archive.* FROM spotter_archive"; |
|
| 4 | + public $db; |
|
| 5 | 5 | |
| 6 | - function __construct($dbc = null) { |
|
| 7 | - $Connection = new Connection($dbc); |
|
| 8 | - $this->db = $Connection->db; |
|
| 9 | - } |
|
| 6 | + function __construct($dbc = null) { |
|
| 7 | + $Connection = new Connection($dbc); |
|
| 8 | + $this->db = $Connection->db; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | |
| 12 | - // Spotter_archive |
|
| 12 | + // Spotter_archive |
|
| 13 | 13 | |
| 14 | - function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 14 | + function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 15 | 15 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 16 | - if ($over_country == '') { |
|
| 17 | - $Spotter = new Spotter($this->db); |
|
| 18 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 16 | + if ($over_country == '') { |
|
| 17 | + $Spotter = new Spotter($this->db); |
|
| 18 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 19 | 19 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 20 | 20 | else $country = ''; |
| 21 | 21 | } else $country = $over_country; |
@@ -28,55 +28,55 @@ discard block |
||
| 28 | 28 | $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
| 29 | 29 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
| 30 | 30 | |
| 31 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 32 | - try { |
|
| 33 | - $sth = $this->db->prepare($query); |
|
| 34 | - $sth->execute($query_values); |
|
| 35 | - } catch(PDOException $e) { |
|
| 36 | - return "error : ".$e->getMessage(); |
|
| 37 | - } |
|
| 38 | - return "success"; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Gets all the spotter information based on a particular callsign |
|
| 44 | - * |
|
| 45 | - * @return Array the spotter information |
|
| 46 | - * |
|
| 47 | - */ |
|
| 48 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 49 | - { |
|
| 31 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
| 32 | + try { |
|
| 33 | + $sth = $this->db->prepare($query); |
|
| 34 | + $sth->execute($query_values); |
|
| 35 | + } catch(PDOException $e) { |
|
| 36 | + return "error : ".$e->getMessage(); |
|
| 37 | + } |
|
| 38 | + return "success"; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Gets all the spotter information based on a particular callsign |
|
| 44 | + * |
|
| 45 | + * @return Array the spotter information |
|
| 46 | + * |
|
| 47 | + */ |
|
| 48 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 49 | + { |
|
| 50 | 50 | $Spotter = new Spotter($this->db); |
| 51 | - date_default_timezone_set('UTC'); |
|
| 51 | + date_default_timezone_set('UTC'); |
|
| 52 | 52 | |
| 53 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 54 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 55 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 53 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 54 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 55 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 56 | 56 | |
| 57 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 57 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 58 | 58 | |
| 59 | - return $spotter_array; |
|
| 60 | - } |
|
| 59 | + return $spotter_array; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Gets last the spotter information based on a particular id |
|
| 65 | - * |
|
| 66 | - * @return Array the spotter information |
|
| 67 | - * |
|
| 68 | - */ |
|
| 69 | - public function getLastArchiveSpotterDataById($id) |
|
| 70 | - { |
|
| 71 | - $Spotter = new Spotter($this->db); |
|
| 72 | - date_default_timezone_set('UTC'); |
|
| 73 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 74 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 75 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 76 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 63 | + /** |
|
| 64 | + * Gets last the spotter information based on a particular id |
|
| 65 | + * |
|
| 66 | + * @return Array the spotter information |
|
| 67 | + * |
|
| 68 | + */ |
|
| 69 | + public function getLastArchiveSpotterDataById($id) |
|
| 70 | + { |
|
| 71 | + $Spotter = new Spotter($this->db); |
|
| 72 | + date_default_timezone_set('UTC'); |
|
| 73 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 74 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 75 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 76 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 77 | 77 | |
| 78 | 78 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 79 | - /* |
|
| 79 | + /* |
|
| 80 | 80 | try { |
| 81 | 81 | $Connection = new Connection(); |
| 82 | 82 | $sth = Connection->$db->prepare($query); |
@@ -86,225 +86,225 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 88 | 88 | */ |
| 89 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 90 | - |
|
| 91 | - return $spotter_array; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Gets all the spotter information based on a particular id |
|
| 96 | - * |
|
| 97 | - * @return Array the spotter information |
|
| 98 | - * |
|
| 99 | - */ |
|
| 100 | - public function getAllArchiveSpotterDataById($id) |
|
| 101 | - { |
|
| 102 | - date_default_timezone_set('UTC'); |
|
| 103 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 104 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 89 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 90 | + |
|
| 91 | + return $spotter_array; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Gets all the spotter information based on a particular id |
|
| 96 | + * |
|
| 97 | + * @return Array the spotter information |
|
| 98 | + * |
|
| 99 | + */ |
|
| 100 | + public function getAllArchiveSpotterDataById($id) |
|
| 101 | + { |
|
| 102 | + date_default_timezone_set('UTC'); |
|
| 103 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 104 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 105 | 105 | |
| 106 | 106 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 107 | 107 | |
| 108 | - try { |
|
| 109 | - $sth = $this->db->prepare($query); |
|
| 110 | - $sth->execute(array(':id' => $id)); |
|
| 111 | - } catch(PDOException $e) { |
|
| 112 | - return "error"; |
|
| 113 | - } |
|
| 114 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 115 | - |
|
| 116 | - return $spotter_array; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Gets coordinate & time spotter information based on a particular id |
|
| 121 | - * |
|
| 122 | - * @return Array the spotter information |
|
| 123 | - * |
|
| 124 | - */ |
|
| 125 | - public function getCoordArchiveSpotterDataById($id) |
|
| 126 | - { |
|
| 127 | - date_default_timezone_set('UTC'); |
|
| 128 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 129 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 108 | + try { |
|
| 109 | + $sth = $this->db->prepare($query); |
|
| 110 | + $sth->execute(array(':id' => $id)); |
|
| 111 | + } catch(PDOException $e) { |
|
| 112 | + return "error"; |
|
| 113 | + } |
|
| 114 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 115 | + |
|
| 116 | + return $spotter_array; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Gets coordinate & time spotter information based on a particular id |
|
| 121 | + * |
|
| 122 | + * @return Array the spotter information |
|
| 123 | + * |
|
| 124 | + */ |
|
| 125 | + public function getCoordArchiveSpotterDataById($id) |
|
| 126 | + { |
|
| 127 | + date_default_timezone_set('UTC'); |
|
| 128 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 129 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 130 | 130 | |
| 131 | 131 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 132 | 132 | |
| 133 | - try { |
|
| 134 | - $sth = $this->db->prepare($query); |
|
| 135 | - $sth->execute(array(':id' => $id)); |
|
| 136 | - } catch(PDOException $e) { |
|
| 137 | - return $e->getMessage(); |
|
| 138 | - } |
|
| 139 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 133 | + try { |
|
| 134 | + $sth = $this->db->prepare($query); |
|
| 135 | + $sth->execute(array(':id' => $id)); |
|
| 136 | + } catch(PDOException $e) { |
|
| 137 | + return $e->getMessage(); |
|
| 138 | + } |
|
| 139 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 140 | 140 | |
| 141 | - return $spotter_array; |
|
| 142 | - } |
|
| 141 | + return $spotter_array; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Gets altitude information based on a particular callsign |
|
| 147 | - * |
|
| 148 | - * @return Array the spotter information |
|
| 149 | - * |
|
| 150 | - */ |
|
| 151 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 152 | - { |
|
| 145 | + /** |
|
| 146 | + * Gets altitude information based on a particular callsign |
|
| 147 | + * |
|
| 148 | + * @return Array the spotter information |
|
| 149 | + * |
|
| 150 | + */ |
|
| 151 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 152 | + { |
|
| 153 | 153 | |
| 154 | - date_default_timezone_set('UTC'); |
|
| 154 | + date_default_timezone_set('UTC'); |
|
| 155 | 155 | |
| 156 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 157 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 156 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 157 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
| 158 | 158 | |
| 159 | - try { |
|
| 160 | - $sth = $this->db->prepare($query); |
|
| 161 | - $sth->execute(array(':ident' => $ident)); |
|
| 162 | - } catch(PDOException $e) { |
|
| 163 | - return "error"; |
|
| 164 | - } |
|
| 165 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 159 | + try { |
|
| 160 | + $sth = $this->db->prepare($query); |
|
| 161 | + $sth->execute(array(':ident' => $ident)); |
|
| 162 | + } catch(PDOException $e) { |
|
| 163 | + return "error"; |
|
| 164 | + } |
|
| 165 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 166 | 166 | |
| 167 | - return $spotter_array; |
|
| 168 | - } |
|
| 167 | + return $spotter_array; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Gets altitude information based on a particular id |
|
| 172 | - * |
|
| 173 | - * @return Array the spotter information |
|
| 174 | - * |
|
| 175 | - */ |
|
| 176 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 177 | - { |
|
| 170 | + /** |
|
| 171 | + * Gets altitude information based on a particular id |
|
| 172 | + * |
|
| 173 | + * @return Array the spotter information |
|
| 174 | + * |
|
| 175 | + */ |
|
| 176 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 177 | + { |
|
| 178 | 178 | |
| 179 | - date_default_timezone_set('UTC'); |
|
| 179 | + date_default_timezone_set('UTC'); |
|
| 180 | 180 | |
| 181 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 181 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 183 | 183 | |
| 184 | - try { |
|
| 185 | - $sth = $this->db->prepare($query); |
|
| 186 | - $sth->execute(array(':id' => $id)); |
|
| 187 | - } catch(PDOException $e) { |
|
| 188 | - return "error"; |
|
| 189 | - } |
|
| 190 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 184 | + try { |
|
| 185 | + $sth = $this->db->prepare($query); |
|
| 186 | + $sth->execute(array(':id' => $id)); |
|
| 187 | + } catch(PDOException $e) { |
|
| 188 | + return "error"; |
|
| 189 | + } |
|
| 190 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 191 | 191 | |
| 192 | - return $spotter_array; |
|
| 193 | - } |
|
| 192 | + return $spotter_array; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Gets altitude & speed information based on a particular id |
|
| 197 | - * |
|
| 198 | - * @return Array the spotter information |
|
| 199 | - * |
|
| 200 | - */ |
|
| 201 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 202 | - { |
|
| 195 | + /** |
|
| 196 | + * Gets altitude & speed information based on a particular id |
|
| 197 | + * |
|
| 198 | + * @return Array the spotter information |
|
| 199 | + * |
|
| 200 | + */ |
|
| 201 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 202 | + { |
|
| 203 | 203 | |
| 204 | - date_default_timezone_set('UTC'); |
|
| 204 | + date_default_timezone_set('UTC'); |
|
| 205 | 205 | |
| 206 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 207 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 206 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 207 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 208 | 208 | |
| 209 | - try { |
|
| 210 | - $sth = $this->db->prepare($query); |
|
| 211 | - $sth->execute(array(':id' => $id)); |
|
| 212 | - } catch(PDOException $e) { |
|
| 213 | - return "error : ".$e->getMessage(); |
|
| 214 | - } |
|
| 215 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 209 | + try { |
|
| 210 | + $sth = $this->db->prepare($query); |
|
| 211 | + $sth->execute(array(':id' => $id)); |
|
| 212 | + } catch(PDOException $e) { |
|
| 213 | + return "error : ".$e->getMessage(); |
|
| 214 | + } |
|
| 215 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 216 | 216 | |
| 217 | - return $spotter_array; |
|
| 218 | - } |
|
| 217 | + return $spotter_array; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * Gets altitude information based on a particular callsign |
|
| 223 | - * |
|
| 224 | - * @return Array the spotter information |
|
| 225 | - * |
|
| 226 | - */ |
|
| 227 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 228 | - { |
|
| 221 | + /** |
|
| 222 | + * Gets altitude information based on a particular callsign |
|
| 223 | + * |
|
| 224 | + * @return Array the spotter information |
|
| 225 | + * |
|
| 226 | + */ |
|
| 227 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 228 | + { |
|
| 229 | 229 | |
| 230 | - date_default_timezone_set('UTC'); |
|
| 230 | + date_default_timezone_set('UTC'); |
|
| 231 | 231 | |
| 232 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 233 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 232 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 233 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 234 | 234 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 235 | 235 | |
| 236 | - try { |
|
| 237 | - $sth = $this->db->prepare($query); |
|
| 238 | - $sth->execute(array(':ident' => $ident)); |
|
| 239 | - } catch(PDOException $e) { |
|
| 240 | - return "error"; |
|
| 241 | - } |
|
| 242 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 236 | + try { |
|
| 237 | + $sth = $this->db->prepare($query); |
|
| 238 | + $sth->execute(array(':ident' => $ident)); |
|
| 239 | + } catch(PDOException $e) { |
|
| 240 | + return "error"; |
|
| 241 | + } |
|
| 242 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 243 | 243 | |
| 244 | - return $spotter_array; |
|
| 245 | - } |
|
| 244 | + return $spotter_array; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Gets all the archive spotter information |
|
| 251 | - * |
|
| 252 | - * @return Array the spotter information |
|
| 253 | - * |
|
| 254 | - */ |
|
| 255 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 256 | - { |
|
| 257 | - $Spotter = new Spotter($this->db); |
|
| 258 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 259 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 249 | + /** |
|
| 250 | + * Gets all the archive spotter information |
|
| 251 | + * |
|
| 252 | + * @return Array the spotter information |
|
| 253 | + * |
|
| 254 | + */ |
|
| 255 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 256 | + { |
|
| 257 | + $Spotter = new Spotter($this->db); |
|
| 258 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 259 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 260 | 260 | |
| 261 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 261 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 262 | 262 | |
| 263 | - return $spotter_array; |
|
| 264 | - } |
|
| 263 | + return $spotter_array; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - public function deleteSpotterArchiveTrackData() |
|
| 267 | - { |
|
| 266 | + public function deleteSpotterArchiveTrackData() |
|
| 267 | + { |
|
| 268 | 268 | global $globalArchiveKeepTrackMonths; |
| 269 | - date_default_timezone_set('UTC'); |
|
| 269 | + date_default_timezone_set('UTC'); |
|
| 270 | 270 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 271 | - try { |
|
| 272 | - $sth = $this->db->prepare($query); |
|
| 273 | - $sth->execute(); |
|
| 274 | - } catch(PDOException $e) { |
|
| 275 | - return "error"; |
|
| 276 | - } |
|
| 271 | + try { |
|
| 272 | + $sth = $this->db->prepare($query); |
|
| 273 | + $sth->execute(); |
|
| 274 | + } catch(PDOException $e) { |
|
| 275 | + return "error"; |
|
| 276 | + } |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | - * Gets Minimal Live Spotter data |
|
| 281 | - * |
|
| 282 | - * @return Array the spotter information |
|
| 283 | - * |
|
| 284 | - */ |
|
| 285 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 286 | - { |
|
| 287 | - global $globalDBdriver, $globalLiveInterval; |
|
| 288 | - date_default_timezone_set('UTC'); |
|
| 289 | - |
|
| 290 | - $filter_query = ''; |
|
| 291 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 292 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 293 | - } |
|
| 294 | - // Use spotter_output also ? |
|
| 295 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 296 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 297 | - } |
|
| 298 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 299 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 300 | - } |
|
| 301 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 302 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 306 | - if ($globalDBdriver == 'mysql') { |
|
| 307 | - /* |
|
| 280 | + * Gets Minimal Live Spotter data |
|
| 281 | + * |
|
| 282 | + * @return Array the spotter information |
|
| 283 | + * |
|
| 284 | + */ |
|
| 285 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 286 | + { |
|
| 287 | + global $globalDBdriver, $globalLiveInterval; |
|
| 288 | + date_default_timezone_set('UTC'); |
|
| 289 | + |
|
| 290 | + $filter_query = ''; |
|
| 291 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 292 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 293 | + } |
|
| 294 | + // Use spotter_output also ? |
|
| 295 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 296 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 297 | + } |
|
| 298 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 299 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 300 | + } |
|
| 301 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 302 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 306 | + if ($globalDBdriver == 'mysql') { |
|
| 307 | + /* |
|
| 308 | 308 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 309 | 309 | FROM spotter_archive |
| 310 | 310 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -316,50 +316,50 @@ discard block |
||
| 316 | 316 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') |
| 317 | 317 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 318 | 318 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 319 | - } else if ($globalDBdriver == 'pgsql') { |
|
| 320 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 321 | - } |
|
| 322 | - //echo $query; |
|
| 323 | - try { |
|
| 324 | - $sth = $this->db->prepare($query); |
|
| 325 | - $sth->execute(); |
|
| 326 | - } catch(PDOException $e) { |
|
| 327 | - return "error"; |
|
| 328 | - } |
|
| 329 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 330 | - |
|
| 331 | - return $spotter_array; |
|
| 332 | - } |
|
| 319 | + } else if ($globalDBdriver == 'pgsql') { |
|
| 320 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 321 | + } |
|
| 322 | + //echo $query; |
|
| 323 | + try { |
|
| 324 | + $sth = $this->db->prepare($query); |
|
| 325 | + $sth->execute(); |
|
| 326 | + } catch(PDOException $e) { |
|
| 327 | + return "error"; |
|
| 328 | + } |
|
| 329 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 330 | + |
|
| 331 | + return $spotter_array; |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | - * Gets Minimal Live Spotter data |
|
| 336 | - * |
|
| 337 | - * @return Array the spotter information |
|
| 338 | - * |
|
| 339 | - */ |
|
| 340 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 341 | - { |
|
| 342 | - global $globalDBdriver, $globalLiveInterval; |
|
| 343 | - date_default_timezone_set('UTC'); |
|
| 344 | - |
|
| 345 | - $filter_query = ''; |
|
| 346 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 347 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 348 | - } |
|
| 349 | - // Should use spotter_output also ? |
|
| 350 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 351 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 352 | - } |
|
| 353 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 354 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 355 | - } |
|
| 356 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 357 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 361 | - if ($globalDBdriver == 'mysql') { |
|
| 362 | - /* |
|
| 335 | + * Gets Minimal Live Spotter data |
|
| 336 | + * |
|
| 337 | + * @return Array the spotter information |
|
| 338 | + * |
|
| 339 | + */ |
|
| 340 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 341 | + { |
|
| 342 | + global $globalDBdriver, $globalLiveInterval; |
|
| 343 | + date_default_timezone_set('UTC'); |
|
| 344 | + |
|
| 345 | + $filter_query = ''; |
|
| 346 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 347 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 348 | + } |
|
| 349 | + // Should use spotter_output also ? |
|
| 350 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 351 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 352 | + } |
|
| 353 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 354 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 355 | + } |
|
| 356 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 357 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 361 | + if ($globalDBdriver == 'mysql') { |
|
| 362 | + /* |
|
| 363 | 363 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 364 | 364 | FROM spotter_archive |
| 365 | 365 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -370,91 +370,91 @@ discard block |
||
| 370 | 370 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 371 | 371 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 372 | 372 | |
| 373 | - } else if ($globalDBdriver == 'pgsql') { |
|
| 374 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 375 | - $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 373 | + } else if ($globalDBdriver == 'pgsql') { |
|
| 374 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 375 | + $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 376 | 376 | FROM spotter_archive_output |
| 377 | 377 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 378 | 378 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 379 | 379 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 380 | - $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 380 | + $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow |
|
| 381 | 381 | FROM spotter_output |
| 382 | 382 | INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao |
| 383 | 383 | WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".' |
| 384 | 384 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 385 | 385 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 386 | 386 | |
| 387 | - } |
|
| 388 | - //echo $query; |
|
| 389 | - try { |
|
| 390 | - $sth = $this->db->prepare($query); |
|
| 391 | - $sth->execute(); |
|
| 392 | - } catch(PDOException $e) { |
|
| 393 | - return $e->getMessage(); |
|
| 394 | - } |
|
| 395 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 396 | - |
|
| 397 | - return $spotter_array; |
|
| 398 | - } |
|
| 387 | + } |
|
| 388 | + //echo $query; |
|
| 389 | + try { |
|
| 390 | + $sth = $this->db->prepare($query); |
|
| 391 | + $sth->execute(); |
|
| 392 | + } catch(PDOException $e) { |
|
| 393 | + return $e->getMessage(); |
|
| 394 | + } |
|
| 395 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 396 | + |
|
| 397 | + return $spotter_array; |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | - * Gets count Live Spotter data |
|
| 402 | - * |
|
| 403 | - * @return Array the spotter information |
|
| 404 | - * |
|
| 405 | - */ |
|
| 406 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 407 | - { |
|
| 408 | - global $globalDBdriver, $globalLiveInterval; |
|
| 409 | - date_default_timezone_set('UTC'); |
|
| 410 | - |
|
| 411 | - $filter_query = ''; |
|
| 412 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 413 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 414 | - } |
|
| 415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 417 | - } |
|
| 418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | - } |
|
| 421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 401 | + * Gets count Live Spotter data |
|
| 402 | + * |
|
| 403 | + * @return Array the spotter information |
|
| 404 | + * |
|
| 405 | + */ |
|
| 406 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 407 | + { |
|
| 408 | + global $globalDBdriver, $globalLiveInterval; |
|
| 409 | + date_default_timezone_set('UTC'); |
|
| 410 | + |
|
| 411 | + $filter_query = ''; |
|
| 412 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 413 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 414 | + } |
|
| 415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 417 | + } |
|
| 418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | + } |
|
| 421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | 427 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 428 | 428 | FROM spotter_archive l |
| 429 | 429 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 430 | 430 | |
| 431 | - } else if ($globalDBdriver == 'pgsql') { |
|
| 431 | + } else if ($globalDBdriver == 'pgsql') { |
|
| 432 | 432 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 433 | - } |
|
| 434 | - //echo $query; |
|
| 435 | - try { |
|
| 436 | - $sth = $this->db->prepare($query); |
|
| 437 | - $sth->execute(); |
|
| 438 | - } catch(PDOException $e) { |
|
| 439 | - return "error"; |
|
| 440 | - } |
|
| 433 | + } |
|
| 434 | + //echo $query; |
|
| 435 | + try { |
|
| 436 | + $sth = $this->db->prepare($query); |
|
| 437 | + $sth->execute(); |
|
| 438 | + } catch(PDOException $e) { |
|
| 439 | + return "error"; |
|
| 440 | + } |
|
| 441 | 441 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 442 | - return $result['nb']; |
|
| 442 | + return $result['nb']; |
|
| 443 | 443 | |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | 446 | |
| 447 | 447 | |
| 448 | 448 | // Spotter_Archive_output |
| 449 | 449 | |
| 450 | - /** |
|
| 451 | - * Gets all the spotter information |
|
| 452 | - * |
|
| 453 | - * @return Array the spotter information |
|
| 454 | - * |
|
| 455 | - */ |
|
| 456 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '') |
|
| 457 | - { |
|
| 450 | + /** |
|
| 451 | + * Gets all the spotter information |
|
| 452 | + * |
|
| 453 | + * @return Array the spotter information |
|
| 454 | + * |
|
| 455 | + */ |
|
| 456 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '') |
|
| 457 | + { |
|
| 458 | 458 | global $globalTimezone, $globalDbdriver; |
| 459 | 459 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 460 | 460 | $Translation = new Translation(); |
@@ -465,159 +465,159 @@ discard block |
||
| 465 | 465 | $additional_query = ''; |
| 466 | 466 | if ($q != "") |
| 467 | 467 | { |
| 468 | - if (!is_string($q)) |
|
| 469 | - { |
|
| 468 | + if (!is_string($q)) |
|
| 469 | + { |
|
| 470 | 470 | return false; |
| 471 | - } else { |
|
| 471 | + } else { |
|
| 472 | 472 | |
| 473 | 473 | $q_array = explode(" ", $q); |
| 474 | 474 | |
| 475 | 475 | foreach ($q_array as $q_item){ |
| 476 | - $additional_query .= " AND ("; |
|
| 477 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 478 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 479 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 480 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 481 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 482 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 483 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 484 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 485 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 486 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 487 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 488 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 489 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 490 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 491 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 492 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 493 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 494 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 495 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 496 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 497 | - $translate = $Translation->ident2icao($q_item); |
|
| 498 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 499 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 500 | - $additional_query .= ")"; |
|
| 501 | - } |
|
| 502 | - } |
|
| 476 | + $additional_query .= " AND ("; |
|
| 477 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 478 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 479 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 480 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 481 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 482 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 483 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 484 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 485 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 486 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 487 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 488 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 489 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 490 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 491 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 492 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 493 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 494 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 495 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 496 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 497 | + $translate = $Translation->ident2icao($q_item); |
|
| 498 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 499 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 500 | + $additional_query .= ")"; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | if ($registration != "") |
| 506 | 506 | { |
| 507 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 508 | - if (!is_string($registration)) |
|
| 509 | - { |
|
| 507 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 508 | + if (!is_string($registration)) |
|
| 509 | + { |
|
| 510 | 510 | return false; |
| 511 | - } else { |
|
| 511 | + } else { |
|
| 512 | 512 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 513 | - } |
|
| 513 | + } |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | if ($aircraft_icao != "") |
| 517 | 517 | { |
| 518 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 519 | - if (!is_string($aircraft_icao)) |
|
| 520 | - { |
|
| 518 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 519 | + if (!is_string($aircraft_icao)) |
|
| 520 | + { |
|
| 521 | 521 | return false; |
| 522 | - } else { |
|
| 522 | + } else { |
|
| 523 | 523 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 524 | - } |
|
| 524 | + } |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | if ($aircraft_manufacturer != "") |
| 528 | 528 | { |
| 529 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 530 | - if (!is_string($aircraft_manufacturer)) |
|
| 531 | - { |
|
| 529 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 530 | + if (!is_string($aircraft_manufacturer)) |
|
| 531 | + { |
|
| 532 | 532 | return false; |
| 533 | - } else { |
|
| 533 | + } else { |
|
| 534 | 534 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 535 | - } |
|
| 535 | + } |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | if ($highlights == "true") |
| 539 | 539 | { |
| 540 | - if (!is_string($highlights)) |
|
| 541 | - { |
|
| 540 | + if (!is_string($highlights)) |
|
| 541 | + { |
|
| 542 | 542 | return false; |
| 543 | - } else { |
|
| 543 | + } else { |
|
| 544 | 544 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 545 | - } |
|
| 545 | + } |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | if ($airline_icao != "") |
| 549 | 549 | { |
| 550 | - $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 551 | - if (!is_string($airline_icao)) |
|
| 552 | - { |
|
| 550 | + $registration = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 551 | + if (!is_string($airline_icao)) |
|
| 552 | + { |
|
| 553 | 553 | return false; |
| 554 | - } else { |
|
| 554 | + } else { |
|
| 555 | 555 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 556 | - } |
|
| 556 | + } |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | if ($airline_country != "") |
| 560 | 560 | { |
| 561 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 562 | - if (!is_string($airline_country)) |
|
| 563 | - { |
|
| 561 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 562 | + if (!is_string($airline_country)) |
|
| 563 | + { |
|
| 564 | 564 | return false; |
| 565 | - } else { |
|
| 565 | + } else { |
|
| 566 | 566 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 567 | - } |
|
| 567 | + } |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | if ($airline_type != "") |
| 571 | 571 | { |
| 572 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 573 | - if (!is_string($airline_type)) |
|
| 574 | - { |
|
| 572 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 573 | + if (!is_string($airline_type)) |
|
| 574 | + { |
|
| 575 | 575 | return false; |
| 576 | - } else { |
|
| 576 | + } else { |
|
| 577 | 577 | if ($airline_type == "passenger") |
| 578 | 578 | { |
| 579 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 579 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 580 | 580 | } |
| 581 | 581 | if ($airline_type == "cargo") |
| 582 | 582 | { |
| 583 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 583 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 584 | 584 | } |
| 585 | 585 | if ($airline_type == "military") |
| 586 | 586 | { |
| 587 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 587 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 588 | + } |
|
| 588 | 589 | } |
| 589 | - } |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | if ($airport != "") |
| 593 | 593 | { |
| 594 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 595 | - if (!is_string($airport)) |
|
| 596 | - { |
|
| 594 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 595 | + if (!is_string($airport)) |
|
| 596 | + { |
|
| 597 | 597 | return false; |
| 598 | - } else { |
|
| 598 | + } else { |
|
| 599 | 599 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | if ($airport_country != "") |
| 604 | 604 | { |
| 605 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 606 | - if (!is_string($airport_country)) |
|
| 607 | - { |
|
| 605 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 606 | + if (!is_string($airport_country)) |
|
| 607 | + { |
|
| 608 | 608 | return false; |
| 609 | - } else { |
|
| 609 | + } else { |
|
| 610 | 610 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 611 | - } |
|
| 611 | + } |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | if ($callsign != "") |
| 615 | 615 | { |
| 616 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 617 | - if (!is_string($callsign)) |
|
| 618 | - { |
|
| 616 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 617 | + if (!is_string($callsign)) |
|
| 618 | + { |
|
| 619 | 619 | return false; |
| 620 | - } else { |
|
| 620 | + } else { |
|
| 621 | 621 | $translate = $Translation->ident2icao($callsign); |
| 622 | 622 | if ($translate != $callsign) { |
| 623 | 623 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -625,99 +625,99 @@ discard block |
||
| 625 | 625 | } else { |
| 626 | 626 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 627 | 627 | } |
| 628 | - } |
|
| 628 | + } |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | if ($owner != "") |
| 632 | 632 | { |
| 633 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 634 | - if (!is_string($owner)) |
|
| 635 | - { |
|
| 633 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 634 | + if (!is_string($owner)) |
|
| 635 | + { |
|
| 636 | 636 | return false; |
| 637 | - } else { |
|
| 637 | + } else { |
|
| 638 | 638 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 639 | - } |
|
| 639 | + } |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | if ($pilot_name != "") |
| 643 | 643 | { |
| 644 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 645 | - if (!is_string($pilot_name)) |
|
| 646 | - { |
|
| 644 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 645 | + if (!is_string($pilot_name)) |
|
| 646 | + { |
|
| 647 | 647 | return false; |
| 648 | - } else { |
|
| 648 | + } else { |
|
| 649 | 649 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 650 | - } |
|
| 650 | + } |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | if ($pilot_id != "") |
| 654 | 654 | { |
| 655 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 656 | - if (!is_string($pilot_id)) |
|
| 657 | - { |
|
| 655 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 656 | + if (!is_string($pilot_id)) |
|
| 657 | + { |
|
| 658 | 658 | return false; |
| 659 | - } else { |
|
| 659 | + } else { |
|
| 660 | 660 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 661 | - } |
|
| 661 | + } |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | if ($departure_airport_route != "") |
| 665 | 665 | { |
| 666 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 667 | - if (!is_string($departure_airport_route)) |
|
| 668 | - { |
|
| 666 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 667 | + if (!is_string($departure_airport_route)) |
|
| 668 | + { |
|
| 669 | 669 | return false; |
| 670 | - } else { |
|
| 670 | + } else { |
|
| 671 | 671 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | if ($arrival_airport_route != "") |
| 676 | 676 | { |
| 677 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 678 | - if (!is_string($arrival_airport_route)) |
|
| 679 | - { |
|
| 677 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 678 | + if (!is_string($arrival_airport_route)) |
|
| 679 | + { |
|
| 680 | 680 | return false; |
| 681 | - } else { |
|
| 681 | + } else { |
|
| 682 | 682 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 683 | - } |
|
| 683 | + } |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if ($altitude != "") |
| 687 | 687 | { |
| 688 | - $altitude_array = explode(",", $altitude); |
|
| 688 | + $altitude_array = explode(",", $altitude); |
|
| 689 | 689 | |
| 690 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 691 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 690 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 691 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 692 | 692 | |
| 693 | 693 | |
| 694 | - if ($altitude_array[1] != "") |
|
| 695 | - { |
|
| 694 | + if ($altitude_array[1] != "") |
|
| 695 | + { |
|
| 696 | 696 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 697 | 697 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 698 | 698 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 699 | - } else { |
|
| 699 | + } else { |
|
| 700 | 700 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 701 | 701 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 702 | - } |
|
| 702 | + } |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | if ($date_posted != "") |
| 706 | 706 | { |
| 707 | - $date_array = explode(",", $date_posted); |
|
| 707 | + $date_array = explode(",", $date_posted); |
|
| 708 | 708 | |
| 709 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 710 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 709 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 710 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 711 | 711 | |
| 712 | - if ($globalTimezone != '') { |
|
| 712 | + if ($globalTimezone != '') { |
|
| 713 | 713 | date_default_timezone_set($globalTimezone); |
| 714 | 714 | $datetime = new DateTime(); |
| 715 | 715 | $offset = $datetime->format('P'); |
| 716 | - } else $offset = '+00:00'; |
|
| 716 | + } else $offset = '+00:00'; |
|
| 717 | 717 | |
| 718 | 718 | |
| 719 | - if ($date_array[1] != "") |
|
| 720 | - { |
|
| 719 | + if ($date_array[1] != "") |
|
| 720 | + { |
|
| 721 | 721 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 722 | 722 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 723 | 723 | if ($globalDBdriver == 'mysql') { |
@@ -725,28 +725,28 @@ discard block |
||
| 725 | 725 | } else { |
| 726 | 726 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 727 | 727 | } |
| 728 | - } else { |
|
| 728 | + } else { |
|
| 729 | 729 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 730 | - if ($globalDBdriver == 'mysql') { |
|
| 730 | + if ($globalDBdriver == 'mysql') { |
|
| 731 | 731 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 732 | 732 | } else { |
| 733 | 733 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 734 | 734 | } |
| 735 | - } |
|
| 735 | + } |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | if ($limit != "") |
| 739 | 739 | { |
| 740 | - $limit_array = explode(",", $limit); |
|
| 740 | + $limit_array = explode(",", $limit); |
|
| 741 | 741 | |
| 742 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 743 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 742 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 743 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 744 | 744 | |
| 745 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 746 | - { |
|
| 745 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 746 | + { |
|
| 747 | 747 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 748 | 748 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 749 | - } |
|
| 749 | + } |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | |
@@ -778,33 +778,33 @@ discard block |
||
| 778 | 778 | $spotter_array = $Spotter->getDataFromDB($query, array(),$limit_query); |
| 779 | 779 | |
| 780 | 780 | return $spotter_array; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | - public function deleteSpotterArchiveData() |
|
| 784 | - { |
|
| 783 | + public function deleteSpotterArchiveData() |
|
| 784 | + { |
|
| 785 | 785 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 786 | - date_default_timezone_set('UTC'); |
|
| 787 | - if ($globalDBdriver == 'mysql') { |
|
| 786 | + date_default_timezone_set('UTC'); |
|
| 787 | + if ($globalDBdriver == 'mysql') { |
|
| 788 | 788 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 789 | 789 | } else { |
| 790 | 790 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 791 | 791 | } |
| 792 | - try { |
|
| 793 | - $sth = $this->db->prepare($query); |
|
| 794 | - $sth->execute(); |
|
| 795 | - } catch(PDOException $e) { |
|
| 796 | - return "error"; |
|
| 797 | - } |
|
| 792 | + try { |
|
| 793 | + $sth = $this->db->prepare($query); |
|
| 794 | + $sth->execute(); |
|
| 795 | + } catch(PDOException $e) { |
|
| 796 | + return "error"; |
|
| 797 | + } |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - /** |
|
| 801 | - * Gets all the spotter information based on the callsign |
|
| 802 | - * |
|
| 803 | - * @return Array the spotter information |
|
| 804 | - * |
|
| 805 | - */ |
|
| 806 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 807 | - { |
|
| 800 | + /** |
|
| 801 | + * Gets all the spotter information based on the callsign |
|
| 802 | + * |
|
| 803 | + * @return Array the spotter information |
|
| 804 | + * |
|
| 805 | + */ |
|
| 806 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 807 | + { |
|
| 808 | 808 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 809 | 809 | |
| 810 | 810 | date_default_timezone_set('UTC'); |
@@ -813,35 +813,35 @@ discard block |
||
| 813 | 813 | |
| 814 | 814 | if ($ident != "") |
| 815 | 815 | { |
| 816 | - if (!is_string($ident)) |
|
| 817 | - { |
|
| 816 | + if (!is_string($ident)) |
|
| 817 | + { |
|
| 818 | 818 | return false; |
| 819 | - } else { |
|
| 819 | + } else { |
|
| 820 | 820 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 821 | 821 | $query_values = array(':ident' => $ident); |
| 822 | - } |
|
| 822 | + } |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | if ($limit != "") |
| 826 | 826 | { |
| 827 | - $limit_array = explode(",", $limit); |
|
| 827 | + $limit_array = explode(",", $limit); |
|
| 828 | 828 | |
| 829 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 830 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 829 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 830 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 831 | 831 | |
| 832 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 833 | - { |
|
| 832 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 833 | + { |
|
| 834 | 834 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 835 | 835 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 836 | - } |
|
| 836 | + } |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | if ($sort != "") |
| 840 | 840 | { |
| 841 | - $search_orderby_array = $this->getOrderBy(); |
|
| 842 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 841 | + $search_orderby_array = $this->getOrderBy(); |
|
| 842 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 843 | 843 | } else { |
| 844 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 844 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -850,16 +850,16 @@ discard block |
||
| 850 | 850 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 851 | 851 | |
| 852 | 852 | return $spotter_array; |
| 853 | - } |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * Gets all number of flight over countries |
|
| 857 | - * |
|
| 858 | - * @return Array the airline country list |
|
| 859 | - * |
|
| 860 | - */ |
|
| 861 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 862 | - { |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * Gets all number of flight over countries |
|
| 857 | + * |
|
| 858 | + * @return Array the airline country list |
|
| 859 | + * |
|
| 860 | + */ |
|
| 861 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 862 | + { |
|
| 863 | 863 | global $globalDBdriver; |
| 864 | 864 | /* |
| 865 | 865 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -869,14 +869,14 @@ discard block |
||
| 869 | 869 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 870 | 870 | FROM countries c, spotter_archive s |
| 871 | 871 | WHERE c.iso2 = s.over_country "; |
| 872 | - if ($olderthanmonths > 0) { |
|
| 873 | - if ($globalDBdriver == 'mysql') { |
|
| 872 | + if ($olderthanmonths > 0) { |
|
| 873 | + if ($globalDBdriver == 'mysql') { |
|
| 874 | 874 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 875 | 875 | } else { |
| 876 | 876 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 877 | 877 | } |
| 878 | 878 | } |
| 879 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 879 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 880 | 880 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 881 | 881 | if ($limit) $query .= " LIMIT 0,10"; |
| 882 | 882 | |
@@ -889,14 +889,14 @@ discard block |
||
| 889 | 889 | |
| 890 | 890 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 891 | 891 | { |
| 892 | - $temp_array['flight_count'] = $row['nb']; |
|
| 893 | - $temp_array['flight_country'] = $row['name']; |
|
| 894 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 895 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 896 | - $flight_array[] = $temp_array; |
|
| 892 | + $temp_array['flight_count'] = $row['nb']; |
|
| 893 | + $temp_array['flight_country'] = $row['name']; |
|
| 894 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 895 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 896 | + $flight_array[] = $temp_array; |
|
| 897 | 897 | } |
| 898 | 898 | return $flight_array; |
| 899 | - } |
|
| 899 | + } |
|
| 900 | 900 | |
| 901 | 901 | } |
| 902 | 902 | ?> |
| 903 | 903 | \ No newline at end of file |
@@ -18,26 +18,26 @@ discard block |
||
| 18 | 18 | // Check if schema is at latest version |
| 19 | 19 | $Connection = new Connection(); |
| 20 | 20 | if ($Connection->latest() === false) { |
| 21 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 22 | - exit(); |
|
| 21 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 22 | + exit(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | // This is to be compatible with old version of settings.php |
| 27 | 27 | if (!isset($globalSources)) { |
| 28 | - if (isset($globalSBS1Hosts)) { |
|
| 29 | - //$hosts = $globalSBS1Hosts; |
|
| 30 | - foreach ($globalSBS1Hosts as $host) { |
|
| 31 | - $globalSources[] = array('host' => $host); |
|
| 32 | - } |
|
| 33 | - } else { |
|
| 34 | - if (!isset($globalSBS1Host)) { |
|
| 35 | - echo '$globalSBS1Host MUST be defined !'; |
|
| 36 | - die; |
|
| 28 | + if (isset($globalSBS1Hosts)) { |
|
| 29 | + //$hosts = $globalSBS1Hosts; |
|
| 30 | + foreach ($globalSBS1Hosts as $host) { |
|
| 31 | + $globalSources[] = array('host' => $host); |
|
| 32 | + } |
|
| 33 | + } else { |
|
| 34 | + if (!isset($globalSBS1Host)) { |
|
| 35 | + echo '$globalSBS1Host MUST be defined !'; |
|
| 36 | + die; |
|
| 37 | 37 | } |
| 38 | 38 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 39 | 39 | $globalSources[] = array('host' => $globalSBS1Host.':'.$globalSBS1Port); |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $options = getopt('s::',array('source::','server','idsource::')); |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 50 | 50 | else $id_source = 1; |
| 51 | 51 | if (isset($globalServer) && $globalServer) { |
| 52 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 53 | - $SI=new SpotterServer(); |
|
| 52 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 53 | + $SI=new SpotterServer(); |
|
| 54 | 54 | } else $SI=new SpotterImport($Connection->db); |
| 55 | 55 | //$APRS=new APRS($Connection->db); |
| 56 | 56 | $SBS=new SBS($Connection->db); |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | //$servertz = system('date +%Z'); |
| 60 | 60 | // signal handler - playing nice with sockets and dump1090 |
| 61 | 61 | if (function_exists('pcntl_fork')) { |
| 62 | - pcntl_signal(SIGINT, function($signo) { |
|
| 63 | - global $sockets; |
|
| 64 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 65 | - die("Bye!\n"); |
|
| 66 | - }); |
|
| 67 | - pcntl_signal_dispatch(); |
|
| 62 | + pcntl_signal(SIGINT, function($signo) { |
|
| 63 | + global $sockets; |
|
| 64 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 65 | + die("Bye!\n"); |
|
| 66 | + }); |
|
| 67 | + pcntl_signal_dispatch(); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // let's try and connect |
@@ -72,125 +72,125 @@ discard block |
||
| 72 | 72 | $use_aprs = false; |
| 73 | 73 | |
| 74 | 74 | function create_socket($host, $port, &$errno, &$errstr) { |
| 75 | - $ip = gethostbyname($host); |
|
| 76 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 77 | - $r = @socket_connect($s, $ip, $port); |
|
| 78 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 79 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 80 | - return $s; |
|
| 81 | - } |
|
| 82 | - $errno = socket_last_error($s); |
|
| 83 | - $errstr = socket_strerror($errno); |
|
| 84 | - socket_close($s); |
|
| 85 | - return false; |
|
| 75 | + $ip = gethostbyname($host); |
|
| 76 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 77 | + $r = @socket_connect($s, $ip, $port); |
|
| 78 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 79 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 80 | + return $s; |
|
| 81 | + } |
|
| 82 | + $errno = socket_last_error($s); |
|
| 83 | + $errstr = socket_strerror($errno); |
|
| 84 | + socket_close($s); |
|
| 85 | + return false; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | function connect_all($hosts) { |
| 89 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 90 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 91 | - foreach ($hosts as $id => $value) { |
|
| 89 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 90 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 91 | + foreach ($hosts as $id => $value) { |
|
| 92 | 92 | $host = $value['host']; |
| 93 | 93 | $globalSources[$id]['last_exec'] = 0; |
| 94 | 94 | // Here we check type of source(s) |
| 95 | 95 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 96 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 97 | - //$formats[$id] = 'deltadbtxt'; |
|
| 98 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 99 | - //$last_exec['deltadbtxt'] = 0; |
|
| 100 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 101 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 102 | - //$formats[$id] = 'vatsimtxt'; |
|
| 103 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 104 | - //$last_exec['vatsimtxt'] = 0; |
|
| 105 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 106 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 107 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 108 | - $$globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 109 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 110 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 111 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 112 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 113 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 114 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 115 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 116 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 117 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 118 | - exit(0); |
|
| 119 | - } |
|
| 120 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 121 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 122 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 123 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 124 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 125 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 126 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 127 | - exit(0); |
|
| 128 | - } |
|
| 129 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'phpvmacars'; |
|
| 131 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 132 | - //$last_exec['phpvmacars'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 135 | - //$formats[$id] = 'whazzup'; |
|
| 136 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 137 | - //$last_exec['whazzup'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 140 | - //$formats[$id] = 'pirepsjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 142 | - //$last_exec['pirepsjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 144 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 145 | - //$formats[$id] = 'fr24json'; |
|
| 146 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 147 | - //$last_exec['fr24json'] = 0; |
|
| 148 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 149 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | - exit(0); |
|
| 152 | - } |
|
| 153 | - //} else if (preg_match('/10001/',$host)) { |
|
| 154 | - } else if (preg_match('/10001/',$host) || $globalSources[$id]['port'] == '10001') { |
|
| 155 | - //$formats[$id] = 'tsv'; |
|
| 156 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 157 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 158 | - } |
|
| 159 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 160 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 161 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 162 | - $hostport = explode(':',$host); |
|
| 163 | - if (isset($hostport[1])) $port = $hostport[1]; |
|
| 164 | - else $port = $globalSources[$id]['port']; |
|
| 165 | - $s = create_socket($host,$port, $errno, $errstr); |
|
| 166 | - if ($s) { |
|
| 167 | - $sockets[$id] = $s; |
|
| 168 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 169 | - if (preg_match('/aprs/',$host)) { |
|
| 96 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 97 | + //$formats[$id] = 'deltadbtxt'; |
|
| 98 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 99 | + //$last_exec['deltadbtxt'] = 0; |
|
| 100 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 101 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 102 | + //$formats[$id] = 'vatsimtxt'; |
|
| 103 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 104 | + //$last_exec['vatsimtxt'] = 0; |
|
| 105 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 106 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 107 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 108 | + $$globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 109 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 110 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 111 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 112 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 113 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 114 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 115 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 116 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 117 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 118 | + exit(0); |
|
| 119 | + } |
|
| 120 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 121 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 122 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 123 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 124 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 125 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 126 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 127 | + exit(0); |
|
| 128 | + } |
|
| 129 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'phpvmacars'; |
|
| 131 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 132 | + //$last_exec['phpvmacars'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 135 | + //$formats[$id] = 'whazzup'; |
|
| 136 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 137 | + //$last_exec['whazzup'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 140 | + //$formats[$id] = 'pirepsjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 142 | + //$last_exec['pirepsjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 144 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 145 | + //$formats[$id] = 'fr24json'; |
|
| 146 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 147 | + //$last_exec['fr24json'] = 0; |
|
| 148 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 149 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | + exit(0); |
|
| 152 | + } |
|
| 153 | + //} else if (preg_match('/10001/',$host)) { |
|
| 154 | + } else if (preg_match('/10001/',$host) || $globalSources[$id]['port'] == '10001') { |
|
| 155 | + //$formats[$id] = 'tsv'; |
|
| 156 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 157 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 158 | + } |
|
| 159 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 160 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 161 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 162 | + $hostport = explode(':',$host); |
|
| 163 | + if (isset($hostport[1])) $port = $hostport[1]; |
|
| 164 | + else $port = $globalSources[$id]['port']; |
|
| 165 | + $s = create_socket($host,$port, $errno, $errstr); |
|
| 166 | + if ($s) { |
|
| 167 | + $sockets[$id] = $s; |
|
| 168 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 169 | + if (preg_match('/aprs/',$host)) { |
|
| 170 | 170 | //$formats[$id] = 'aprs'; |
| 171 | 171 | $globalSources[$id]['format'] = 'aprs'; |
| 172 | 172 | //$aprs_connect = 0; |
| 173 | 173 | //$use_aprs = true; |
| 174 | - } elseif ($port == '10001') { |
|
| 175 | - //$formats[$id] = 'tsv'; |
|
| 176 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 177 | - } elseif ($port == '30002') { |
|
| 178 | - //$formats[$id] = 'raw'; |
|
| 179 | - $globalSources[$id]['format'] = 'raw'; |
|
| 180 | - } elseif ($port == '30005') { |
|
| 174 | + } elseif ($port == '10001') { |
|
| 175 | + //$formats[$id] = 'tsv'; |
|
| 176 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 177 | + } elseif ($port == '30002') { |
|
| 178 | + //$formats[$id] = 'raw'; |
|
| 179 | + $globalSources[$id]['format'] = 'raw'; |
|
| 180 | + } elseif ($port == '30005') { |
|
| 181 | 181 | // Not yet supported |
| 182 | - //$formats[$id] = 'beast'; |
|
| 183 | - $globalSources[$id]['format'] = 'beast'; |
|
| 184 | - //} else $formats[$id] = 'sbs'; |
|
| 185 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 186 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 182 | + //$formats[$id] = 'beast'; |
|
| 183 | + $globalSources[$id]['format'] = 'beast'; |
|
| 184 | + //} else $formats[$id] = 'sbs'; |
|
| 185 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 186 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 187 | 187 | } |
| 188 | 188 | if ($globalDebug) echo 'Connection in progress to '.$host.'('.$globalSources[$id]['format'].')....'."\n"; |
| 189 | - } else { |
|
| 189 | + } else { |
|
| 190 | 190 | if ($globalDebug) echo 'Connection failed to '.$host.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 191 | - } |
|
| 192 | - } |
|
| 193 | - } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | 194 | } |
| 195 | 195 | if (!isset($globalMinFetch)) $globalMinFetch = 0; |
| 196 | 196 | |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // APRS Configuration |
| 215 | 215 | foreach ($globalSources as $key => $source) { |
| 216 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 216 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 217 | 217 | $aprs_connect = 0; |
| 218 | 218 | $use_aprs = true; |
| 219 | 219 | break; |
| 220 | - } elseif (!isset($source['format'])) { |
|
| 221 | - $globalSources[$key]['format'] = 'auto'; |
|
| 222 | - } |
|
| 220 | + } elseif (!isset($source['format'])) { |
|
| 221 | + $globalSources[$key]['format'] = 'auto'; |
|
| 222 | + } |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if ($use_aprs) { |
@@ -259,53 +259,53 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 261 | 261 | while ($i > 0) { |
| 262 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 263 | - // Delete old ATC |
|
| 264 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 265 | - $ATC->deleteOldATC(); |
|
| 266 | - } |
|
| 267 | - //foreach ($formats as $id => $value) { |
|
| 268 | - foreach ($globalSources as $id => $value) { |
|
| 262 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 263 | + // Delete old ATC |
|
| 264 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 265 | + $ATC->deleteOldATC(); |
|
| 266 | + } |
|
| 267 | + //foreach ($formats as $id => $value) { |
|
| 268 | + foreach ($globalSources as $id => $value) { |
|
| 269 | 269 | //if ($value == 'deltadbtxt' && (time() - $last_exec['deltadbtxt'] > $globalMinFetch)) { |
| 270 | 270 | if ($value['format'] == 'deltadbtxt' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 271 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 272 | - $buffer = $Common->getData($value['host']); |
|
| 273 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 274 | - $buffer = explode('\n',$buffer); |
|
| 275 | - foreach ($buffer as $line) { |
|
| 276 | - if ($line != '') { |
|
| 277 | - $line = explode(',', $line); |
|
| 278 | - $data = array(); |
|
| 279 | - $data['hex'] = $line[1]; // hex |
|
| 280 | - $data['ident'] = $line[2]; // ident |
|
| 281 | - $data['altitude'] = $line[3]; // altitude |
|
| 282 | - $data['speed'] = $line[4]; // speed |
|
| 283 | - $data['heading'] = $line[5]; // heading |
|
| 284 | - $data['latitude'] = $line[6]; // lat |
|
| 285 | - $data['longitude'] = $line[7]; // long |
|
| 286 | - $data['verticalrate'] = ''; // vertical rate |
|
| 287 | - $data['squawk'] = ''; // squawk |
|
| 288 | - $data['emergency'] = ''; // emergency |
|
| 289 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 290 | - $data['format_source'] = 'deltadbtxt'; |
|
| 291 | - $data['id_source'] = $id_source; |
|
| 292 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 293 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 294 | - $SI->add($data); |
|
| 295 | - unset($data); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - $value['last_exec'] = time(); |
|
| 271 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 272 | + $buffer = $Common->getData($value['host']); |
|
| 273 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 274 | + $buffer = explode('\n',$buffer); |
|
| 275 | + foreach ($buffer as $line) { |
|
| 276 | + if ($line != '') { |
|
| 277 | + $line = explode(',', $line); |
|
| 278 | + $data = array(); |
|
| 279 | + $data['hex'] = $line[1]; // hex |
|
| 280 | + $data['ident'] = $line[2]; // ident |
|
| 281 | + $data['altitude'] = $line[3]; // altitude |
|
| 282 | + $data['speed'] = $line[4]; // speed |
|
| 283 | + $data['heading'] = $line[5]; // heading |
|
| 284 | + $data['latitude'] = $line[6]; // lat |
|
| 285 | + $data['longitude'] = $line[7]; // long |
|
| 286 | + $data['verticalrate'] = ''; // vertical rate |
|
| 287 | + $data['squawk'] = ''; // squawk |
|
| 288 | + $data['emergency'] = ''; // emergency |
|
| 289 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 290 | + $data['format_source'] = 'deltadbtxt'; |
|
| 291 | + $data['id_source'] = $id_source; |
|
| 292 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 293 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 294 | + $SI->add($data); |
|
| 295 | + unset($data); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + $value['last_exec'] = time(); |
|
| 299 | 299 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 300 | 300 | } elseif (($value['format'] == 'whazzup' && (time() - $value['last_exec'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value['last_exec'] > $globalMinFetch))) { |
| 301 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 302 | - $buffer = $Common->getData($value['host']); |
|
| 303 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 304 | - $buffer = explode('\n',$buffer); |
|
| 305 | - foreach ($buffer as $line) { |
|
| 306 | - if ($line != '') { |
|
| 307 | - $line = explode(':', $line); |
|
| 308 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 301 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 302 | + $buffer = $Common->getData($value['host']); |
|
| 303 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 304 | + $buffer = explode('\n',$buffer); |
|
| 305 | + foreach ($buffer as $line) { |
|
| 306 | + if ($line != '') { |
|
| 307 | + $line = explode(':', $line); |
|
| 308 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 309 | 309 | $data = array(); |
| 310 | 310 | $data['id'] = $line[1].'-'.$line[0]; |
| 311 | 311 | $data['pilot_id'] = $line[1]; |
@@ -317,35 +317,35 @@ discard block |
||
| 317 | 317 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 318 | 318 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 319 | 319 | $data['latitude'] = $line[5]; // lat |
| 320 | - $data['longitude'] = $line[6]; // long |
|
| 321 | - $data['verticalrate'] = ''; // vertical rate |
|
| 322 | - $data['squawk'] = ''; // squawk |
|
| 323 | - $data['emergency'] = ''; // emergency |
|
| 324 | - $data['waypoints'] = $line[30]; |
|
| 320 | + $data['longitude'] = $line[6]; // long |
|
| 321 | + $data['verticalrate'] = ''; // vertical rate |
|
| 322 | + $data['squawk'] = ''; // squawk |
|
| 323 | + $data['emergency'] = ''; // emergency |
|
| 324 | + $data['waypoints'] = $line[30]; |
|
| 325 | 325 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 326 | 326 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 327 | - $data['departure_airport_icao'] = $line[11]; |
|
| 328 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 329 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 327 | + $data['departure_airport_icao'] = $line[11]; |
|
| 328 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 329 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 330 | 330 | $data['frequency'] = $line[4]; |
| 331 | 331 | $data['type'] = $line[18]; |
| 332 | 332 | $data['range'] = $line[19]; |
| 333 | 333 | if (isset($line[35])) $data['info'] = $line[35]; |
| 334 | - $data['id_source'] = $id_source; |
|
| 335 | - //$data['arrival_airport_time'] = ; |
|
| 336 | - if ($line[9] != '') { |
|
| 337 | - $aircraft_data = explode('/',$line[9]); |
|
| 338 | - if (isset($aircraft_data[1])) { |
|
| 339 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - /* |
|
| 334 | + $data['id_source'] = $id_source; |
|
| 335 | + //$data['arrival_airport_time'] = ; |
|
| 336 | + if ($line[9] != '') { |
|
| 337 | + $aircraft_data = explode('/',$line[9]); |
|
| 338 | + if (isset($aircraft_data[1])) { |
|
| 339 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + /* |
|
| 343 | 343 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 344 | 344 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 345 | 345 | */ |
| 346 | - $data['format_source'] = $value['format']; |
|
| 346 | + $data['format_source'] = $value['format']; |
|
| 347 | 347 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 348 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 348 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 349 | 349 | elseif ($line[3] == 'ATC') { |
| 350 | 350 | //print_r($data); |
| 351 | 351 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -363,212 +363,212 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
| 365 | 365 | } |
| 366 | - unset($data); |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - } |
|
| 370 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 371 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 372 | - $value['last_exec'] = time(); |
|
| 373 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 374 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 375 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 376 | - if ($buffer != '') { |
|
| 377 | - $all_data = json_decode($buffer,true); |
|
| 378 | - if (isset($all_data['acList'])) { |
|
| 366 | + unset($data); |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + } |
|
| 370 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 371 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 372 | + $value['last_exec'] = time(); |
|
| 373 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 374 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 375 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 376 | + if ($buffer != '') { |
|
| 377 | + $all_data = json_decode($buffer,true); |
|
| 378 | + if (isset($all_data['acList'])) { |
|
| 379 | 379 | foreach ($all_data['acList'] as $line) { |
| 380 | - $data = array(); |
|
| 381 | - $data['hex'] = $line['Icao']; // hex |
|
| 382 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 383 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 384 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 385 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 386 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 387 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 388 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 389 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 390 | - $data['emergency'] = ''; // emergency |
|
| 391 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 392 | - /* |
|
| 380 | + $data = array(); |
|
| 381 | + $data['hex'] = $line['Icao']; // hex |
|
| 382 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 383 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 384 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 385 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 386 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 387 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 388 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 389 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 390 | + $data['emergency'] = ''; // emergency |
|
| 391 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 392 | + /* |
|
| 393 | 393 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 394 | 394 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 395 | 395 | */ |
| 396 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 397 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 398 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 399 | - $data['id_source'] = $id_source; |
|
| 400 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 401 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 402 | - unset($data); |
|
| 396 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 397 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 398 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 399 | + $data['id_source'] = $id_source; |
|
| 400 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 401 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 402 | + unset($data); |
|
| 403 | 403 | } |
| 404 | - } else { |
|
| 404 | + } else { |
|
| 405 | 405 | foreach ($all_data as $line) { |
| 406 | - $data = array(); |
|
| 407 | - $data['hex'] = $line['hex']; // hex |
|
| 408 | - $data['ident'] = $line['flight']; // ident |
|
| 409 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 410 | - $data['speed'] = $line['speed']; // speed |
|
| 411 | - $data['heading'] = $line['track']; // heading |
|
| 412 | - $data['latitude'] = $line['lat']; // lat |
|
| 413 | - $data['longitude'] = $line['lon']; // long |
|
| 414 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 415 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 416 | - $data['emergency'] = ''; // emergency |
|
| 417 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 418 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 419 | - $data['id_source'] = $id_source; |
|
| 420 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 421 | - $SI->add($data); |
|
| 422 | - unset($data); |
|
| 406 | + $data = array(); |
|
| 407 | + $data['hex'] = $line['hex']; // hex |
|
| 408 | + $data['ident'] = $line['flight']; // ident |
|
| 409 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 410 | + $data['speed'] = $line['speed']; // speed |
|
| 411 | + $data['heading'] = $line['track']; // heading |
|
| 412 | + $data['latitude'] = $line['lat']; // lat |
|
| 413 | + $data['longitude'] = $line['lon']; // long |
|
| 414 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 415 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 416 | + $data['emergency'] = ''; // emergency |
|
| 417 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 418 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 419 | + $data['id_source'] = $id_source; |
|
| 420 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 421 | + $SI->add($data); |
|
| 422 | + unset($data); |
|
| 423 | + } |
|
| 423 | 424 | } |
| 424 | - } |
|
| 425 | - } |
|
| 426 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 427 | - $value['last_exec'] = time(); |
|
| 428 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 429 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 430 | - $buffer = $Common->getData($value['host']); |
|
| 431 | - $all_data = json_decode($buffer,true); |
|
| 432 | - if (isset($all_data['planes'])) { |
|
| 425 | + } |
|
| 426 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 427 | + $value['last_exec'] = time(); |
|
| 428 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 429 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 430 | + $buffer = $Common->getData($value['host']); |
|
| 431 | + $all_data = json_decode($buffer,true); |
|
| 432 | + if (isset($all_data['planes'])) { |
|
| 433 | 433 | foreach ($all_data['planes'] as $key => $line) { |
| 434 | - $data = array(); |
|
| 435 | - $data['hex'] = $key; // hex |
|
| 436 | - $data['ident'] = $line[3]; // ident |
|
| 437 | - $data['altitude'] = $line[6]; // altitude |
|
| 438 | - $data['speed'] = $line[8]; // speed |
|
| 439 | - $data['heading'] = $line[7]; // heading |
|
| 440 | - $data['latitude'] = $line[4]; // lat |
|
| 441 | - $data['longitude'] = $line[5]; // long |
|
| 442 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 443 | - $data['squawk'] = $line[10]; // squawk |
|
| 444 | - $data['emergency'] = ''; // emergency |
|
| 445 | - $data['registration'] = $line[2]; |
|
| 446 | - $data['aircraft_icao'] = $line[0]; |
|
| 447 | - $deparr = explode('-',$line[1]); |
|
| 448 | - if (count($deparr) == 2) { |
|
| 434 | + $data = array(); |
|
| 435 | + $data['hex'] = $key; // hex |
|
| 436 | + $data['ident'] = $line[3]; // ident |
|
| 437 | + $data['altitude'] = $line[6]; // altitude |
|
| 438 | + $data['speed'] = $line[8]; // speed |
|
| 439 | + $data['heading'] = $line[7]; // heading |
|
| 440 | + $data['latitude'] = $line[4]; // lat |
|
| 441 | + $data['longitude'] = $line[5]; // long |
|
| 442 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 443 | + $data['squawk'] = $line[10]; // squawk |
|
| 444 | + $data['emergency'] = ''; // emergency |
|
| 445 | + $data['registration'] = $line[2]; |
|
| 446 | + $data['aircraft_icao'] = $line[0]; |
|
| 447 | + $deparr = explode('-',$line[1]); |
|
| 448 | + if (count($deparr) == 2) { |
|
| 449 | 449 | $data['departure_airport_icao'] = $deparr[0]; |
| 450 | 450 | $data['arrival_airport_icao'] = $deparr[1]; |
| 451 | - } |
|
| 452 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 453 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 454 | - $data['id_source'] = $id_source; |
|
| 455 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 456 | - $SI->add($data); |
|
| 457 | - unset($data); |
|
| 451 | + } |
|
| 452 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 453 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 454 | + $data['id_source'] = $id_source; |
|
| 455 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 456 | + $SI->add($data); |
|
| 457 | + unset($data); |
|
| 458 | 458 | } |
| 459 | - } |
|
| 460 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 461 | - $value['last_exec'] = time(); |
|
| 462 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 463 | - } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 464 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 465 | - $buffer = $Common->getData($value['host']); |
|
| 466 | - $all_data = json_decode($buffer,true); |
|
| 467 | - foreach ($all_data as $key => $line) { |
|
| 459 | + } |
|
| 460 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 461 | + $value['last_exec'] = time(); |
|
| 462 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 463 | + } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 464 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 465 | + $buffer = $Common->getData($value['host']); |
|
| 466 | + $all_data = json_decode($buffer,true); |
|
| 467 | + foreach ($all_data as $key => $line) { |
|
| 468 | 468 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 469 | - $data = array(); |
|
| 470 | - $data['hex'] = $line[0]; |
|
| 471 | - $data['ident'] = $line[16]; //$line[13] |
|
| 472 | - $data['altitude'] = $line[4]; // altitude |
|
| 473 | - $data['speed'] = $line[5]; // speed |
|
| 474 | - $data['heading'] = $line[3]; // heading |
|
| 475 | - $data['latitude'] = $line[1]; // lat |
|
| 476 | - $data['longitude'] = $line[2]; // long |
|
| 477 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 478 | - $data['squawk'] = $line[6]; // squawk |
|
| 479 | - $data['aircraft_icao'] = $line[8]; |
|
| 480 | - $data['registration'] = $line[9]; |
|
| 481 | - $data['departure_airport_iata'] = $line[11]; |
|
| 482 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 483 | - $data['emergency'] = ''; // emergency |
|
| 484 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 485 | - $data['format_source'] = 'fr24json'; |
|
| 486 | - $data['id_source'] = $id_source; |
|
| 487 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 488 | - $SI->add($data); |
|
| 489 | - unset($data); |
|
| 469 | + $data = array(); |
|
| 470 | + $data['hex'] = $line[0]; |
|
| 471 | + $data['ident'] = $line[16]; //$line[13] |
|
| 472 | + $data['altitude'] = $line[4]; // altitude |
|
| 473 | + $data['speed'] = $line[5]; // speed |
|
| 474 | + $data['heading'] = $line[3]; // heading |
|
| 475 | + $data['latitude'] = $line[1]; // lat |
|
| 476 | + $data['longitude'] = $line[2]; // long |
|
| 477 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 478 | + $data['squawk'] = $line[6]; // squawk |
|
| 479 | + $data['aircraft_icao'] = $line[8]; |
|
| 480 | + $data['registration'] = $line[9]; |
|
| 481 | + $data['departure_airport_iata'] = $line[11]; |
|
| 482 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 483 | + $data['emergency'] = ''; // emergency |
|
| 484 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 485 | + $data['format_source'] = 'fr24json'; |
|
| 486 | + $data['id_source'] = $id_source; |
|
| 487 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 488 | + $SI->add($data); |
|
| 489 | + unset($data); |
|
| 490 | + } |
|
| 490 | 491 | } |
| 491 | - } |
|
| 492 | - //$last_exec['fr24json'] = time(); |
|
| 493 | - $value['last_exec'] = time(); |
|
| 494 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 495 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 496 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 497 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 498 | - //echo $buffer; |
|
| 499 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 500 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 501 | - $all_data = json_decode($buffer,true); |
|
| 502 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 492 | + //$last_exec['fr24json'] = time(); |
|
| 493 | + $value['last_exec'] = time(); |
|
| 494 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 495 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 496 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 497 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 498 | + //echo $buffer; |
|
| 499 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 500 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 501 | + $all_data = json_decode($buffer,true); |
|
| 502 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 503 | 503 | die(json_last_error_msg()); |
| 504 | - } |
|
| 505 | - if (isset($all_data['mrkrs'])) { |
|
| 504 | + } |
|
| 505 | + if (isset($all_data['mrkrs'])) { |
|
| 506 | 506 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 507 | - if (isset($line['inf'])) { |
|
| 507 | + if (isset($line['inf'])) { |
|
| 508 | 508 | $data = array(); |
| 509 | 509 | $data['hex'] = $line['inf']['ia']; |
| 510 | 510 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 511 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 512 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 513 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 514 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 515 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 516 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 517 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 518 | - //$data['aircraft_icao'] = $line[8]; |
|
| 519 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 511 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 512 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 513 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 514 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 515 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 516 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 517 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 518 | + //$data['aircraft_icao'] = $line[8]; |
|
| 519 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 520 | 520 | //$data['departure_airport_iata'] = $line[11]; |
| 521 | 521 | //$data['arrival_airport_iata'] = $line[12]; |
| 522 | - //$data['emergency'] = ''; // emergency |
|
| 522 | + //$data['emergency'] = ''; // emergency |
|
| 523 | 523 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 524 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 525 | - $data['id_source'] = $id_source; |
|
| 524 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 525 | + $data['id_source'] = $id_source; |
|
| 526 | 526 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 527 | 527 | $SI->add($data); |
| 528 | 528 | unset($data); |
| 529 | - } |
|
| 529 | + } |
|
| 530 | + } |
|
| 530 | 531 | } |
| 531 | - } |
|
| 532 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 533 | - $value['last_exec'] = time(); |
|
| 534 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 535 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 536 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 537 | - $buffer = $Common->getData($value['host']); |
|
| 538 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 532 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 533 | + $value['last_exec'] = time(); |
|
| 534 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 535 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 536 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 537 | + $buffer = $Common->getData($value['host']); |
|
| 538 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 539 | 539 | |
| 540 | - if (isset($all_data['pireps'])) { |
|
| 541 | - foreach ($all_data['pireps'] as $line) { |
|
| 542 | - $data = array(); |
|
| 543 | - $data['hex'] = str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT); |
|
| 544 | - $data['ident'] = $line['callsign']; // ident |
|
| 545 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 546 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 547 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 548 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 549 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 550 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 551 | - $data['latitude'] = $line['lat']; // lat |
|
| 552 | - $data['longitude'] = $line['lon']; // long |
|
| 553 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 554 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 555 | - //$data['emergency'] = ''; // emergency |
|
| 556 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 557 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 558 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 559 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 560 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 561 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 562 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 563 | - else $data['info'] = ''; |
|
| 564 | - $data['format_source'] = 'pireps'; |
|
| 565 | - $data['id_source'] = $id_source; |
|
| 566 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 567 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 568 | - if ($line['icon'] == 'plane') { |
|
| 540 | + if (isset($all_data['pireps'])) { |
|
| 541 | + foreach ($all_data['pireps'] as $line) { |
|
| 542 | + $data = array(); |
|
| 543 | + $data['hex'] = str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT); |
|
| 544 | + $data['ident'] = $line['callsign']; // ident |
|
| 545 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 546 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 547 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 548 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 549 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 550 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 551 | + $data['latitude'] = $line['lat']; // lat |
|
| 552 | + $data['longitude'] = $line['lon']; // long |
|
| 553 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 554 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 555 | + //$data['emergency'] = ''; // emergency |
|
| 556 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 557 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 558 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 559 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 560 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 561 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 562 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 563 | + else $data['info'] = ''; |
|
| 564 | + $data['format_source'] = 'pireps'; |
|
| 565 | + $data['id_source'] = $id_source; |
|
| 566 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 567 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 568 | + if ($line['icon'] == 'plane') { |
|
| 569 | 569 | $SI->add($data); |
| 570 | - // print_r($data); |
|
| 571 | - } elseif ($line['icon'] == 'ct') { |
|
| 570 | + // print_r($data); |
|
| 571 | + } elseif ($line['icon'] == 'ct') { |
|
| 572 | 572 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 573 | 573 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 574 | 574 | $typec = substr($data['ident'],-3); |
@@ -583,178 +583,178 @@ discard block |
||
| 583 | 583 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 584 | 584 | else $data['type'] = 'Observer'; |
| 585 | 585 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
| 586 | - } |
|
| 587 | - unset($data); |
|
| 586 | + } |
|
| 587 | + unset($data); |
|
| 588 | + } |
|
| 588 | 589 | } |
| 589 | - } |
|
| 590 | - //$last_exec['pirepsjson'] = time(); |
|
| 591 | - $value['last_exec'] = time(); |
|
| 592 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 593 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 594 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 595 | - $buffer = $Common->getData($value['host']); |
|
| 596 | - $all_data = json_decode($buffer,true); |
|
| 597 | - if ($buffer != '' && is_array($all_data)) { |
|
| 590 | + //$last_exec['pirepsjson'] = time(); |
|
| 591 | + $value['last_exec'] = time(); |
|
| 592 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 593 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
|
| 594 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 595 | + $buffer = $Common->getData($value['host']); |
|
| 596 | + $all_data = json_decode($buffer,true); |
|
| 597 | + if ($buffer != '' && is_array($all_data)) { |
|
| 598 | 598 | foreach ($all_data as $line) { |
| 599 | - $data = array(); |
|
| 600 | - //$data['id'] = $line['id']; // id not usable |
|
| 601 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 602 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 603 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 604 | - $data['ident'] = $line['flightnum']; // ident |
|
| 605 | - $data['altitude'] = $line['alt']; // altitude |
|
| 606 | - $data['speed'] = $line['gs']; // speed |
|
| 607 | - $data['heading'] = $line['heading']; // heading |
|
| 608 | - $data['latitude'] = $line['lat']; // lat |
|
| 609 | - $data['longitude'] = $line['lng']; // long |
|
| 610 | - $data['verticalrate'] = ''; // verticale rate |
|
| 611 | - $data['squawk'] = ''; // squawk |
|
| 612 | - $data['emergency'] = ''; // emergency |
|
| 613 | - //$data['datetime'] = $line['lastupdate']; |
|
| 614 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 615 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 616 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 617 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 618 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 619 | - $data['registration'] = $line['aircraft']; |
|
| 620 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 621 | - if (isset($line['aircraftname'])) { |
|
| 599 | + $data = array(); |
|
| 600 | + //$data['id'] = $line['id']; // id not usable |
|
| 601 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 602 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 603 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 604 | + $data['ident'] = $line['flightnum']; // ident |
|
| 605 | + $data['altitude'] = $line['alt']; // altitude |
|
| 606 | + $data['speed'] = $line['gs']; // speed |
|
| 607 | + $data['heading'] = $line['heading']; // heading |
|
| 608 | + $data['latitude'] = $line['lat']; // lat |
|
| 609 | + $data['longitude'] = $line['lng']; // long |
|
| 610 | + $data['verticalrate'] = ''; // verticale rate |
|
| 611 | + $data['squawk'] = ''; // squawk |
|
| 612 | + $data['emergency'] = ''; // emergency |
|
| 613 | + //$data['datetime'] = $line['lastupdate']; |
|
| 614 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 615 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 616 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 617 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 618 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 619 | + $data['registration'] = $line['aircraft']; |
|
| 620 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 621 | + if (isset($line['aircraftname'])) { |
|
| 622 | 622 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 623 | 623 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 624 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 625 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 626 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 627 | - else { |
|
| 628 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 629 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 630 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 631 | - } |
|
| 632 | - } |
|
| 633 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 634 | - $data['id_source'] = $id_source; |
|
| 635 | - $data['format_source'] = 'phpvmacars'; |
|
| 636 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 637 | - $SI->add($data); |
|
| 638 | - unset($data); |
|
| 624 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 625 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 626 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 627 | + else { |
|
| 628 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 629 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 630 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 634 | + $data['id_source'] = $id_source; |
|
| 635 | + $data['format_source'] = 'phpvmacars'; |
|
| 636 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 637 | + $SI->add($data); |
|
| 638 | + unset($data); |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | - //$last_exec['phpvmacars'] = time(); |
|
| 642 | - $value['last_exec'] = time(); |
|
| 641 | + //$last_exec['phpvmacars'] = time(); |
|
| 642 | + $value['last_exec'] = time(); |
|
| 643 | 643 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 644 | 644 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast') { |
| 645 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 645 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 646 | 646 | |
| 647 | - //$read = array( $sockets[$id] ); |
|
| 648 | - $read = $sockets; |
|
| 649 | - $write = NULL; |
|
| 650 | - $e = NULL; |
|
| 651 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 652 | - if ($e != NULL) var_dump($e); |
|
| 653 | - if ($n > 0) { |
|
| 647 | + //$read = array( $sockets[$id] ); |
|
| 648 | + $read = $sockets; |
|
| 649 | + $write = NULL; |
|
| 650 | + $e = NULL; |
|
| 651 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 652 | + if ($e != NULL) var_dump($e); |
|
| 653 | + if ($n > 0) { |
|
| 654 | 654 | foreach ($read as $nb => $r) { |
| 655 | - //$value = $formats[$nb]; |
|
| 656 | - $format = $globalSources[$nb]['format']; |
|
| 657 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 658 | - //echo $buffer."\n"; |
|
| 659 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 660 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 661 | - $dataFound = false; |
|
| 662 | - $error = false; |
|
| 663 | - //$SI::del(); |
|
| 664 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 665 | - // SBS format is CSV format |
|
| 666 | - if ($buffer != '') { |
|
| 655 | + //$value = $formats[$nb]; |
|
| 656 | + $format = $globalSources[$nb]['format']; |
|
| 657 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 658 | + //echo $buffer."\n"; |
|
| 659 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 660 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 661 | + $dataFound = false; |
|
| 662 | + $error = false; |
|
| 663 | + //$SI::del(); |
|
| 664 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 665 | + // SBS format is CSV format |
|
| 666 | + if ($buffer != '') { |
|
| 667 | 667 | $tt = 0; |
| 668 | 668 | if ($format == 'raw') { |
| 669 | - // AVR format |
|
| 670 | - $data = $SBS->parse($buffer); |
|
| 671 | - if (is_array($data)) { |
|
| 669 | + // AVR format |
|
| 670 | + $data = $SBS->parse($buffer); |
|
| 671 | + if (is_array($data)) { |
|
| 672 | 672 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 673 | 673 | $data['format_source'] = 'raw'; |
| 674 | 674 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 675 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 676 | - $SI->add($data); |
|
| 677 | - } |
|
| 675 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 676 | + $SI->add($data); |
|
| 677 | + } |
|
| 678 | 678 | } elseif ($format == 'beast') { |
| 679 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 680 | - die; |
|
| 679 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 680 | + die; |
|
| 681 | 681 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 682 | - $line = explode("\t", $buffer); |
|
| 683 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 682 | + $line = explode("\t", $buffer); |
|
| 683 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 684 | 684 | $key = $line[$k]; |
| 685 | - $lined[$key] = $line[$k+1]; |
|
| 686 | - } |
|
| 687 | - if (count($lined) > 3) { |
|
| 688 | - $data['hex'] = $lined['hexid']; |
|
| 689 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 690 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 691 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 692 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 693 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 694 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 695 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 696 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 697 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 698 | - $data['id_source'] = $id_source; |
|
| 699 | - $data['format_source'] = 'tsv'; |
|
| 700 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 701 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 702 | - $SI->add($data); |
|
| 703 | - unset($lined); |
|
| 704 | - unset($data); |
|
| 705 | - } else $error = true; |
|
| 685 | + $lined[$key] = $line[$k+1]; |
|
| 686 | + } |
|
| 687 | + if (count($lined) > 3) { |
|
| 688 | + $data['hex'] = $lined['hexid']; |
|
| 689 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 690 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 691 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 692 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 693 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 694 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 695 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 696 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 697 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 698 | + $data['id_source'] = $id_source; |
|
| 699 | + $data['format_source'] = 'tsv'; |
|
| 700 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 701 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 702 | + $SI->add($data); |
|
| 703 | + unset($lined); |
|
| 704 | + unset($data); |
|
| 705 | + } else $error = true; |
|
| 706 | 706 | } elseif ($format == 'aprs' && $use_aprs) { |
| 707 | - if ($aprs_connect == 0) { |
|
| 707 | + if ($aprs_connect == 0) { |
|
| 708 | 708 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 709 | 709 | $aprs_connect = 1; |
| 710 | - } |
|
| 711 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 710 | + } |
|
| 711 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 712 | 712 | $aprs_last_tx = time(); |
| 713 | 713 | $data_aprs = "# Keep alive"; |
| 714 | 714 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 715 | - } |
|
| 716 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 717 | - if (substr($buffer,0,1) != '#') { |
|
| 715 | + } |
|
| 716 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 717 | + if (substr($buffer,0,1) != '#') { |
|
| 718 | 718 | $line = $APRS->parse($buffer); |
| 719 | 719 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 720 | - $data = array(); |
|
| 721 | - //print_r($line); |
|
| 722 | - $data['hex'] = $line['address']; |
|
| 723 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 724 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 725 | - $data['ident'] = $line['ident']; |
|
| 726 | - $data['latitude'] = $line['latitude']; |
|
| 727 | - $data['longitude'] = $line['longitude']; |
|
| 728 | - //$data['verticalrate'] = $line[16]; |
|
| 729 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 730 | - else $data['speed'] = 0; |
|
| 731 | - $data['altitude'] = $line['altitude']; |
|
| 732 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 733 | - //else $data['heading'] = 0; |
|
| 734 | - $data['aircraft_type'] = $line['stealth']; |
|
| 735 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 736 | - $data['id_source'] = $id_source; |
|
| 737 | - $data['format_source'] = 'aprs'; |
|
| 738 | - $data['source_name'] = $line['source']; |
|
| 739 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 740 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 741 | - $aprsdate = strtotime($data['datetime']); |
|
| 742 | - // Accept data if time <= system time + 20s |
|
| 743 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20)) $send = $SI->add($data); |
|
| 744 | - else { |
|
| 720 | + $data = array(); |
|
| 721 | + //print_r($line); |
|
| 722 | + $data['hex'] = $line['address']; |
|
| 723 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 724 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 725 | + $data['ident'] = $line['ident']; |
|
| 726 | + $data['latitude'] = $line['latitude']; |
|
| 727 | + $data['longitude'] = $line['longitude']; |
|
| 728 | + //$data['verticalrate'] = $line[16]; |
|
| 729 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 730 | + else $data['speed'] = 0; |
|
| 731 | + $data['altitude'] = $line['altitude']; |
|
| 732 | + if (isset($line['course'])) $data['heading'] = $line['course']; |
|
| 733 | + //else $data['heading'] = 0; |
|
| 734 | + $data['aircraft_type'] = $line['stealth']; |
|
| 735 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 736 | + $data['id_source'] = $id_source; |
|
| 737 | + $data['format_source'] = 'aprs'; |
|
| 738 | + $data['source_name'] = $line['source']; |
|
| 739 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 740 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 741 | + $aprsdate = strtotime($data['datetime']); |
|
| 742 | + // Accept data if time <= system time + 20s |
|
| 743 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20)) $send = $SI->add($data); |
|
| 744 | + else { |
|
| 745 | 745 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 746 | 746 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 747 | - } |
|
| 748 | - unset($data); |
|
| 747 | + } |
|
| 748 | + unset($data); |
|
| 749 | 749 | } |
| 750 | 750 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 751 | 751 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 752 | - } |
|
| 752 | + } |
|
| 753 | 753 | } else { |
| 754 | - $line = explode(',', $buffer); |
|
| 755 | - if (count($line) > 20) { |
|
| 756 | - $data['hex'] = $line[4]; |
|
| 757 | - /* |
|
| 754 | + $line = explode(',', $buffer); |
|
| 755 | + if (count($line) > 20) { |
|
| 756 | + $data['hex'] = $line[4]; |
|
| 757 | + /* |
|
| 758 | 758 | $data['datetime'] = $line[6].' '.$line[7]; |
| 759 | 759 | date_default_timezone_set($globalTimezone); |
| 760 | 760 | $datetime = new DateTime($data['datetime']); |
@@ -762,27 +762,27 @@ discard block |
||
| 762 | 762 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 763 | 763 | date_default_timezone_set('UTC'); |
| 764 | 764 | */ |
| 765 | - // Force datetime to current UTC datetime |
|
| 766 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 767 | - $data['ident'] = trim($line[10]); |
|
| 768 | - $data['latitude'] = $line[14]; |
|
| 769 | - $data['longitude'] = $line[15]; |
|
| 770 | - $data['verticalrate'] = $line[16]; |
|
| 771 | - $data['emergency'] = $line[20]; |
|
| 772 | - $data['speed'] = $line[12]; |
|
| 773 | - $data['squawk'] = $line[17]; |
|
| 774 | - $data['altitude'] = $line[11]; |
|
| 775 | - $data['heading'] = $line[13]; |
|
| 776 | - $data['ground'] = $line[21]; |
|
| 777 | - $data['emergency'] = $line[19]; |
|
| 778 | - $data['format_source'] = 'sbs'; |
|
| 765 | + // Force datetime to current UTC datetime |
|
| 766 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 767 | + $data['ident'] = trim($line[10]); |
|
| 768 | + $data['latitude'] = $line[14]; |
|
| 769 | + $data['longitude'] = $line[15]; |
|
| 770 | + $data['verticalrate'] = $line[16]; |
|
| 771 | + $data['emergency'] = $line[20]; |
|
| 772 | + $data['speed'] = $line[12]; |
|
| 773 | + $data['squawk'] = $line[17]; |
|
| 774 | + $data['altitude'] = $line[11]; |
|
| 775 | + $data['heading'] = $line[13]; |
|
| 776 | + $data['ground'] = $line[21]; |
|
| 777 | + $data['emergency'] = $line[19]; |
|
| 778 | + $data['format_source'] = 'sbs'; |
|
| 779 | 779 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 780 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 781 | - $data['id_source'] = $id_source; |
|
| 782 | - $send = $SI->add($data); |
|
| 783 | - unset($data); |
|
| 784 | - } else $error = true; |
|
| 785 | - if ($error) { |
|
| 780 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 781 | + $data['id_source'] = $id_source; |
|
| 782 | + $send = $SI->add($data); |
|
| 783 | + unset($data); |
|
| 784 | + } else $error = true; |
|
| 785 | + if ($error) { |
|
| 786 | 786 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 787 | 787 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 788 | 788 | } else { |
@@ -795,50 +795,50 @@ discard block |
||
| 795 | 795 | if ($globalDebug) echo "Reconnect after an error...\n"; |
| 796 | 796 | connect_all($globalSources); |
| 797 | 797 | } |
| 798 | - } |
|
| 798 | + } |
|
| 799 | 799 | } |
| 800 | 800 | // Sleep for xxx microseconds |
| 801 | 801 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 802 | - } else { |
|
| 802 | + } else { |
|
| 803 | 803 | $tt++; |
| 804 | 804 | if ($tt > 30) { |
| 805 | - if ($globalDebug)echo "ERROR : Reconnect..."; |
|
| 806 | - //@socket_close($r); |
|
| 807 | - sleep(2); |
|
| 808 | - connect_all($globalSources); |
|
| 809 | - break; |
|
| 810 | - $tt = 0; |
|
| 805 | + if ($globalDebug)echo "ERROR : Reconnect..."; |
|
| 806 | + //@socket_close($r); |
|
| 807 | + sleep(2); |
|
| 808 | + connect_all($globalSources); |
|
| 809 | + break; |
|
| 810 | + $tt = 0; |
|
| 811 | + } |
|
| 811 | 812 | } |
| 812 | - } |
|
| 813 | 813 | } |
| 814 | - } else { |
|
| 814 | + } else { |
|
| 815 | 815 | $error = socket_strerror(socket_last_error()); |
| 816 | 816 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 817 | 817 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
| 818 | 818 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 819 | 819 | // Restart the script if possible |
| 820 | 820 | if (is_array($sockets)) { |
| 821 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 821 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 822 | 822 | |
| 823 | - foreach ($sockets as $sock) { |
|
| 823 | + foreach ($sockets as $sock) { |
|
| 824 | 824 | @socket_shutdown($sock,2); |
| 825 | 825 | @socket_close($sock); |
| 826 | - } |
|
| 826 | + } |
|
| 827 | 827 | |
| 828 | 828 | } |
| 829 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 830 | - sleep(2); |
|
| 831 | - $time = time(); |
|
| 832 | - //connect_all($hosts); |
|
| 833 | - connect_all($globalSources); |
|
| 829 | + if ($globalDebug) echo "Restart all connections..."; |
|
| 830 | + sleep(2); |
|
| 831 | + $time = time(); |
|
| 832 | + //connect_all($hosts); |
|
| 833 | + connect_all($globalSources); |
|
| 834 | 834 | |
| 835 | 835 | } |
| 836 | - } |
|
| 836 | + } |
|
| 837 | 837 | } |
| 838 | 838 | if ($globalDaemon == false) { |
| 839 | - $SI->checkAll(); |
|
| 839 | + $SI->checkAll(); |
|
| 840 | + } |
|
| 840 | 841 | } |
| 841 | - } |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | ?> |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 43 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 44 | 44 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 45 | 45 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 46 | 46 | if (isset($options['s'])) $globalSources[] = array('host' => $options['s']); |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | else $id_source = 1; |
| 51 | 51 | if (isset($globalServer) && $globalServer) { |
| 52 | 52 | if ($globalDebug) echo "Using Server Mode\n"; |
| 53 | - $SI=new SpotterServer(); |
|
| 54 | -} else $SI=new SpotterImport($Connection->db); |
|
| 53 | + $SI = new SpotterServer(); |
|
| 54 | +} else $SI = new SpotterImport($Connection->db); |
|
| 55 | 55 | //$APRS=new APRS($Connection->db); |
| 56 | -$SBS=new SBS($Connection->db); |
|
| 57 | -$Common=new Common(); |
|
| 56 | +$SBS = new SBS($Connection->db); |
|
| 57 | +$Common = new Common(); |
|
| 58 | 58 | date_default_timezone_set('UTC'); |
| 59 | 59 | //$servertz = system('date +%Z'); |
| 60 | 60 | // signal handler - playing nice with sockets and dump1090 |
| 61 | 61 | if (function_exists('pcntl_fork')) { |
| 62 | - pcntl_signal(SIGINT, function($signo) { |
|
| 62 | + pcntl_signal(SIGINT, function($signo) { |
|
| 63 | 63 | global $sockets; |
| 64 | 64 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 65 | 65 | die("Bye!\n"); |
@@ -87,28 +87,28 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function connect_all($hosts) { |
| 89 | 89 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 90 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 90 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs; |
|
| 91 | 91 | foreach ($hosts as $id => $value) { |
| 92 | 92 | $host = $value['host']; |
| 93 | 93 | $globalSources[$id]['last_exec'] = 0; |
| 94 | 94 | // Here we check type of source(s) |
| 95 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 96 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 95 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 96 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 97 | 97 | //$formats[$id] = 'deltadbtxt'; |
| 98 | 98 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 99 | 99 | //$last_exec['deltadbtxt'] = 0; |
| 100 | 100 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 101 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 101 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 102 | 102 | //$formats[$id] = 'vatsimtxt'; |
| 103 | 103 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 104 | 104 | //$last_exec['vatsimtxt'] = 0; |
| 105 | 105 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 106 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 106 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 107 | 107 | //$formats[$id] = 'aircraftlistjson'; |
| 108 | 108 | $$globalSources[$id]['format'] = 'aircraftlistjson'; |
| 109 | 109 | //$last_exec['aircraftlistjson'] = 0; |
| 110 | 110 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 111 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 111 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 112 | 112 | //$formats[$id] = 'radarvirtueljson'; |
| 113 | 113 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 114 | 114 | //$last_exec['radarvirtueljson'] = 0; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 118 | 118 | exit(0); |
| 119 | 119 | } |
| 120 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 120 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 121 | 121 | //$formats[$id] = 'planeupdatefaa'; |
| 122 | 122 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 123 | 123 | //$last_exec['planeupdatefaa'] = 0; |
@@ -126,22 +126,22 @@ discard block |
||
| 126 | 126 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 127 | 127 | exit(0); |
| 128 | 128 | } |
| 129 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 129 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 130 | 130 | //$formats[$id] = 'phpvmacars'; |
| 131 | 131 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 132 | 132 | //$last_exec['phpvmacars'] = 0; |
| 133 | 133 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 134 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 134 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'whazzup'; |
| 136 | 136 | $globalSources[$id]['format'] = 'whazzup'; |
| 137 | 137 | //$last_exec['whazzup'] = 0; |
| 138 | 138 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 139 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 139 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 140 | 140 | //$formats[$id] = 'pirepsjson'; |
| 141 | 141 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 142 | 142 | //$last_exec['pirepsjson'] = 0; |
| 143 | 143 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 144 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 144 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 145 | 145 | //$formats[$id] = 'fr24json'; |
| 146 | 146 | $globalSources[$id]['format'] = 'fr24json'; |
| 147 | 147 | //$last_exec['fr24json'] = 0; |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | exit(0); |
| 152 | 152 | } |
| 153 | 153 | //} else if (preg_match('/10001/',$host)) { |
| 154 | - } else if (preg_match('/10001/',$host) || $globalSources[$id]['port'] == '10001') { |
|
| 154 | + } else if (preg_match('/10001/', $host) || $globalSources[$id]['port'] == '10001') { |
|
| 155 | 155 | //$formats[$id] = 'tsv'; |
| 156 | 156 | $globalSources[$id]['format'] = 'tsv'; |
| 157 | 157 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 158 | 158 | } |
| 159 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 159 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 160 | 160 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 161 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 162 | - $hostport = explode(':',$host); |
|
| 161 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 162 | + $hostport = explode(':', $host); |
|
| 163 | 163 | if (isset($hostport[1])) $port = $hostport[1]; |
| 164 | 164 | else $port = $globalSources[$id]['port']; |
| 165 | - $s = create_socket($host,$port, $errno, $errstr); |
|
| 165 | + $s = create_socket($host, $port, $errno, $errstr); |
|
| 166 | 166 | if ($s) { |
| 167 | 167 | $sockets[$id] = $s; |
| 168 | 168 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 169 | - if (preg_match('/aprs/',$host)) { |
|
| 169 | + if (preg_match('/aprs/', $host)) { |
|
| 170 | 170 | //$formats[$id] = 'aprs'; |
| 171 | 171 | $globalSources[$id]['format'] = 'aprs'; |
| 172 | 172 | //$aprs_connect = 0; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 205 | 205 | else $timeout = 20; |
| 206 | 206 | $errno = ''; |
| 207 | -$errstr=''; |
|
| 207 | +$errstr = ''; |
|
| 208 | 208 | |
| 209 | 209 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 210 | 210 | /* Initiate connections to all the hosts simultaneously */ |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | if ($use_aprs) { |
| 226 | 226 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 227 | - $APRS=new APRS($Connection->db); |
|
| 227 | + $APRS = new APRS($Connection->db); |
|
| 228 | 228 | $aprs_connect = 0; |
| 229 | 229 | $aprs_keep = 240; |
| 230 | 230 | $aprs_last_tx = time(); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | else $aprs_ssid = 'FAM'; |
| 236 | 236 | //else $aprs_ssid = 'PerlEx'; |
| 237 | 237 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 238 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 238 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 239 | 239 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
| 240 | 240 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
| 241 | 241 | } |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | sleep(1); |
| 246 | 246 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 247 | 247 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 248 | -$endtime = time()+$globalCronEnd; |
|
| 248 | +$endtime = time() + $globalCronEnd; |
|
| 249 | 249 | $i = 1; |
| 250 | 250 | $tt = 0; |
| 251 | 251 | |
| 252 | 252 | // Delete all ATC |
| 253 | 253 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 254 | - $ATC=new ATC($Connection->db); |
|
| 254 | + $ATC = new ATC($Connection->db); |
|
| 255 | 255 | } |
| 256 | 256 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 257 | 257 | $ATC->deleteAll(); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 261 | 261 | while ($i > 0) { |
| 262 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 262 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 263 | 263 | // Delete old ATC |
| 264 | 264 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 265 | 265 | $ATC->deleteOldATC(); |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | if ($value['format'] == 'deltadbtxt' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 271 | 271 | //$buffer = $Common->getData($hosts[$id]); |
| 272 | 272 | $buffer = $Common->getData($value['host']); |
| 273 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 274 | - $buffer = explode('\n',$buffer); |
|
| 273 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 274 | + $buffer = explode('\n', $buffer); |
|
| 275 | 275 | foreach ($buffer as $line) { |
| 276 | 276 | if ($line != '') { |
| 277 | 277 | $line = explode(',', $line); |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | } elseif (($value['format'] == 'whazzup' && (time() - $value['last_exec'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value['last_exec'] > $globalMinFetch))) { |
| 301 | 301 | //$buffer = $Common->getData($hosts[$id]); |
| 302 | 302 | $buffer = $Common->getData($value['host']); |
| 303 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 304 | - $buffer = explode('\n',$buffer); |
|
| 303 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 304 | + $buffer = explode('\n', $buffer); |
|
| 305 | 305 | foreach ($buffer as $line) { |
| 306 | 306 | if ($line != '') { |
| 307 | 307 | $line = explode(':', $line); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $data['id'] = $line[1].'-'.$line[0]; |
| 311 | 311 | $data['pilot_id'] = $line[1]; |
| 312 | 312 | $data['pilot_name'] = $line[2]; |
| 313 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
| 313 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
| 314 | 314 | $data['ident'] = $line[0]; // ident |
| 315 | 315 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 316 | 316 | $data['speed'] = $line[8]; // speed |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 326 | 326 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 327 | 327 | $data['departure_airport_icao'] = $line[11]; |
| 328 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 328 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 329 | 329 | $data['arrival_airport_icao'] = $line[13]; |
| 330 | 330 | $data['frequency'] = $line[4]; |
| 331 | 331 | $data['type'] = $line[18]; |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $data['id_source'] = $id_source; |
| 335 | 335 | //$data['arrival_airport_time'] = ; |
| 336 | 336 | if ($line[9] != '') { |
| 337 | - $aircraft_data = explode('/',$line[9]); |
|
| 337 | + $aircraft_data = explode('/', $line[9]); |
|
| 338 | 338 | if (isset($aircraft_data[1])) { |
| 339 | 339 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 340 | 340 | } |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | if ($line[3] == 'PILOT') $SI->add($data); |
| 349 | 349 | elseif ($line[3] == 'ATC') { |
| 350 | 350 | //print_r($data); |
| 351 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 352 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 353 | - $typec = substr($data['ident'],-3); |
|
| 351 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 352 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 353 | + $typec = substr($data['ident'], -3); |
|
| 354 | 354 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 355 | 355 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 356 | 356 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 362 | 362 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 363 | 363 | |
| 364 | - echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
|
| 364 | + echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']); |
|
| 365 | 365 | } |
| 366 | 366 | unset($data); |
| 367 | 367 | } |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | $value['last_exec'] = time(); |
| 373 | 373 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 374 | 374 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 375 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 375 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 376 | 376 | if ($buffer != '') { |
| 377 | - $all_data = json_decode($buffer,true); |
|
| 377 | + $all_data = json_decode($buffer, true); |
|
| 378 | 378 | if (isset($all_data['acList'])) { |
| 379 | 379 | foreach ($all_data['acList'] as $line) { |
| 380 | 380 | $data = array(); |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 429 | 429 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 430 | 430 | $buffer = $Common->getData($value['host']); |
| 431 | - $all_data = json_decode($buffer,true); |
|
| 431 | + $all_data = json_decode($buffer, true); |
|
| 432 | 432 | if (isset($all_data['planes'])) { |
| 433 | 433 | foreach ($all_data['planes'] as $key => $line) { |
| 434 | 434 | $data = array(); |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | $data['emergency'] = ''; // emergency |
| 445 | 445 | $data['registration'] = $line[2]; |
| 446 | 446 | $data['aircraft_icao'] = $line[0]; |
| 447 | - $deparr = explode('-',$line[1]); |
|
| 447 | + $deparr = explode('-', $line[1]); |
|
| 448 | 448 | if (count($deparr) == 2) { |
| 449 | 449 | $data['departure_airport_icao'] = $deparr[0]; |
| 450 | 450 | $data['arrival_airport_icao'] = $deparr[1]; |
| 451 | 451 | } |
| 452 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 452 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 453 | 453 | $data['format_source'] = 'planeupdatefaa'; |
| 454 | 454 | $data['id_source'] = $id_source; |
| 455 | 455 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } elseif ($value['format'] == 'fr24json' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 464 | 464 | //$buffer = $Common->getData($hosts[$id]); |
| 465 | 465 | $buffer = $Common->getData($value['host']); |
| 466 | - $all_data = json_decode($buffer,true); |
|
| 466 | + $all_data = json_decode($buffer, true); |
|
| 467 | 467 | foreach ($all_data as $key => $line) { |
| 468 | 468 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 469 | 469 | $data = array(); |
@@ -494,11 +494,11 @@ discard block |
||
| 494 | 494 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 495 | 495 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 496 | 496 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 497 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 497 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 498 | 498 | //echo $buffer; |
| 499 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 500 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 501 | - $all_data = json_decode($buffer,true); |
|
| 499 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 500 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 501 | + $all_data = json_decode($buffer, true); |
|
| 502 | 502 | if (json_last_error() != JSON_ERROR_NONE) { |
| 503 | 503 | die(json_last_error_msg()); |
| 504 | 504 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | //$data['departure_airport_iata'] = $line[11]; |
| 521 | 521 | //$data['arrival_airport_iata'] = $line[12]; |
| 522 | 522 | //$data['emergency'] = ''; // emergency |
| 523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 523 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 524 | 524 | $data['format_source'] = 'radarvirtueljson'; |
| 525 | 525 | $data['id_source'] = $id_source; |
| 526 | 526 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -535,12 +535,12 @@ discard block |
||
| 535 | 535 | } elseif ($value['format'] == 'pirepsjson' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 536 | 536 | //$buffer = $Common->getData($hosts[$id]); |
| 537 | 537 | $buffer = $Common->getData($value['host']); |
| 538 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 538 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 539 | 539 | |
| 540 | 540 | if (isset($all_data['pireps'])) { |
| 541 | 541 | foreach ($all_data['pireps'] as $line) { |
| 542 | 542 | $data = array(); |
| 543 | - $data['hex'] = str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT); |
|
| 543 | + $data['hex'] = str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT); |
|
| 544 | 544 | $data['ident'] = $line['callsign']; // ident |
| 545 | 545 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 546 | 546 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -569,9 +569,9 @@ discard block |
||
| 569 | 569 | $SI->add($data); |
| 570 | 570 | // print_r($data); |
| 571 | 571 | } elseif ($line['icon'] == 'ct') { |
| 572 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 573 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 574 | - $typec = substr($data['ident'],-3); |
|
| 572 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 573 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 574 | + $typec = substr($data['ident'], -3); |
|
| 575 | 575 | $data['type'] = ''; |
| 576 | 576 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 577 | 577 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 583 | 583 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 584 | 584 | else $data['type'] = 'Observer'; |
| 585 | - echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']); |
|
| 585 | + echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']); |
|
| 586 | 586 | } |
| 587 | 587 | unset($data); |
| 588 | 588 | } |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | } elseif ($value['format'] == 'phpvmacars' && (time() - $value['last_exec'] > $globalMinFetch)) { |
| 594 | 594 | //$buffer = $Common->getData($hosts[$id]); |
| 595 | 595 | $buffer = $Common->getData($value['host']); |
| 596 | - $all_data = json_decode($buffer,true); |
|
| 596 | + $all_data = json_decode($buffer, true); |
|
| 597 | 597 | if ($buffer != '' && is_array($all_data)) { |
| 598 | 598 | foreach ($all_data as $line) { |
| 599 | 599 | $data = array(); |
| 600 | 600 | //$data['id'] = $line['id']; // id not usable |
| 601 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 601 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 602 | 602 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 603 | 603 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 604 | 604 | $data['ident'] = $line['flightnum']; // ident |
@@ -620,12 +620,12 @@ discard block |
||
| 620 | 620 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 621 | 621 | if (isset($line['aircraftname'])) { |
| 622 | 622 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 623 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 624 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 623 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 624 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 625 | 625 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 626 | 626 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 627 | 627 | else { |
| 628 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 628 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 629 | 629 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 630 | 630 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 631 | 631 | } |
@@ -654,14 +654,14 @@ discard block |
||
| 654 | 654 | foreach ($read as $nb => $r) { |
| 655 | 655 | //$value = $formats[$nb]; |
| 656 | 656 | $format = $globalSources[$nb]['format']; |
| 657 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 657 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 658 | 658 | //echo $buffer."\n"; |
| 659 | 659 | // lets play nice and handle signals such as ctrl-c/kill properly |
| 660 | 660 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 661 | 661 | $dataFound = false; |
| 662 | 662 | $error = false; |
| 663 | 663 | //$SI::del(); |
| 664 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 664 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 665 | 665 | // SBS format is CSV format |
| 666 | 666 | if ($buffer != '') { |
| 667 | 667 | $tt = 0; |
@@ -678,16 +678,16 @@ discard block |
||
| 678 | 678 | } elseif ($format == 'beast') { |
| 679 | 679 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 680 | 680 | die; |
| 681 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 681 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 682 | 682 | $line = explode("\t", $buffer); |
| 683 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 683 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 684 | 684 | $key = $line[$k]; |
| 685 | - $lined[$key] = $line[$k+1]; |
|
| 685 | + $lined[$key] = $line[$k + 1]; |
|
| 686 | 686 | } |
| 687 | 687 | if (count($lined) > 3) { |
| 688 | 688 | $data['hex'] = $lined['hexid']; |
| 689 | 689 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 690 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 690 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 691 | 691 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 692 | 692 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 693 | 693 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -705,22 +705,22 @@ discard block |
||
| 705 | 705 | } else $error = true; |
| 706 | 706 | } elseif ($format == 'aprs' && $use_aprs) { |
| 707 | 707 | if ($aprs_connect == 0) { |
| 708 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 708 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 709 | 709 | $aprs_connect = 1; |
| 710 | 710 | } |
| 711 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 711 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 712 | 712 | $aprs_last_tx = time(); |
| 713 | 713 | $data_aprs = "# Keep alive"; |
| 714 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 714 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 715 | 715 | } |
| 716 | 716 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 717 | - if (substr($buffer,0,1) != '#') { |
|
| 717 | + if (substr($buffer, 0, 1) != '#') { |
|
| 718 | 718 | $line = $APRS->parse($buffer); |
| 719 | 719 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 720 | 720 | $data = array(); |
| 721 | 721 | //print_r($line); |
| 722 | 722 | $data['hex'] = $line['address']; |
| 723 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 723 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 724 | 724 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 725 | 725 | $data['ident'] = $line['ident']; |
| 726 | 726 | $data['latitude'] = $line['latitude']; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $currentdate = date('Y-m-d H:i:s'); |
| 741 | 741 | $aprsdate = strtotime($data['datetime']); |
| 742 | 742 | // Accept data if time <= system time + 20s |
| 743 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20)) $send = $SI->add($data); |
|
| 743 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20)) $send = $SI->add($data); |
|
| 744 | 744 | else { |
| 745 | 745 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 746 | 746 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | } else { |
| 815 | 815 | $error = socket_strerror(socket_last_error()); |
| 816 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 816 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 817 | 817 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) { |
| 818 | 818 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 819 | 819 | // Restart the script if possible |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 822 | 822 | |
| 823 | 823 | foreach ($sockets as $sock) { |
| 824 | - @socket_shutdown($sock,2); |
|
| 824 | + @socket_shutdown($sock, 2); |
|
| 825 | 825 | @socket_close($sock); |
| 826 | 826 | } |
| 827 | 827 | |