@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (Marine)'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -78,8 +82,11 @@ discard block |
||
| 78 | 82 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 79 | 83 | } |
| 80 | 84 | } |
| 81 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 82 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 85 | + if ($filter_query_where == '' && $where) { |
|
| 86 | + $filter_query_where = ' WHERE'; |
|
| 87 | + } elseif ($filter_query_where != '' && $and) { |
|
| 88 | + $filter_query_where .= ' AND'; |
|
| 89 | + } |
|
| 83 | 90 | if ($filter_query_where != '') { |
| 84 | 91 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 85 | 92 | } |
@@ -133,42 +140,84 @@ discard block |
||
| 133 | 140 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 134 | 141 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 135 | 142 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 136 | - */} |
|
| 137 | - elseif (isset($row['marineid'])) { |
|
| 143 | + */} elseif (isset($row['marineid'])) { |
|
| 138 | 144 | $temp_array['marine_id'] = $row['marineid']; |
| 139 | 145 | } else { |
| 140 | 146 | $temp_array['marine_id'] = ''; |
| 141 | 147 | } |
| 142 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 143 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 144 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 145 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 146 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
| 147 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
| 148 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
| 149 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
| 150 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
| 151 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
| 152 | - if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time']; |
|
| 153 | - if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank']; |
|
| 154 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 155 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 156 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 157 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 158 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 159 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 148 | + if (isset($row['fammarine_id'])) { |
|
| 149 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['mmsi'])) { |
|
| 152 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['type'])) { |
|
| 155 | + $temp_array['type'] = $row['type']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['type_id'])) { |
|
| 158 | + $temp_array['type_id'] = $row['type_id']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['status'])) { |
|
| 161 | + $temp_array['status'] = $row['status']; |
|
| 162 | + } |
|
| 163 | + if (isset($row['status_id'])) { |
|
| 164 | + $temp_array['status_id'] = $row['status_id']; |
|
| 165 | + } |
|
| 166 | + if (isset($row['captain_id'])) { |
|
| 167 | + $temp_array['captain_id'] = $row['captain_id']; |
|
| 168 | + } |
|
| 169 | + if (isset($row['captain_name'])) { |
|
| 170 | + $temp_array['captain_name'] = $row['captain_name']; |
|
| 171 | + } |
|
| 172 | + if (isset($row['race_id'])) { |
|
| 173 | + $temp_array['race_id'] = $row['race_id']; |
|
| 174 | + } |
|
| 175 | + if (isset($row['race_name'])) { |
|
| 176 | + $temp_array['race_name'] = $row['race_name']; |
|
| 177 | + } |
|
| 178 | + if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) { |
|
| 179 | + $temp_array['race_time'] = $row['race_time']; |
|
| 180 | + } |
|
| 181 | + if (isset($row['race_rank'])) { |
|
| 182 | + $temp_array['race_rank'] = $row['race_rank']; |
|
| 183 | + } |
|
| 184 | + if (isset($row['ident'])) { |
|
| 185 | + $temp_array['ident'] = $row['ident']; |
|
| 186 | + } |
|
| 187 | + if (isset($row['arrival_port_name'])) { |
|
| 188 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 189 | + } |
|
| 190 | + if (isset($row['latitude'])) { |
|
| 191 | + $temp_array['latitude'] = $row['latitude']; |
|
| 192 | + } |
|
| 193 | + if (isset($row['longitude'])) { |
|
| 194 | + $temp_array['longitude'] = $row['longitude']; |
|
| 195 | + } |
|
| 196 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 197 | + $temp_array['distance'] = $row['distance']; |
|
| 198 | + } |
|
| 199 | + if (isset($row['format_source'])) { |
|
| 200 | + $temp_array['format_source'] = $row['format_source']; |
|
| 201 | + } |
|
| 160 | 202 | if (isset($row['heading'])) { |
| 161 | 203 | $temp_array['heading'] = $row['heading']; |
| 162 | 204 | $heading_direction = $this->parseDirection($row['heading']); |
| 163 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 205 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 206 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + if (isset($row['ground_speed'])) { |
|
| 210 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 164 | 211 | } |
| 165 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 166 | 212 | |
| 167 | 213 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 168 | 214 | { |
| 169 | 215 | $Image = new Image($this->db); |
| 170 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 171 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 216 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 217 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 218 | + } else { |
|
| 219 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 220 | + } |
|
| 172 | 221 | unset($Image); |
| 173 | 222 | if (count($image_array) > 0) { |
| 174 | 223 | $temp_array['image'] = $image_array[0]['image']; |
@@ -220,13 +269,21 @@ discard block |
||
| 220 | 269 | } |
| 221 | 270 | |
| 222 | 271 | $fromsource = NULL; |
| 223 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 224 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 225 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 272 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 273 | + $temp_array['source_name'] = $row['source_name']; |
|
| 274 | + } |
|
| 275 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 276 | + $temp_array['over_country'] = $row['over_country']; |
|
| 277 | + } |
|
| 278 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 279 | + $temp_array['distance'] = $row['distance']; |
|
| 280 | + } |
|
| 226 | 281 | $temp_array['query_number_rows'] = $num_rows; |
| 227 | 282 | $spotter_array[] = $temp_array; |
| 228 | 283 | } |
| 229 | - if ($num_rows == 0) return array(); |
|
| 284 | + if ($num_rows == 0) { |
|
| 285 | + return array(); |
|
| 286 | + } |
|
| 230 | 287 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 231 | 288 | return $spotter_array; |
| 232 | 289 | } |
@@ -252,8 +309,12 @@ discard block |
||
| 252 | 309 | { |
| 253 | 310 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 254 | 311 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 255 | - } else $limit_query = ""; |
|
| 256 | - } else $limit_query = ""; |
|
| 312 | + } else { |
|
| 313 | + $limit_query = ""; |
|
| 314 | + } |
|
| 315 | + } else { |
|
| 316 | + $limit_query = ""; |
|
| 317 | + } |
|
| 257 | 318 | if ($sort != "") |
| 258 | 319 | { |
| 259 | 320 | $search_orderby_array = $this->getOrderBy(); |
@@ -277,7 +338,9 @@ discard block |
||
| 277 | 338 | global $global_marine_query; |
| 278 | 339 | |
| 279 | 340 | date_default_timezone_set('UTC'); |
| 280 | - if ($id == '') return array(); |
|
| 341 | + if ($id == '') { |
|
| 342 | + return array(); |
|
| 343 | + } |
|
| 281 | 344 | $additional_query = "marine_output.fammarine_id = :id"; |
| 282 | 345 | $query_values = array(':id' => $id); |
| 283 | 346 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -721,8 +784,11 @@ discard block |
||
| 721 | 784 | $sth = $this->db->prepare($query); |
| 722 | 785 | $sth->execute($query_values); |
| 723 | 786 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 724 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 725 | - else return $result[0]['duration']; |
|
| 787 | + if (is_int($result[0]['duration'])) { |
|
| 788 | + return gmdate('H:i:s',$result[0]['duration']); |
|
| 789 | + } else { |
|
| 790 | + return $result[0]['duration']; |
|
| 791 | + } |
|
| 726 | 792 | } |
| 727 | 793 | |
| 728 | 794 | /** |
@@ -781,8 +847,11 @@ discard block |
||
| 781 | 847 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 782 | 848 | |
| 783 | 849 | $sth = $this->db->prepare($query); |
| 784 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 785 | - else $sth->execute(); |
|
| 850 | + if (!empty($query_values)) { |
|
| 851 | + $sth->execute($query_values); |
|
| 852 | + } else { |
|
| 853 | + $sth->execute(); |
|
| 854 | + } |
|
| 786 | 855 | |
| 787 | 856 | $source_array = array(); |
| 788 | 857 | $temp_array = array(); |
@@ -837,8 +906,11 @@ discard block |
||
| 837 | 906 | $sth = $this->db->prepare($query); |
| 838 | 907 | $sth->execute(array(':mmsi' => $mmsi)); |
| 839 | 908 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 840 | - if (isset($result[0])) return $result[0]; |
|
| 841 | - else return array(); |
|
| 909 | + if (isset($result[0])) { |
|
| 910 | + return $result[0]; |
|
| 911 | + } else { |
|
| 912 | + return array(); |
|
| 913 | + } |
|
| 842 | 914 | } |
| 843 | 915 | |
| 844 | 916 | /** |
@@ -879,7 +951,9 @@ discard block |
||
| 879 | 951 | date_default_timezone_set($globalTimezone); |
| 880 | 952 | $datetime = new DateTime(); |
| 881 | 953 | $offset = $datetime->format('P'); |
| 882 | - } else $offset = '+00:00'; |
|
| 954 | + } else { |
|
| 955 | + $offset = '+00:00'; |
|
| 956 | + } |
|
| 883 | 957 | |
| 884 | 958 | if ($globalDBdriver == 'mysql') { |
| 885 | 959 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -987,8 +1061,12 @@ discard block |
||
| 987 | 1061 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '') |
| 988 | 1062 | { |
| 989 | 1063 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id'; |
| 990 | - if ($latitude == '') $latitude = NULL; |
|
| 991 | - if ($longitude == '') $longitude = NULL; |
|
| 1064 | + if ($latitude == '') { |
|
| 1065 | + $latitude = NULL; |
|
| 1066 | + } |
|
| 1067 | + if ($longitude == '') { |
|
| 1068 | + $longitude = NULL; |
|
| 1069 | + } |
|
| 992 | 1070 | $groundspeed = round($groundspeed); |
| 993 | 1071 | $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status); |
| 994 | 1072 | try { |
@@ -1134,14 +1212,28 @@ discard block |
||
| 1134 | 1212 | $latitude = 0; |
| 1135 | 1213 | $longitude = 0; |
| 1136 | 1214 | } |
| 1137 | - if ($type_id == '') $type_id = NULL; |
|
| 1138 | - if ($status_id == '') $status_id = NULL; |
|
| 1139 | - if ($distance == '') $distance = NULL; |
|
| 1140 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1141 | - if ($race_time == '') $race_time = NULL; |
|
| 1142 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1215 | + if ($type_id == '') { |
|
| 1216 | + $type_id = NULL; |
|
| 1217 | + } |
|
| 1218 | + if ($status_id == '') { |
|
| 1219 | + $status_id = NULL; |
|
| 1220 | + } |
|
| 1221 | + if ($distance == '') { |
|
| 1222 | + $distance = NULL; |
|
| 1223 | + } |
|
| 1224 | + if ($race_rank == '') { |
|
| 1225 | + $race_rank = NULL; |
|
| 1226 | + } |
|
| 1227 | + if ($race_time == '') { |
|
| 1228 | + $race_time = NULL; |
|
| 1229 | + } |
|
| 1230 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 1231 | + $heading = 0; |
|
| 1232 | + } |
|
| 1143 | 1233 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1144 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1234 | + if ($arrival_date == '') { |
|
| 1235 | + $arrival_date = NULL; |
|
| 1236 | + } |
|
| 1145 | 1237 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
| 1146 | 1238 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1147 | 1239 | |
@@ -1248,7 +1340,9 @@ discard block |
||
| 1248 | 1340 | global $globalDBdriver, $globalArchive; |
| 1249 | 1341 | //$filter_query = $this->getFilter($filters,true,true); |
| 1250 | 1342 | $Connection= new Connection($this->db); |
| 1251 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 1343 | + if (!$Connection->tableExists('countries')) { |
|
| 1344 | + return array(); |
|
| 1345 | + } |
|
| 1252 | 1346 | require_once('class.SpotterLive.php'); |
| 1253 | 1347 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1254 | 1348 | $MarineLive = new MarineLive($this->db); |
@@ -1292,7 +1386,9 @@ discard block |
||
| 1292 | 1386 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 1293 | 1387 | } |
| 1294 | 1388 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 1295 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1389 | + if ($limit) { |
|
| 1390 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1391 | + } |
|
| 1296 | 1392 | |
| 1297 | 1393 | $sth = $this->db->prepare($query); |
| 1298 | 1394 | $sth->execute(); |
@@ -1326,12 +1422,18 @@ discard block |
||
| 1326 | 1422 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 1327 | 1423 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1328 | 1424 | if ($olderthanmonths > 0) { |
| 1329 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1330 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1425 | + if ($globalDBdriver == 'mysql') { |
|
| 1426 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1427 | + } else { |
|
| 1428 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1429 | + } |
|
| 1331 | 1430 | } |
| 1332 | 1431 | if ($sincedate != '') { |
| 1333 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1334 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1432 | + if ($globalDBdriver == 'mysql') { |
|
| 1433 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1434 | + } else { |
|
| 1435 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1436 | + } |
|
| 1335 | 1437 | } |
| 1336 | 1438 | $query_values = array(); |
| 1337 | 1439 | if ($year != '') { |
@@ -1362,7 +1464,9 @@ discard block |
||
| 1362 | 1464 | } |
| 1363 | 1465 | } |
| 1364 | 1466 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 1365 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1467 | + if ($limit) { |
|
| 1468 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1469 | + } |
|
| 1366 | 1470 | |
| 1367 | 1471 | $sth = $this->db->prepare($query); |
| 1368 | 1472 | $sth->execute($query_values); |
@@ -1397,7 +1501,9 @@ discard block |
||
| 1397 | 1501 | date_default_timezone_set($globalTimezone); |
| 1398 | 1502 | $datetime = new DateTime(); |
| 1399 | 1503 | $offset = $datetime->format('P'); |
| 1400 | - } else $offset = '+00:00'; |
|
| 1504 | + } else { |
|
| 1505 | + $offset = '+00:00'; |
|
| 1506 | + } |
|
| 1401 | 1507 | |
| 1402 | 1508 | if ($globalDBdriver == 'mysql') { |
| 1403 | 1509 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1447,7 +1553,9 @@ discard block |
||
| 1447 | 1553 | date_default_timezone_set($globalTimezone); |
| 1448 | 1554 | $datetime = new DateTime(); |
| 1449 | 1555 | $offset = $datetime->format('P'); |
| 1450 | - } else $offset = '+00:00'; |
|
| 1556 | + } else { |
|
| 1557 | + $offset = '+00:00'; |
|
| 1558 | + } |
|
| 1451 | 1559 | $filter_query = $this->getFilter($filters,true,true); |
| 1452 | 1560 | if ($globalDBdriver == 'mysql') { |
| 1453 | 1561 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1493,7 +1601,9 @@ discard block |
||
| 1493 | 1601 | date_default_timezone_set($globalTimezone); |
| 1494 | 1602 | $datetime = new DateTime(); |
| 1495 | 1603 | $offset = $datetime->format('P'); |
| 1496 | - } else $offset = '+00:00'; |
|
| 1604 | + } else { |
|
| 1605 | + $offset = '+00:00'; |
|
| 1606 | + } |
|
| 1497 | 1607 | $filter_query = $this->getFilter($filters,true,true); |
| 1498 | 1608 | if ($globalDBdriver == 'mysql') { |
| 1499 | 1609 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1541,7 +1651,9 @@ discard block |
||
| 1541 | 1651 | date_default_timezone_set($globalTimezone); |
| 1542 | 1652 | $datetime = new DateTime(); |
| 1543 | 1653 | $offset = $datetime->format('P'); |
| 1544 | - } else $offset = '+00:00'; |
|
| 1654 | + } else { |
|
| 1655 | + $offset = '+00:00'; |
|
| 1656 | + } |
|
| 1545 | 1657 | |
| 1546 | 1658 | if ($globalDBdriver == 'mysql') { |
| 1547 | 1659 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1590,7 +1702,9 @@ discard block |
||
| 1590 | 1702 | date_default_timezone_set($globalTimezone); |
| 1591 | 1703 | $datetime = new DateTime(); |
| 1592 | 1704 | $offset = $datetime->format('P'); |
| 1593 | - } else $offset = '+00:00'; |
|
| 1705 | + } else { |
|
| 1706 | + $offset = '+00:00'; |
|
| 1707 | + } |
|
| 1594 | 1708 | $filter_query = $this->getFilter($filters,true,true); |
| 1595 | 1709 | if ($globalDBdriver == 'mysql') { |
| 1596 | 1710 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1639,7 +1753,9 @@ discard block |
||
| 1639 | 1753 | date_default_timezone_set($globalTimezone); |
| 1640 | 1754 | $datetime = new DateTime(); |
| 1641 | 1755 | $offset = $datetime->format('P'); |
| 1642 | - } else $offset = '+00:00'; |
|
| 1756 | + } else { |
|
| 1757 | + $offset = '+00:00'; |
|
| 1758 | + } |
|
| 1643 | 1759 | |
| 1644 | 1760 | $orderby_sql = ''; |
| 1645 | 1761 | if ($orderby == "hour") |
@@ -1708,7 +1824,9 @@ discard block |
||
| 1708 | 1824 | date_default_timezone_set($globalTimezone); |
| 1709 | 1825 | $datetime = new DateTime($date); |
| 1710 | 1826 | $offset = $datetime->format('P'); |
| 1711 | - } else $offset = '+00:00'; |
|
| 1827 | + } else { |
|
| 1828 | + $offset = '+00:00'; |
|
| 1829 | + } |
|
| 1712 | 1830 | |
| 1713 | 1831 | if ($globalDBdriver == 'mysql') { |
| 1714 | 1832 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1756,7 +1874,9 @@ discard block |
||
| 1756 | 1874 | date_default_timezone_set($globalTimezone); |
| 1757 | 1875 | $datetime = new DateTime(); |
| 1758 | 1876 | $offset = $datetime->format('P'); |
| 1759 | - } else $offset = '+00:00'; |
|
| 1877 | + } else { |
|
| 1878 | + $offset = '+00:00'; |
|
| 1879 | + } |
|
| 1760 | 1880 | |
| 1761 | 1881 | if ($globalDBdriver == 'mysql') { |
| 1762 | 1882 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1821,8 +1941,11 @@ discard block |
||
| 1821 | 1941 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1822 | 1942 | } |
| 1823 | 1943 | } |
| 1824 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1825 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1944 | + if (empty($query_values)) { |
|
| 1945 | + $queryi .= $this->getFilter($filters); |
|
| 1946 | + } else { |
|
| 1947 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1948 | + } |
|
| 1826 | 1949 | |
| 1827 | 1950 | $sth = $this->db->prepare($queryi); |
| 1828 | 1951 | $sth->execute($query_values); |
@@ -1859,8 +1982,11 @@ discard block |
||
| 1859 | 1982 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1860 | 1983 | } |
| 1861 | 1984 | } |
| 1862 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1863 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1985 | + if (empty($query_values)) { |
|
| 1986 | + $queryi .= $this->getFilter($filters); |
|
| 1987 | + } else { |
|
| 1988 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1989 | + } |
|
| 1864 | 1990 | |
| 1865 | 1991 | $sth = $this->db->prepare($queryi); |
| 1866 | 1992 | $sth->execute($query_values); |
@@ -1882,7 +2008,9 @@ discard block |
||
| 1882 | 2008 | date_default_timezone_set($globalTimezone); |
| 1883 | 2009 | $datetime = new DateTime(); |
| 1884 | 2010 | $offset = $datetime->format('P'); |
| 1885 | - } else $offset = '+00:00'; |
|
| 2011 | + } else { |
|
| 2012 | + $offset = '+00:00'; |
|
| 2013 | + } |
|
| 1886 | 2014 | |
| 1887 | 2015 | if ($globalDBdriver == 'mysql') { |
| 1888 | 2016 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1986,7 +2114,9 @@ discard block |
||
| 1986 | 2114 | */ |
| 1987 | 2115 | public function parseDirection($direction = 0) |
| 1988 | 2116 | { |
| 1989 | - if ($direction == '') $direction = 0; |
|
| 2117 | + if ($direction == '') { |
|
| 2118 | + $direction = 0; |
|
| 2119 | + } |
|
| 1990 | 2120 | $direction_array = array(); |
| 1991 | 2121 | $temp_array = array(); |
| 1992 | 2122 | |
@@ -2075,7 +2205,9 @@ discard block |
||
| 2075 | 2205 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 2076 | 2206 | |
| 2077 | 2207 | $Connection = new Connection($this->db); |
| 2078 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2208 | + if (!$Connection->tableExists('countries')) { |
|
| 2209 | + return ''; |
|
| 2210 | + } |
|
| 2079 | 2211 | |
| 2080 | 2212 | try { |
| 2081 | 2213 | /* |
@@ -2095,9 +2227,13 @@ discard block |
||
| 2095 | 2227 | $sth->closeCursor(); |
| 2096 | 2228 | if (count($row) > 0) { |
| 2097 | 2229 | return $row; |
| 2098 | - } else return ''; |
|
| 2230 | + } else { |
|
| 2231 | + return ''; |
|
| 2232 | + } |
|
| 2099 | 2233 | } catch (PDOException $e) { |
| 2100 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2234 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2235 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2236 | + } |
|
| 2101 | 2237 | return ''; |
| 2102 | 2238 | } |
| 2103 | 2239 | |
@@ -2115,7 +2251,9 @@ discard block |
||
| 2115 | 2251 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 2116 | 2252 | |
| 2117 | 2253 | $Connection = new Connection($this->db); |
| 2118 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2254 | + if (!$Connection->tableExists('countries')) { |
|
| 2255 | + return ''; |
|
| 2256 | + } |
|
| 2119 | 2257 | |
| 2120 | 2258 | try { |
| 2121 | 2259 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2127,9 +2265,13 @@ discard block |
||
| 2127 | 2265 | $sth->closeCursor(); |
| 2128 | 2266 | if (count($row) > 0) { |
| 2129 | 2267 | return $row; |
| 2130 | - } else return ''; |
|
| 2268 | + } else { |
|
| 2269 | + return ''; |
|
| 2270 | + } |
|
| 2131 | 2271 | } catch (PDOException $e) { |
| 2132 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2272 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2273 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2274 | + } |
|
| 2133 | 2275 | return ''; |
| 2134 | 2276 | } |
| 2135 | 2277 | |
@@ -2147,7 +2289,9 @@ discard block |
||
| 2147 | 2289 | { |
| 2148 | 2290 | global $globalBitlyAccessToken; |
| 2149 | 2291 | |
| 2150 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 2292 | + if ($globalBitlyAccessToken == '') { |
|
| 2293 | + return $url; |
|
| 2294 | + } |
|
| 2151 | 2295 | |
| 2152 | 2296 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 2153 | 2297 | |
@@ -2223,7 +2367,9 @@ discard block |
||
| 2223 | 2367 | } |
| 2224 | 2368 | } |
| 2225 | 2369 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
| 2226 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2370 | + if ($limit) { |
|
| 2371 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2372 | + } |
|
| 2227 | 2373 | $sth = $this->db->prepare($query); |
| 2228 | 2374 | $sth->execute($query_values); |
| 2229 | 2375 | $marine_array = array(); |
@@ -2261,9 +2407,15 @@ discard block |
||
| 2261 | 2407 | foreach ($q_array as $q_item){ |
| 2262 | 2408 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 2263 | 2409 | $additional_query .= " AND ("; |
| 2264 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2265 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2266 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2410 | + if (is_int($q_item)) { |
|
| 2411 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2412 | + } |
|
| 2413 | + if (is_int($q_item)) { |
|
| 2414 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2415 | + } |
|
| 2416 | + if (is_int($q_item)) { |
|
| 2417 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2418 | + } |
|
| 2267 | 2419 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 2268 | 2420 | $additional_query .= ")"; |
| 2269 | 2421 | } |
@@ -2311,7 +2463,9 @@ discard block |
||
| 2311 | 2463 | date_default_timezone_set($globalTimezone); |
| 2312 | 2464 | $datetime = new DateTime(); |
| 2313 | 2465 | $offset = $datetime->format('P'); |
| 2314 | - } else $offset = '+00:00'; |
|
| 2466 | + } else { |
|
| 2467 | + $offset = '+00:00'; |
|
| 2468 | + } |
|
| 2315 | 2469 | if ($date_array[1] != "") |
| 2316 | 2470 | { |
| 2317 | 2471 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2338,8 +2492,12 @@ discard block |
||
| 2338 | 2492 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2339 | 2493 | { |
| 2340 | 2494 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 2341 | - } else $limit_query = ""; |
|
| 2342 | - } else $limit_query = ""; |
|
| 2495 | + } else { |
|
| 2496 | + $limit_query = ""; |
|
| 2497 | + } |
|
| 2498 | + } else { |
|
| 2499 | + $limit_query = ""; |
|
| 2500 | + } |
|
| 2343 | 2501 | if ($sort != "") |
| 2344 | 2502 | { |
| 2345 | 2503 | $search_orderby_array = $this->getOrderBy(); |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | public function checkAll() { |
| 55 | 55 | global $globalDebug, $globalNoDB; |
| 56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 57 | + if ($globalDebug) { |
|
| 58 | + echo "Update last seen tracked data...\n"; |
|
| 59 | + } |
|
| 58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
| 59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
| 60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -77,13 +79,17 @@ discard block |
||
| 77 | 79 | public function del() { |
| 78 | 80 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 79 | 81 | // Delete old infos |
| 80 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 84 | + } |
|
| 81 | 85 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | 86 | if (isset($flight['lastupdate'])) { |
| 83 | 87 | if ($flight['lastupdate'] < (time()-3000)) { |
| 84 | 88 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 85 | 89 | if (isset($this->all_tracked[$key]['id'])) { |
| 86 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 90 | + if ($globalDebug) { |
|
| 91 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 92 | + } |
|
| 87 | 93 | /* |
| 88 | 94 | $MarineLive = new MarineLive(); |
| 89 | 95 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -102,7 +108,9 @@ discard block |
||
| 102 | 108 | } else { |
| 103 | 109 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 104 | 110 | } |
| 105 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 111 | + if ($globalDebug && $result != 'success') { |
|
| 112 | + echo '!!! ERROR : '.$result."\n"; |
|
| 113 | + } |
|
| 106 | 114 | } |
| 107 | 115 | // Put in archive |
| 108 | 116 | // $Marine->db = null; |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | |
| 117 | 125 | public function add($line) { |
| 118 | 126 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
| 119 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 127 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 128 | + $globalCoordMinChange = '0.02'; |
|
| 129 | + } |
|
| 120 | 130 | date_default_timezone_set('UTC'); |
| 121 | 131 | $dataFound = false; |
| 122 | 132 | $send = false; |
@@ -130,20 +140,30 @@ discard block |
||
| 130 | 140 | // Increment message number |
| 131 | 141 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 132 | 142 | $current_date = date('Y-m-d'); |
| 133 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | - else $source = ''; |
|
| 135 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 143 | + if (isset($line['source_name'])) { |
|
| 144 | + $source = $line['source_name']; |
|
| 145 | + } else { |
|
| 146 | + $source = ''; |
|
| 147 | + } |
|
| 148 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 149 | + $source = $line['format_source']; |
|
| 150 | + } |
|
| 136 | 151 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 137 | 152 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 138 | 153 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 139 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 154 | + } else { |
|
| 155 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 156 | + } |
|
| 140 | 157 | } |
| 141 | 158 | |
| 142 | 159 | |
| 143 | 160 | $Common = new Common(); |
| 144 | 161 | $AIS = new AIS(); |
| 145 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | - else $id = trim($line['id']); |
|
| 162 | + if (!isset($line['id'])) { |
|
| 163 | + $id = trim($line['mmsi']); |
|
| 164 | + } else { |
|
| 165 | + $id = trim($line['id']); |
|
| 166 | + } |
|
| 147 | 167 | |
| 148 | 168 | if (!isset($this->all_tracked[$id])) { |
| 149 | 169 | $this->all_tracked[$id] = array(); |
@@ -151,10 +171,16 @@ discard block |
||
| 151 | 171 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => date('Y-m-d H:i:s'))); |
| 152 | 172 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 153 | 173 | if (!isset($line['id'])) { |
| 154 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 174 | + if (!isset($globalDaemon)) { |
|
| 175 | + $globalDaemon = TRUE; |
|
| 176 | + } |
|
| 155 | 177 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 178 | + } else { |
|
| 179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 180 | + } |
|
| 181 | + if ($globalAllTracked !== FALSE) { |
|
| 182 | + $dataFound = true; |
|
| 183 | + } |
|
| 158 | 184 | } |
| 159 | 185 | |
| 160 | 186 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -211,7 +237,9 @@ discard block |
||
| 211 | 237 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | 238 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 213 | 239 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 214 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 240 | + if ($globalDebug) { |
|
| 241 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 242 | + } |
|
| 215 | 243 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | 244 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 217 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -224,7 +252,9 @@ discard block |
||
| 224 | 252 | } |
| 225 | 253 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
| 226 | 254 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 227 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 255 | + if ($globalDebug) { |
|
| 256 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 257 | + } |
|
| 228 | 258 | if (!isset($line['id'])) { |
| 229 | 259 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
| 230 | 260 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -233,7 +263,9 @@ discard block |
||
| 233 | 263 | } |
| 234 | 264 | } |
| 235 | 265 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 266 | + if (strtotime($line['arrival_date']) > time()) { |
|
| 267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 268 | + } |
|
| 237 | 269 | } |
| 238 | 270 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -278,34 +310,49 @@ discard block |
||
| 278 | 310 | $Marine = new Marine($this->db); |
| 279 | 311 | $fromsource = NULL; |
| 280 | 312 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 281 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 313 | + if ($globalDebug && $result != 'success') { |
|
| 314 | + echo '!!! ERROR : '.$result."\n"; |
|
| 315 | + } |
|
| 282 | 316 | $Marine->db = null; |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 317 | + if ($globalDebugTimeElapsed) { |
|
| 318 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 319 | + } |
|
| 284 | 320 | } |
| 285 | 321 | } |
| 286 | 322 | } |
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 323 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 325 | + } |
|
| 288 | 326 | } |
| 289 | 327 | |
| 290 | 328 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 291 | 329 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 292 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 293 | 331 | } else { |
| 294 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 295 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 332 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 333 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 334 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 335 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 336 | + } |
|
| 296 | 337 | return ''; |
| 297 | 338 | } |
| 298 | 339 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 299 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 340 | + if ($globalDebug) { |
|
| 341 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 342 | + } |
|
| 300 | 343 | return ''; |
| 301 | 344 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 302 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 347 | + } |
|
| 303 | 348 | return ''; |
| 304 | 349 | } elseif (!isset($line['datetime'])) { |
| 305 | 350 | date_default_timezone_set('UTC'); |
| 306 | 351 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 307 | 352 | } else { |
| 308 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 353 | + if ($globalDebug) { |
|
| 354 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 355 | + } |
|
| 309 | 356 | return ''; |
| 310 | 357 | } |
| 311 | 358 | |
@@ -318,14 +365,21 @@ discard block |
||
| 318 | 365 | if ($distance > 1000 && $distance < 10000) { |
| 319 | 366 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 367 | $speed = $speed*3.6; |
| 321 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 322 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 368 | + if ($speed < 1000) { |
|
| 369 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 370 | + } |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 373 | + } |
|
| 323 | 374 | } |
| 324 | 375 | } |
| 325 | 376 | |
| 326 | 377 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | - else unset($timediff); |
|
| 378 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 379 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 380 | + } else { |
|
| 381 | + unset($timediff); |
|
| 382 | + } |
|
| 329 | 383 | if ($this->tmd > 5 || |
| 330 | 384 | !isset($timediff) || |
| 331 | 385 | $timediff > $globalLiveInterval || |
@@ -342,22 +396,32 @@ discard block |
||
| 342 | 396 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 397 | $this->all_tracked[$id]['putinarchive'] = true; |
| 344 | 398 | |
| 345 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 399 | + if ($globalDebug) { |
|
| 400 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 401 | + } |
|
| 346 | 402 | $timeelapsed = microtime(true); |
| 347 | 403 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | 404 | $Marine = new Marine($this->db); |
| 349 | 405 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 350 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 406 | + if (!empty($all_country)) { |
|
| 407 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 408 | + } |
|
| 351 | 409 | $Marine->db = null; |
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 410 | + if ($globalDebugTimeElapsed) { |
|
| 411 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 412 | + } |
|
| 353 | 413 | } |
| 354 | 414 | $this->tmd = 0; |
| 355 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 415 | + if ($globalDebug) { |
|
| 416 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 417 | + } |
|
| 356 | 418 | } |
| 357 | 419 | } |
| 358 | 420 | |
| 359 | 421 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 422 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 423 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 424 | + } |
|
| 361 | 425 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 362 | 426 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 363 | 427 | $dataFound = true; |
@@ -366,8 +430,12 @@ discard block |
||
| 366 | 430 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 367 | 431 | } |
| 368 | 432 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 370 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 433 | + if ($line['longitude'] > 180) { |
|
| 434 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 435 | + } |
|
| 436 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 437 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 438 | + } |
|
| 371 | 439 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 372 | 440 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 373 | 441 | $dataFound = true; |
@@ -385,7 +453,9 @@ discard block |
||
| 385 | 453 | } |
| 386 | 454 | } |
| 387 | 455 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 456 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 457 | + $dataFound = true; |
|
| 458 | + } |
|
| 389 | 459 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 390 | 460 | } |
| 391 | 461 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -399,15 +469,21 @@ discard block |
||
| 399 | 469 | } |
| 400 | 470 | |
| 401 | 471 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 472 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 473 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 474 | + } |
|
| 403 | 475 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 404 | 476 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 405 | 477 | //$dataFound = true; |
| 406 | 478 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 407 | 479 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 408 | 480 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 481 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 482 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 483 | + } |
|
| 484 | + if ($globalDebug) { |
|
| 485 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 486 | + } |
|
| 411 | 487 | } |
| 412 | 488 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 413 | 489 | |
@@ -419,28 +495,45 @@ discard block |
||
| 419 | 495 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 420 | 496 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 421 | 497 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 498 | + if ($globalDebug) { |
|
| 499 | + echo "Check if vessel is already in DB..."; |
|
| 500 | + } |
|
| 423 | 501 | $timeelapsed = microtime(true); |
| 424 | 502 | $MarineLive = new MarineLive($this->db); |
| 425 | 503 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
| 426 | 504 | $Marine = new Marine($this->db); |
| 427 | 505 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 506 | + if ($globalDebugTimeElapsed) { |
|
| 507 | + echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 508 | + } |
|
| 429 | 509 | $Marine->db=null; |
| 430 | 510 | } elseif (isset($line['id'])) { |
| 431 | 511 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 512 | + if ($globalDebugTimeElapsed) { |
|
| 513 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 514 | + } |
|
| 433 | 515 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 434 | 516 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 517 | + if ($globalDebugTimeElapsed) { |
|
| 518 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 519 | + } |
|
| 436 | 520 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 437 | 521 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 439 | - } else $recent_ident = ''; |
|
| 522 | + if ($globalDebugTimeElapsed) { |
|
| 523 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 524 | + } |
|
| 525 | + } else { |
|
| 526 | + $recent_ident = ''; |
|
| 527 | + } |
|
| 440 | 528 | $MarineLive->db=null; |
| 441 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 443 | - } else $recent_ident = ''; |
|
| 529 | + if ($globalDebug && $recent_ident == '') { |
|
| 530 | + echo " Not in DB.\n"; |
|
| 531 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 532 | + echo " Already in DB.\n"; |
|
| 533 | + } |
|
| 534 | + } else { |
|
| 535 | + $recent_ident = ''; |
|
| 536 | + } |
|
| 444 | 537 | } else { |
| 445 | 538 | $recent_ident = ''; |
| 446 | 539 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -449,12 +542,17 @@ discard block |
||
| 449 | 542 | if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
| 450 | 543 | { |
| 451 | 544 | if ($globalDebug) { |
| 452 | - if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 453 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 545 | + if ($this->all_tracked[$id]['mmsi'] == '') { |
|
| 546 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 547 | + } else { |
|
| 548 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 549 | + } |
|
| 454 | 550 | } |
| 455 | 551 | //adds the spotter data for the archive |
| 456 | 552 | $highlight = ''; |
| 457 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 553 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 554 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 555 | + } |
|
| 458 | 556 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 459 | 557 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | 558 | $timeelapsed = microtime(true); |
@@ -465,20 +563,30 @@ discard block |
||
| 465 | 563 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 466 | 564 | } |
| 467 | 565 | $Marine->db = null; |
| 468 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 566 | + if ($globalDebug && isset($result)) { |
|
| 567 | + echo $result."\n"; |
|
| 568 | + } |
|
| 569 | + if ($globalDebugTimeElapsed) { |
|
| 570 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 571 | + } |
|
| 470 | 572 | } |
| 471 | 573 | } |
| 472 | 574 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 473 | 575 | // Add source stat in DB |
| 474 | 576 | $Stats = new Stats($this->db); |
| 475 | 577 | if (!empty($this->stats)) { |
| 476 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 578 | + if ($globalDebug) { |
|
| 579 | + echo 'Add source stats : '; |
|
| 580 | + } |
|
| 477 | 581 | foreach($this->stats as $date => $data) { |
| 478 | 582 | foreach($data as $source => $sourced) { |
| 479 | 583 | //print_r($sourced); |
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 584 | + if (isset($sourced['polar'])) { |
|
| 585 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 586 | + } |
|
| 587 | + if (isset($sourced['hist'])) { |
|
| 588 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 589 | + } |
|
| 482 | 590 | if (isset($sourced['msg'])) { |
| 483 | 591 | if (time() - $sourced['msg']['date'] > 10) { |
| 484 | 592 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -491,7 +599,9 @@ discard block |
||
| 491 | 599 | unset($this->stats[$date]); |
| 492 | 600 | } |
| 493 | 601 | } |
| 494 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 602 | + if ($globalDebug) { |
|
| 603 | + echo 'Done'."\n"; |
|
| 604 | + } |
|
| 495 | 605 | } |
| 496 | 606 | $Stats->db = null; |
| 497 | 607 | } |
@@ -501,13 +611,17 @@ discard block |
||
| 501 | 611 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 502 | 612 | //print_r($this->all_tracked[$id]); |
| 503 | 613 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 504 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 614 | + if ($globalDebug) { |
|
| 615 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 616 | + } |
|
| 505 | 617 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 506 | 618 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 507 | 619 | $MarineLive = new MarineLive($this->db); |
| 508 | 620 | $MarineLive->deleteLiveMarineData(); |
| 509 | 621 | $MarineLive->db=null; |
| 510 | - if ($globalDebug) echo " Done\n"; |
|
| 622 | + if ($globalDebug) { |
|
| 623 | + echo " Done\n"; |
|
| 624 | + } |
|
| 511 | 625 | } |
| 512 | 626 | $this->last_delete = time(); |
| 513 | 627 | } |
@@ -539,18 +653,26 @@ discard block |
||
| 539 | 653 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 540 | 654 | } |
| 541 | 655 | $ignoreImport = false; |
| 542 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 656 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') { |
|
| 657 | + $ignoreImport = true; |
|
| 658 | + } |
|
| 543 | 659 | if (!$ignoreImport) { |
| 544 | 660 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 545 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 661 | + if ($globalDebug) { |
|
| 662 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 663 | + } |
|
| 546 | 664 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | 665 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 548 | 666 | $timeelapsed = microtime(true); |
| 549 | 667 | $MarineLive = new MarineLive($this->db); |
| 550 | 668 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 551 | 669 | $MarineLive->db = null; |
| 552 | - if ($globalDebug) echo $result."\n"; |
|
| 553 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 670 | + if ($globalDebug) { |
|
| 671 | + echo $result."\n"; |
|
| 672 | + } |
|
| 673 | + if ($globalDebugTimeElapsed) { |
|
| 674 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 675 | + } |
|
| 554 | 676 | } |
| 555 | 677 | } |
| 556 | 678 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -562,7 +684,9 @@ discard block |
||
| 562 | 684 | |
| 563 | 685 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 564 | 686 | $source = $this->all_tracked[$id]['source_name']; |
| 565 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 687 | + if ($source == '') { |
|
| 688 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 689 | + } |
|
| 566 | 690 | if (!isset($this->source_location[$source])) { |
| 567 | 691 | $Location = new Source($this->db); |
| 568 | 692 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -583,7 +707,9 @@ discard block |
||
| 583 | 707 | $stats_heading = round($stats_heading/22.5); |
| 584 | 708 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 585 | 709 | $current_date = date('Y-m-d'); |
| 586 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 710 | + if ($stats_heading == 16) { |
|
| 711 | + $stats_heading = 0; |
|
| 712 | + } |
|
| 587 | 713 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | 714 | for ($i=0;$i<=15;$i++) { |
| 589 | 715 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -601,7 +727,9 @@ discard block |
||
| 601 | 727 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | 728 | end($this->stats[$current_date][$source]['hist']); |
| 603 | 729 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 604 | - } else $mini = 0; |
|
| 730 | + } else { |
|
| 731 | + $mini = 0; |
|
| 732 | + } |
|
| 605 | 733 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 606 | 734 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 607 | 735 | } |
@@ -613,19 +741,27 @@ discard block |
||
| 613 | 741 | |
| 614 | 742 | |
| 615 | 743 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 616 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 617 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 744 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 745 | + $send = true; |
|
| 746 | + } |
|
| 747 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 748 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 749 | + } |
|
| 618 | 750 | //$this->del(); |
| 619 | 751 | |
| 620 | 752 | |
| 621 | 753 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 622 | 754 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 623 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 755 | + if ($globalDebug) { |
|
| 756 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 757 | + } |
|
| 624 | 758 | $MarineLive = new MarineLive($this->db); |
| 625 | 759 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 626 | 760 | $MarineLive->db = null; |
| 627 | 761 | //MarineLive->deleteLiveMarineData(); |
| 628 | - if ($globalDebug) echo " Done\n"; |
|
| 762 | + if ($globalDebug) { |
|
| 763 | + echo " Done\n"; |
|
| 764 | + } |
|
| 629 | 765 | } |
| 630 | 766 | $this->last_delete_hourly = time(); |
| 631 | 767 | } |
@@ -634,7 +770,9 @@ discard block |
||
| 634 | 770 | //$ignoreImport = false; |
| 635 | 771 | } |
| 636 | 772 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 637 | - if ($send) return $this->all_tracked[$id]; |
|
| 773 | + if ($send) { |
|
| 774 | + return $this->all_tracked[$id]; |
|
| 775 | + } |
|
| 638 | 776 | } |
| 639 | 777 | } |
| 640 | 778 | } |
@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
| 59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 64 | if (isset($options['s'])) { |
| 61 | 65 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 64 | -} elseif (isset($options['source'])) { |
|
| 66 | + if (isset($options['format'])) { |
|
| 67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 68 | + } else { |
|
| 69 | + $globalSources[] = array('host' => $options['s']); |
|
| 70 | + } |
|
| 71 | + } elseif (isset($options['source'])) { |
|
| 65 | 72 | $globalSources = array(); |
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 68 | -} |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['source']); |
|
| 77 | + } |
|
| 78 | + } |
|
| 69 | 79 | if (isset($options['aprsserverhost'])) { |
| 70 | 80 | $globalServerAPRS = TRUE; |
| 71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
| 72 | 82 | } |
| 73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 83 | +if (isset($options['aprsserverport'])) { |
|
| 84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 85 | +} |
|
| 86 | +if (isset($options['aprsserverssid'])) { |
|
| 87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 88 | +} |
|
| 89 | +if (isset($options['aprsserverpass'])) { |
|
| 90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 91 | +} |
|
| 92 | +if (isset($options['noaprsserver'])) { |
|
| 93 | + $globalServerAPRS = FALSE; |
|
| 94 | +} |
|
| 77 | 95 | if (isset($options['enable-aircraft'])) { |
| 78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo 'Enable Aircraft mode'."\n"; |
|
| 98 | + } |
|
| 79 | 99 | $globalAircraft = TRUE; |
| 80 | 100 | } |
| 81 | 101 | if (isset($options['disable-aircraft'])) { |
| 82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo 'Disable Aircraft mode'."\n"; |
|
| 104 | + } |
|
| 83 | 105 | $globalAircraft = FALSE; |
| 84 | 106 | } |
| 85 | 107 | if (isset($options['enable-tracker'])) { |
| 86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 108 | + if ($globalDebug) { |
|
| 109 | + echo 'Enable Tracker mode'."\n"; |
|
| 110 | + } |
|
| 87 | 111 | $globalTracker = TRUE; |
| 88 | 112 | } |
| 89 | 113 | if (isset($options['disable-tracker'])) { |
| 90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 114 | + if ($globalDebug) { |
|
| 115 | + echo 'Disable Tracker mode'."\n"; |
|
| 116 | + } |
|
| 91 | 117 | $globalTracker = FALSE; |
| 92 | 118 | } |
| 93 | 119 | if (isset($options['enable-marine'])) { |
| 94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 120 | + if ($globalDebug) { |
|
| 121 | + echo 'Enable Marine mode'."\n"; |
|
| 122 | + } |
|
| 95 | 123 | $globalMarine = TRUE; |
| 96 | 124 | } |
| 97 | 125 | if (isset($options['disable-marine'])) { |
| 98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 126 | + if ($globalDebug) { |
|
| 127 | + echo 'Disable Marine mode'."\n"; |
|
| 128 | + } |
|
| 99 | 129 | $globalMarine = FALSE; |
| 100 | 130 | } |
| 101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 104 | -else $id_source = 1; |
|
| 131 | +if (isset($options['nodaemon'])) { |
|
| 132 | + $globalDaemon = FALSE; |
|
| 133 | +} |
|
| 134 | +if (isset($options['server'])) { |
|
| 135 | + $globalServer = TRUE; |
|
| 136 | +} |
|
| 137 | +if (isset($options['idsource'])) { |
|
| 138 | + $id_source = $options['idsource']; |
|
| 139 | +} else { |
|
| 140 | + $id_source = 1; |
|
| 141 | +} |
|
| 105 | 142 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo "Using Server Mode\n"; |
|
| 145 | + } |
|
| 107 | 146 | $SI=new SpotterServer(); |
| 108 | 147 | /* |
| 109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 149 | $SI = new adsb2aprs(); |
| 111 | 150 | $SI->connect(); |
| 112 | 151 | */ |
| 113 | -} else $SI=new SpotterImport($Connection->db); |
|
| 152 | +} else { |
|
| 153 | + $SI=new SpotterImport($Connection->db); |
|
| 154 | +} |
|
| 114 | 155 | |
| 115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 156 | +if (isset($globalTracker) && $globalTracker) { |
|
| 157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 158 | +} |
|
| 116 | 159 | if (isset($globalMarine) && $globalMarine) { |
| 117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 119 | 162 | } |
| 120 | 163 | |
| 121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 164 | +if (isset($globalTracker) && $globalTracker) { |
|
| 165 | + $TI = new TrackerImport($Connection->db); |
|
| 166 | +} |
|
| 122 | 167 | if (isset($globalMarine) && $globalMarine) { |
| 123 | 168 | $AIS = new AIS(); |
| 124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
| 143 | 188 | } |
| 144 | 189 | |
| 145 | 190 | // let's try and connect |
| 146 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 191 | +if ($globalDebug) { |
|
| 192 | + echo "Connecting...\n"; |
|
| 193 | +} |
|
| 147 | 194 | $use_aprs = false; |
| 148 | 195 | $aprs_full = false; |
| 149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
| 152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 154 | 201 | $reset++; |
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 202 | + if ($globalDebug) { |
|
| 203 | + echo 'Connect to all...'."\n"; |
|
| 204 | + } |
|
| 156 | 205 | foreach ($hosts as $id => $value) { |
| 157 | 206 | $host = $value['host']; |
| 158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,32 +211,44 @@ discard block |
||
| 162 | 211 | //$formats[$id] = 'deltadbtxt'; |
| 163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 164 | 213 | //$last_exec['deltadbtxt'] = 0; |
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 216 | + } |
|
| 166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 167 | 218 | //$formats[$id] = 'vatsimtxt'; |
| 168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 169 | 220 | //$last_exec['vatsimtxt'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 223 | + } |
|
| 171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
| 173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 230 | + } |
|
| 176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 177 | 232 | //$formats[$id] = 'aircraftjson'; |
| 178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 237 | + } |
|
| 181 | 238 | } else if (preg_match('/aircraft$/i',$host)) { |
| 182 | 239 | //$formats[$id] = 'planefinderclient'; |
| 183 | 240 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 244 | + } |
|
| 186 | 245 | } else if (preg_match('/opensky/i',$host)) { |
| 187 | 246 | //$formats[$id] = 'aircraftlistjson'; |
| 188 | 247 | $globalSources[$id]['format'] = 'opensky'; |
| 189 | 248 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 251 | + } |
|
| 191 | 252 | /* |
| 192 | 253 | // Disabled for now, site change source format |
| 193 | 254 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -204,7 +265,9 @@ discard block |
||
| 204 | 265 | //$formats[$id] = 'planeupdatefaa'; |
| 205 | 266 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 206 | 267 | //$last_exec['planeupdatefaa'] = 0; |
| 207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 268 | + if ($globalDebug) { |
|
| 269 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 270 | + } |
|
| 208 | 271 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 209 | 272 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 210 | 273 | exit(0); |
@@ -213,37 +276,53 @@ discard block |
||
| 213 | 276 | //$formats[$id] = 'phpvmacars'; |
| 214 | 277 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 215 | 278 | //$last_exec['phpvmacars'] = 0; |
| 216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 279 | + if ($globalDebug) { |
|
| 280 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 281 | + } |
|
| 217 | 282 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 218 | 283 | //$formats[$id] = 'phpvmacars'; |
| 219 | 284 | $globalSources[$id]['format'] = 'vaos'; |
| 220 | 285 | //$last_exec['phpvmacars'] = 0; |
| 221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 288 | + } |
|
| 222 | 289 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 223 | 290 | //$formats[$id] = 'phpvmacars'; |
| 224 | 291 | $globalSources[$id]['format'] = 'vam'; |
| 225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 292 | + if ($globalDebug) { |
|
| 293 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 294 | + } |
|
| 226 | 295 | } else if (preg_match('/whazzup/i',$host)) { |
| 227 | 296 | //$formats[$id] = 'whazzup'; |
| 228 | 297 | $globalSources[$id]['format'] = 'whazzup'; |
| 229 | 298 | //$last_exec['whazzup'] = 0; |
| 230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 299 | + if ($globalDebug) { |
|
| 300 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 301 | + } |
|
| 231 | 302 | } else if (preg_match('/blitzortung/i',$host)) { |
| 232 | 303 | $globalSources[$id]['format'] = 'blitzortung'; |
| 233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 304 | + if ($globalDebug) { |
|
| 305 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 306 | + } |
|
| 234 | 307 | } else if (preg_match('/airwhere/i',$host)) { |
| 235 | 308 | $globalSources[$id]['format'] = 'airwhere'; |
| 236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 309 | + if ($globalDebug) { |
|
| 310 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 311 | + } |
|
| 237 | 312 | } else if (preg_match('/recentpireps/i',$host)) { |
| 238 | 313 | //$formats[$id] = 'pirepsjson'; |
| 239 | 314 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 240 | 315 | //$last_exec['pirepsjson'] = 0; |
| 241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 316 | + if ($globalDebug) { |
|
| 317 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 318 | + } |
|
| 242 | 319 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 243 | 320 | //$formats[$id] = 'fr24json'; |
| 244 | 321 | $globalSources[$id]['format'] = 'fr24json'; |
| 245 | 322 | //$last_exec['fr24json'] = 0; |
| 246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 325 | + } |
|
| 247 | 326 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 248 | 327 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 249 | 328 | exit(0); |
@@ -252,7 +331,9 @@ discard block |
||
| 252 | 331 | //$formats[$id] = 'fr24json'; |
| 253 | 332 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 254 | 333 | //$last_exec['fr24json'] = 0; |
| 255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 336 | + } |
|
| 256 | 337 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 257 | 338 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 258 | 339 | exit(0); |
@@ -261,17 +342,26 @@ discard block |
||
| 261 | 342 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 262 | 343 | //$formats[$id] = 'tsv'; |
| 263 | 344 | $globalSources[$id]['format'] = 'tsv'; |
| 264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 347 | + } |
|
| 265 | 348 | } |
| 266 | 349 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
| 267 | 350 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 268 | 351 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 269 | 352 | if ($idf !== false) { |
| 270 | 353 | $httpfeeds[$id] = $idf; |
| 271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 354 | + if ($globalDebug) { |
|
| 355 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 356 | + } |
|
| 357 | + } elseif ($globalDebug) { |
|
| 358 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 359 | + } |
|
| 360 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 361 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 362 | + } elseif ($globalDebug) { |
|
| 363 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 275 | 365 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 276 | 366 | $hostport = explode(':',$host); |
| 277 | 367 | if (isset($hostport[1])) { |
@@ -311,19 +401,27 @@ discard block |
||
| 311 | 401 | //$formats[$id] = 'beast'; |
| 312 | 402 | $globalSources[$id]['format'] = 'beast'; |
| 313 | 403 | //} else $formats[$id] = 'sbs'; |
| 314 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 404 | + } else { |
|
| 405 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 406 | + } |
|
| 315 | 407 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 316 | 408 | } |
| 317 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 409 | + if ($globalDebug) { |
|
| 410 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 411 | + } |
|
| 318 | 412 | } else { |
| 319 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 415 | + } |
|
| 320 | 416 | sleep(10); |
| 321 | 417 | connect_all($hosts); |
| 322 | 418 | } |
| 323 | 419 | } |
| 324 | 420 | } |
| 325 | 421 | } |
| 326 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 422 | +if (!isset($globalMinFetch)) { |
|
| 423 | + $globalMinFetch = 15; |
|
| 424 | +} |
|
| 327 | 425 | |
| 328 | 426 | // Initialize all |
| 329 | 427 | $status = array(); |
@@ -332,13 +430,19 @@ discard block |
||
| 332 | 430 | $formats = array(); |
| 333 | 431 | $last_exec = array(); |
| 334 | 432 | $time = time(); |
| 335 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 336 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 337 | -else $timeout = 20; |
|
| 433 | +if (isset($globalSourcesTimeout)) { |
|
| 434 | + $timeout = $globalSourcesTimeOut; |
|
| 435 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 436 | + $timeout = $globalSBS1TimeOut; |
|
| 437 | +} else { |
|
| 438 | + $timeout = 20; |
|
| 439 | +} |
|
| 338 | 440 | $errno = ''; |
| 339 | 441 | $errstr=''; |
| 340 | 442 | |
| 341 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 443 | +if (!isset($globalDaemon)) { |
|
| 444 | + $globalDaemon = TRUE; |
|
| 445 | +} |
|
| 342 | 446 | /* Initiate connections to all the hosts simultaneously */ |
| 343 | 447 | //connect_all($hosts); |
| 344 | 448 | //connect_all($globalSources); |
@@ -367,7 +471,9 @@ discard block |
||
| 367 | 471 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 368 | 472 | $aprs_connect = 0; |
| 369 | 473 | $use_aprs = true; |
| 370 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 474 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 475 | + $aprs_full = true; |
|
| 476 | + } |
|
| 371 | 477 | break; |
| 372 | 478 | } |
| 373 | 479 | } |
@@ -378,25 +484,46 @@ discard block |
||
| 378 | 484 | $aprs_connect = 0; |
| 379 | 485 | $aprs_keep = 120; |
| 380 | 486 | $aprs_last_tx = time(); |
| 381 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 382 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 383 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 384 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 385 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 386 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 387 | - if ($aprs_full) $aprs_filter = ''; |
|
| 388 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 389 | - else $aprs_pass = '-1'; |
|
| 487 | + if (isset($globalAPRSversion)) { |
|
| 488 | + $aprs_version = $globalAPRSversion; |
|
| 489 | + } else { |
|
| 490 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 491 | + } |
|
| 492 | + if (isset($globalAPRSssid)) { |
|
| 493 | + $aprs_ssid = $globalAPRSssid; |
|
| 494 | + } else { |
|
| 495 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 496 | + } |
|
| 497 | + if (isset($globalAPRSfilter)) { |
|
| 498 | + $aprs_filter = $globalAPRSfilter; |
|
| 499 | + } else { |
|
| 500 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 501 | + } |
|
| 502 | + if ($aprs_full) { |
|
| 503 | + $aprs_filter = ''; |
|
| 504 | + } |
|
| 505 | + if (isset($globalAPRSpass)) { |
|
| 506 | + $aprs_pass = $globalAPRSpass; |
|
| 507 | + } else { |
|
| 508 | + $aprs_pass = '-1'; |
|
| 509 | + } |
|
| 390 | 510 | |
| 391 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 392 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 393 | -} |
|
| 511 | + if ($aprs_filter != '') { |
|
| 512 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 513 | + } else { |
|
| 514 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 515 | + } |
|
| 516 | + } |
|
| 394 | 517 | |
| 395 | 518 | // connected - lets do some work |
| 396 | 519 | //if ($globalDebug) echo "Connected!\n"; |
| 397 | 520 | sleep(1); |
| 398 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 399 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 521 | +if ($globalDebug) { |
|
| 522 | + echo "SCAN MODE \n\n"; |
|
| 523 | +} |
|
| 524 | +if (!isset($globalCronEnd)) { |
|
| 525 | + $globalCronEnd = 60; |
|
| 526 | +} |
|
| 400 | 527 | $endtime = time()+$globalCronEnd; |
| 401 | 528 | $i = 1; |
| 402 | 529 | $tt = array(); |
@@ -410,22 +537,32 @@ discard block |
||
| 410 | 537 | |
| 411 | 538 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 412 | 539 | while ($i > 0) { |
| 413 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 540 | + if (function_exists('pcntl_fork')) { |
|
| 541 | + pcntl_signal_dispatch(); |
|
| 542 | + } |
|
| 414 | 543 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 544 | + if (!$globalDaemon) { |
|
| 545 | + $i = $endtime-time(); |
|
| 546 | + } |
|
| 416 | 547 | // Delete old ATC |
| 417 | 548 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 418 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 549 | + if ($globalDebug) { |
|
| 550 | + echo 'Delete old ATC...'."\n"; |
|
| 551 | + } |
|
| 419 | 552 | $ATC->deleteOldATC(); |
| 420 | 553 | } |
| 421 | 554 | |
| 422 | 555 | if (count($last_exec) == count($globalSources)) { |
| 423 | 556 | $max = $globalMinFetch; |
| 424 | 557 | foreach ($last_exec as $last) { |
| 425 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 558 | + if ((time() - $last['last']) < $max) { |
|
| 559 | + $max = time() - $last['last']; |
|
| 560 | + } |
|
| 426 | 561 | } |
| 427 | 562 | if ($max < $globalMinFetch) { |
| 428 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 563 | + if ($globalDebug) { |
|
| 564 | + echo 'Sleeping...'."\n"; |
|
| 565 | + } |
|
| 429 | 566 | sleep($globalMinFetch-$max+2); |
| 430 | 567 | } |
| 431 | 568 | } |
@@ -435,7 +572,9 @@ discard block |
||
| 435 | 572 | foreach ($globalSources as $id => $value) { |
| 436 | 573 | date_default_timezone_set('UTC'); |
| 437 | 574 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 438 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 575 | + if (!isset($last_exec[$id]['last'])) { |
|
| 576 | + $last_exec[$id]['last'] = 0; |
|
| 577 | + } |
|
| 439 | 578 | if ($value['format'] === 'deltadbtxt' && |
| 440 | 579 | ( |
| 441 | 580 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -444,7 +583,9 @@ discard block |
||
| 444 | 583 | ) { |
| 445 | 584 | //$buffer = $Common->getData($hosts[$id]); |
| 446 | 585 | $buffer = $Common->getData($value['host']); |
| 447 | - if ($buffer != '') $reset = 0; |
|
| 586 | + if ($buffer != '') { |
|
| 587 | + $reset = 0; |
|
| 588 | + } |
|
| 448 | 589 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 449 | 590 | $buffer = explode('\n',$buffer); |
| 450 | 591 | foreach ($buffer as $line) { |
@@ -453,20 +594,41 @@ discard block |
||
| 453 | 594 | $data = array(); |
| 454 | 595 | $data['hex'] = $line[1]; // hex |
| 455 | 596 | $data['ident'] = $line[2]; // ident |
| 456 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 597 | + if (isset($line[3])) { |
|
| 598 | + $data['altitude'] = $line[3]; |
|
| 599 | + } |
|
| 600 | + // altitude |
|
| 601 | + if (isset($line[4])) { |
|
| 602 | + $data['speed'] = $line[4]; |
|
| 603 | + } |
|
| 604 | + // speed |
|
| 605 | + if (isset($line[5])) { |
|
| 606 | + $data['heading'] = $line[5]; |
|
| 607 | + } |
|
| 608 | + // heading |
|
| 609 | + if (isset($line[6])) { |
|
| 610 | + $data['latitude'] = $line[6]; |
|
| 611 | + } |
|
| 612 | + // lat |
|
| 613 | + if (isset($line[7])) { |
|
| 614 | + $data['longitude'] = $line[7]; |
|
| 615 | + } |
|
| 616 | + // long |
|
| 461 | 617 | $data['verticalrate'] = ''; // vertical rate |
| 462 | 618 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 463 | 619 | $data['emergency'] = ''; // emergency |
| 464 | 620 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 465 | 621 | $data['format_source'] = 'deltadbtxt'; |
| 466 | 622 | $data['id_source'] = $id_source; |
| 467 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 623 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 624 | + $data['source_name'] = $value['name']; |
|
| 625 | + } |
|
| 626 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 627 | + $data['noarchive'] = true; |
|
| 628 | + } |
|
| 629 | + if (isset($value['sourcestats'])) { |
|
| 630 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 631 | + } |
|
| 470 | 632 | $SI->add($data); |
| 471 | 633 | unset($data); |
| 472 | 634 | } |
@@ -481,7 +643,9 @@ discard block |
||
| 481 | 643 | date_default_timezone_set('CET'); |
| 482 | 644 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 483 | 645 | date_default_timezone_set('UTC'); |
| 484 | - if ($buffer != '') $reset = 0; |
|
| 646 | + if ($buffer != '') { |
|
| 647 | + $reset = 0; |
|
| 648 | + } |
|
| 485 | 649 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 486 | 650 | $buffer = explode('\n',$buffer); |
| 487 | 651 | foreach ($buffer as $line) { |
@@ -490,18 +654,42 @@ discard block |
||
| 490 | 654 | $add = false; |
| 491 | 655 | $ais_data = $AIS->parse_line(trim($line)); |
| 492 | 656 | $data = array(); |
| 493 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 657 | + if (isset($ais_data['ident'])) { |
|
| 658 | + $data['ident'] = $ais_data['ident']; |
|
| 659 | + } |
|
| 660 | + if (isset($ais_data['mmsi'])) { |
|
| 661 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 662 | + } |
|
| 663 | + if (isset($ais_data['speed'])) { |
|
| 664 | + $data['speed'] = $ais_data['speed']; |
|
| 665 | + } |
|
| 666 | + if (isset($ais_data['heading'])) { |
|
| 667 | + $data['heading'] = $ais_data['heading']; |
|
| 668 | + } |
|
| 669 | + if (isset($ais_data['latitude'])) { |
|
| 670 | + $data['latitude'] = $ais_data['latitude']; |
|
| 671 | + } |
|
| 672 | + if (isset($ais_data['longitude'])) { |
|
| 673 | + $data['longitude'] = $ais_data['longitude']; |
|
| 674 | + } |
|
| 675 | + if (isset($ais_data['status'])) { |
|
| 676 | + $data['status'] = $ais_data['status']; |
|
| 677 | + } |
|
| 678 | + if (isset($ais_data['statusid'])) { |
|
| 679 | + $data['status_id'] = $ais_data['statusid']; |
|
| 680 | + } |
|
| 681 | + if (isset($ais_data['type'])) { |
|
| 682 | + $data['type'] = $ais_data['type']; |
|
| 683 | + } |
|
| 684 | + if (isset($ais_data['typeid'])) { |
|
| 685 | + $data['type_id'] = $ais_data['typeid']; |
|
| 686 | + } |
|
| 687 | + if (isset($ais_data['imo'])) { |
|
| 688 | + $data['imo'] = $ais_data['imo']; |
|
| 689 | + } |
|
| 690 | + if (isset($ais_data['callsign'])) { |
|
| 691 | + $data['callsign'] = $ais_data['callsign']; |
|
| 692 | + } |
|
| 505 | 693 | if (isset($ais_data['timestamp'])) { |
| 506 | 694 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 507 | 695 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -515,8 +703,12 @@ discard block |
||
| 515 | 703 | $data['format_source'] = 'aisnmeatxt'; |
| 516 | 704 | $data['id_source'] = $id_source; |
| 517 | 705 | //print_r($data); |
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 706 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 707 | + $data['noarchive'] = true; |
|
| 708 | + } |
|
| 709 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 710 | + $MI->add($data); |
|
| 711 | + } |
|
| 520 | 712 | unset($data); |
| 521 | 713 | } |
| 522 | 714 | } |
@@ -539,20 +731,48 @@ discard block |
||
| 539 | 731 | if ($line != '') { |
| 540 | 732 | $ais_data = $AIS->parse_line(trim($line)); |
| 541 | 733 | $data = array(); |
| 542 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 543 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 544 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 545 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 546 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 547 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 548 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 549 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 550 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 551 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 552 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 553 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 554 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 555 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 734 | + if (isset($ais_data['ident'])) { |
|
| 735 | + $data['ident'] = $ais_data['ident']; |
|
| 736 | + } |
|
| 737 | + if (isset($ais_data['mmsi'])) { |
|
| 738 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 739 | + } |
|
| 740 | + if (isset($ais_data['speed'])) { |
|
| 741 | + $data['speed'] = $ais_data['speed']; |
|
| 742 | + } |
|
| 743 | + if (isset($ais_data['heading'])) { |
|
| 744 | + $data['heading'] = $ais_data['heading']; |
|
| 745 | + } |
|
| 746 | + if (isset($ais_data['latitude'])) { |
|
| 747 | + $data['latitude'] = $ais_data['latitude']; |
|
| 748 | + } |
|
| 749 | + if (isset($ais_data['longitude'])) { |
|
| 750 | + $data['longitude'] = $ais_data['longitude']; |
|
| 751 | + } |
|
| 752 | + if (isset($ais_data['status'])) { |
|
| 753 | + $data['status'] = $ais_data['status']; |
|
| 754 | + } |
|
| 755 | + if (isset($ais_data['statusid'])) { |
|
| 756 | + $data['status_id'] = $ais_data['statusid']; |
|
| 757 | + } |
|
| 758 | + if (isset($ais_data['type'])) { |
|
| 759 | + $data['type'] = $ais_data['type']; |
|
| 760 | + } |
|
| 761 | + if (isset($ais_data['typeid'])) { |
|
| 762 | + $data['type_id'] = $ais_data['typeid']; |
|
| 763 | + } |
|
| 764 | + if (isset($ais_data['imo'])) { |
|
| 765 | + $data['imo'] = $ais_data['imo']; |
|
| 766 | + } |
|
| 767 | + if (isset($ais_data['callsign'])) { |
|
| 768 | + $data['callsign'] = $ais_data['callsign']; |
|
| 769 | + } |
|
| 770 | + if (isset($ais_data['destination'])) { |
|
| 771 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 772 | + } |
|
| 773 | + if (isset($ais_data['eta_ts'])) { |
|
| 774 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 775 | + } |
|
| 556 | 776 | if (isset($ais_data['timestamp'])) { |
| 557 | 777 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 558 | 778 | } else { |
@@ -560,18 +780,27 @@ discard block |
||
| 560 | 780 | } |
| 561 | 781 | $data['format_source'] = 'aisnmeahttp'; |
| 562 | 782 | $data['id_source'] = $id_source; |
| 563 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 564 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 784 | + $data['noarchive'] = true; |
|
| 785 | + } |
|
| 786 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 787 | + $MI->add($data); |
|
| 788 | + } |
|
| 565 | 789 | unset($data); |
| 566 | 790 | } |
| 567 | 791 | } |
| 568 | 792 | } |
| 569 | 793 | } else { |
| 570 | 794 | $format = $value['format']; |
| 571 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | - else $tt[$format] = 0; |
|
| 795 | + if (isset($tt[$format])) { |
|
| 796 | + $tt[$format]++; |
|
| 797 | + } else { |
|
| 798 | + $tt[$format] = 0; |
|
| 799 | + } |
|
| 573 | 800 | if ($tt[$format] > 30) { |
| 574 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 801 | + if ($globalDebug) { |
|
| 802 | + echo 'Reconnect...'."\n"; |
|
| 803 | + } |
|
| 575 | 804 | sleep(2); |
| 576 | 805 | //$sourceeen[] = $value; |
| 577 | 806 | //connect_all($sourceeen); |
@@ -607,12 +836,18 @@ discard block |
||
| 607 | 836 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 608 | 837 | //$data['type_id'] = $line['TYPE']; |
| 609 | 838 | $data['imo'] = $line['IMO']; |
| 610 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 839 | + if ($line['DEST'] != '') { |
|
| 840 | + $data['arrival_code'] = $line['DEST']; |
|
| 841 | + } |
|
| 842 | + if ($line['ARV'] != '') { |
|
| 843 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 844 | + } |
|
| 612 | 845 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 613 | 846 | $data['format_source'] = 'myshiptracking'; |
| 614 | 847 | $data['id_source'] = $id_source; |
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 849 | + $data['noarchive'] = true; |
|
| 850 | + } |
|
| 616 | 851 | $MI->add($data); |
| 617 | 852 | unset($data); |
| 618 | 853 | } |
@@ -637,7 +872,9 @@ discard block |
||
| 637 | 872 | $data['callsign'] = $line['callsign']; |
| 638 | 873 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 639 | 874 | $data['speed'] = $line['sog']; |
| 640 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 875 | + if ($line['heading'] != '511') { |
|
| 876 | + $data['heading'] = $line['heading']; |
|
| 877 | + } |
|
| 641 | 878 | $data['latitude'] = $line['latitude']; |
| 642 | 879 | $data['longitude'] = $line['longitude']; |
| 643 | 880 | $data['type_id'] = $line['shiptype']; |
@@ -645,7 +882,9 @@ discard block |
||
| 645 | 882 | $data['datetime'] = $line['time']; |
| 646 | 883 | $data['format_source'] = 'boatbeaconapp'; |
| 647 | 884 | $data['id_source'] = $id_source; |
| 648 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 885 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 886 | + $data['noarchive'] = true; |
|
| 887 | + } |
|
| 649 | 888 | $MI->add($data); |
| 650 | 889 | unset($data); |
| 651 | 890 | } |
@@ -667,22 +906,44 @@ discard block |
||
| 667 | 906 | foreach ($all_data['features'] as $line) { |
| 668 | 907 | print_r($line); |
| 669 | 908 | $data = array(); |
| 670 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 671 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 672 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 673 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 674 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 675 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 909 | + if (isset($line['properties']['name'])) { |
|
| 910 | + $data['ident'] = $line['properties']['name']; |
|
| 911 | + } |
|
| 912 | + if (isset($line['properties']['callsign'])) { |
|
| 913 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 914 | + } |
|
| 915 | + if (isset($line['properties']['mmsi'])) { |
|
| 916 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 917 | + } |
|
| 918 | + if (isset($line['properties']['imo'])) { |
|
| 919 | + $data['imo'] = $line['properties']['imo']; |
|
| 920 | + } |
|
| 921 | + if (isset($line['properties']['speed'])) { |
|
| 922 | + $data['speed'] = $line['properties']['speed']; |
|
| 923 | + } |
|
| 924 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 925 | + $data['heading'] = $line['properties']['heading']; |
|
| 926 | + } |
|
| 676 | 927 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 677 | 928 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 678 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 679 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 680 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 929 | + if (isset($line['properties']['vesselType'])) { |
|
| 930 | + $data['type'] = $line['properties']['vesselType']; |
|
| 931 | + } |
|
| 932 | + if (isset($line['properties']['destination'])) { |
|
| 933 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 934 | + } |
|
| 935 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 936 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 937 | + } |
|
| 681 | 938 | $data['format_source'] = 'boatnerd'; |
| 682 | 939 | $data['id_source'] = $id_source; |
| 683 | 940 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 684 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 685 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 941 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 942 | + $data['noarchive'] = true; |
|
| 943 | + } |
|
| 944 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 945 | + $MI->add($data); |
|
| 946 | + } |
|
| 686 | 947 | unset($data); |
| 687 | 948 | } |
| 688 | 949 | } |
@@ -695,11 +956,17 @@ discard block |
||
| 695 | 956 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 696 | 957 | ) |
| 697 | 958 | ) { |
| 698 | - if ($globalDebug) echo 'download...'; |
|
| 959 | + if ($globalDebug) { |
|
| 960 | + echo 'download...'; |
|
| 961 | + } |
|
| 699 | 962 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 700 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 963 | + if ($globalDebug) { |
|
| 964 | + echo 'done !'."\n"; |
|
| 965 | + } |
|
| 701 | 966 | // FIXME: Need more work |
| 702 | - if ($buffer != '') $reset = 0; |
|
| 967 | + if ($buffer != '') { |
|
| 968 | + $reset = 0; |
|
| 969 | + } |
|
| 703 | 970 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 704 | 971 | $buffer = explode('\n',$buffer); |
| 705 | 972 | foreach ($buffer as $line) { |
@@ -725,7 +992,9 @@ discard block |
||
| 725 | 992 | //$data['etaTime'] = substr($line,135,5); |
| 726 | 993 | $data['format_source'] = 'shipplotter'; |
| 727 | 994 | $data['id_source'] = $id_source; |
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 995 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 996 | + $data['noarchive'] = true; |
|
| 997 | + } |
|
| 729 | 998 | //print_r($data); |
| 730 | 999 | //echo 'Add...'."\n"; |
| 731 | 1000 | $MI->add($data); |
@@ -739,11 +1008,17 @@ discard block |
||
| 739 | 1008 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 740 | 1009 | ) |
| 741 | 1010 | ) { |
| 742 | - if ($globalDebug) echo '! Download... '; |
|
| 1011 | + if ($globalDebug) { |
|
| 1012 | + echo '! Download... '; |
|
| 1013 | + } |
|
| 743 | 1014 | for ($i =0; $i <= 1; $i++) { |
| 744 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1015 | + if ($globalDebug) { |
|
| 1016 | + echo 'Racetype: '.$i.' '; |
|
| 1017 | + } |
|
| 745 | 1018 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 746 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1019 | + if ($globalDebug) { |
|
| 1020 | + echo 'done'."\n"; |
|
| 1021 | + } |
|
| 747 | 1022 | if ($buffer != '') { |
| 748 | 1023 | $all_data = json_decode($buffer,true); |
| 749 | 1024 | if (isset($all_data['missions'])) { |
@@ -752,7 +1027,9 @@ discard block |
||
| 752 | 1027 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$mission['mistitle']); |
| 753 | 1028 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 754 | 1029 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 755 | - } else $bufferm = ''; |
|
| 1030 | + } else { |
|
| 1031 | + $bufferm = ''; |
|
| 1032 | + } |
|
| 756 | 1033 | if ($bufferm != '') { |
| 757 | 1034 | $mission_data = json_decode($bufferm,true); |
| 758 | 1035 | if (isset($mission_data['leaderboard'][0]['results'])) { |
@@ -790,7 +1067,9 @@ discard block |
||
| 790 | 1067 | $data['captain_id'] = $sail['usrnr']; |
| 791 | 1068 | $data['captain_name'] = $sail['usrname']; |
| 792 | 1069 | $data['race_id'] = $sail['misnr']; |
| 793 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1070 | + if ($sail['rank'] != 'DNF') { |
|
| 1071 | + $data['race_rank'] = $sail['rank']; |
|
| 1072 | + } |
|
| 794 | 1073 | $data['race_time'] = $sail['racetime']; |
| 795 | 1074 | if ($mission_user != '') { |
| 796 | 1075 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -800,7 +1079,9 @@ discard block |
||
| 800 | 1079 | //$data['callsign'] = trim(substr($line,100,7); |
| 801 | 1080 | $data['format_source'] = 'sailaway'; |
| 802 | 1081 | $data['id_source'] = $id_source; |
| 803 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1082 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1083 | + $data['noarchive'] = true; |
|
| 1084 | + } |
|
| 804 | 1085 | //print_r($data); |
| 805 | 1086 | //echo 'Add...'."\n"; |
| 806 | 1087 | $MI->add($data); |
@@ -841,16 +1122,28 @@ discard block |
||
| 841 | 1122 | $line = explode(':', $line); |
| 842 | 1123 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 843 | 1124 | $data = array(); |
| 844 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 845 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1125 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1126 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1127 | + } else { |
|
| 1128 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1129 | + } |
|
| 846 | 1130 | $data['pilot_id'] = $line[1]; |
| 847 | 1131 | $data['pilot_name'] = $line[2]; |
| 848 | 1132 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 849 | 1133 | $data['ident'] = $line[0]; // ident |
| 850 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1134 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1135 | + $data['altitude'] = $line[7]; |
|
| 1136 | + } |
|
| 1137 | + // altitude |
|
| 851 | 1138 | $data['speed'] = $line[8]; // speed |
| 852 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 853 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1139 | + if (isset($line[45])) { |
|
| 1140 | + $data['heading'] = $line[45]; |
|
| 1141 | + } |
|
| 1142 | + // heading |
|
| 1143 | + elseif (isset($line[38])) { |
|
| 1144 | + $data['heading'] = $line[38]; |
|
| 1145 | + } |
|
| 1146 | + // heading |
|
| 854 | 1147 | $data['latitude'] = $line[5]; // lat |
| 855 | 1148 | $data['longitude'] = $line[6]; // long |
| 856 | 1149 | $data['verticalrate'] = ''; // vertical rate |
@@ -866,7 +1159,9 @@ discard block |
||
| 866 | 1159 | $data['frequency'] = $line[4]; |
| 867 | 1160 | $data['type'] = $line[18]; |
| 868 | 1161 | $data['range'] = $line[19]; |
| 869 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1162 | + if (isset($line[35])) { |
|
| 1163 | + $data['info'] = $line[35]; |
|
| 1164 | + } |
|
| 870 | 1165 | $data['id_source'] = $id_source; |
| 871 | 1166 | //$data['arrival_airport_time'] = ; |
| 872 | 1167 | if ($line[9] != '') { |
@@ -880,27 +1175,47 @@ discard block |
||
| 880 | 1175 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 881 | 1176 | */ |
| 882 | 1177 | $data['format_source'] = $value['format']; |
| 883 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 884 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 885 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 886 | - elseif ($line[3] === 'ATC') { |
|
| 1178 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1179 | + $data['noarchive'] = true; |
|
| 1180 | + } |
|
| 1181 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1182 | + $data['source_name'] = $value['name']; |
|
| 1183 | + } |
|
| 1184 | + if ($line[3] === 'PILOT') { |
|
| 1185 | + $SI->add($data); |
|
| 1186 | + } elseif ($line[3] === 'ATC') { |
|
| 887 | 1187 | //print_r($data); |
| 888 | 1188 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 889 | 1189 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 890 | 1190 | $typec = substr($data['ident'],-3); |
| 891 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 892 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 893 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 894 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 895 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 896 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 897 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 898 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 899 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 900 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1191 | + if ($typec === 'APP') { |
|
| 1192 | + $data['type'] = 'Approach'; |
|
| 1193 | + } elseif ($typec === 'TWR') { |
|
| 1194 | + $data['type'] = 'Tower'; |
|
| 1195 | + } elseif ($typec === 'OBS') { |
|
| 1196 | + $data['type'] = 'Observer'; |
|
| 1197 | + } elseif ($typec === 'GND') { |
|
| 1198 | + $data['type'] = 'Ground'; |
|
| 1199 | + } elseif ($typec === 'DEL') { |
|
| 1200 | + $data['type'] = 'Delivery'; |
|
| 1201 | + } elseif ($typec === 'DEP') { |
|
| 1202 | + $data['type'] = 'Departure'; |
|
| 1203 | + } elseif ($typec === 'FSS') { |
|
| 1204 | + $data['type'] = 'Flight Service Station'; |
|
| 1205 | + } elseif ($typec === 'CTR') { |
|
| 1206 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1207 | + } elseif ($data['type'] === '') { |
|
| 1208 | + $data['type'] = 'Observer'; |
|
| 1209 | + } |
|
| 1210 | + if (!isset($data['source_name'])) { |
|
| 1211 | + $data['source_name'] = ''; |
|
| 1212 | + } |
|
| 901 | 1213 | if (isset($ATC)) { |
| 902 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 903 | - else 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'],$data['format_source'],$data['source_name']); |
|
| 1214 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1215 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1216 | + } else { |
|
| 1217 | + 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'],$data['format_source'],$data['source_name']); |
|
| 1218 | + } |
|
| 904 | 1219 | } |
| 905 | 1220 | } |
| 906 | 1221 | unset($data); |
@@ -927,14 +1242,20 @@ discard block |
||
| 927 | 1242 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 928 | 1243 | $data['latitude'] = (float)$line['pktLatitude']; |
| 929 | 1244 | $data['longitude'] = (float)$line['pktLongitude']; |
| 930 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 931 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1245 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1246 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1247 | + } |
|
| 1248 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1249 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1250 | + } |
|
| 932 | 1251 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 933 | 1252 | $data['altitude_relative'] = 'AMSL'; |
| 934 | 1253 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 935 | 1254 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 936 | 1255 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 937 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1256 | + if (isset($pilot_data[4])) { |
|
| 1257 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1258 | + } |
|
| 938 | 1259 | $data['format_source'] = $value['format']; |
| 939 | 1260 | $SI->add($data); |
| 940 | 1261 | unset($data); |
@@ -982,25 +1303,59 @@ discard block |
||
| 982 | 1303 | foreach ($all_data['acList'] as $line) { |
| 983 | 1304 | $data = array(); |
| 984 | 1305 | $data['hex'] = $line['Icao']; // hex |
| 985 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 986 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 987 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 988 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 989 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 990 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1306 | + if (isset($line['Call'])) { |
|
| 1307 | + $data['ident'] = $line['Call']; |
|
| 1308 | + } |
|
| 1309 | + // ident |
|
| 1310 | + if (isset($line['Alt'])) { |
|
| 1311 | + $data['altitude'] = $line['Alt']; |
|
| 1312 | + } |
|
| 1313 | + // altitude |
|
| 1314 | + if (isset($line['Spd'])) { |
|
| 1315 | + $data['speed'] = $line['Spd']; |
|
| 1316 | + } |
|
| 1317 | + // speed |
|
| 1318 | + if (isset($line['Trak'])) { |
|
| 1319 | + $data['heading'] = $line['Trak']; |
|
| 1320 | + } |
|
| 1321 | + // heading |
|
| 1322 | + if (isset($line['Lat'])) { |
|
| 1323 | + $data['latitude'] = $line['Lat']; |
|
| 1324 | + } |
|
| 1325 | + // lat |
|
| 1326 | + if (isset($line['Long'])) { |
|
| 1327 | + $data['longitude'] = $line['Long']; |
|
| 1328 | + } |
|
| 1329 | + // long |
|
| 991 | 1330 | //$data['verticalrate'] = $line['']; // verticale rate |
| 992 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1331 | + if (isset($line['Sqk'])) { |
|
| 1332 | + $data['squawk'] = $line['Sqk']; |
|
| 1333 | + } |
|
| 1334 | + // squawk |
|
| 993 | 1335 | $data['emergency'] = ''; // emergency |
| 994 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 995 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 996 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1336 | + if (isset($line['Reg'])) { |
|
| 1337 | + $data['registration'] = $line['Reg']; |
|
| 1338 | + } |
|
| 1339 | + if (isset($line['PosTime'])) { |
|
| 1340 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1341 | + } else { |
|
| 1342 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1343 | + } |
|
| 997 | 1344 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 998 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1345 | + if (isset($line['Type'])) { |
|
| 1346 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1347 | + } |
|
| 999 | 1348 | $data['format_source'] = 'aircraftlistjson'; |
| 1000 | 1349 | $data['id_source'] = $id_source; |
| 1001 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1002 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1003 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1350 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1351 | + $data['source_name'] = $value['name']; |
|
| 1352 | + } |
|
| 1353 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1354 | + $data['noarchive'] = true; |
|
| 1355 | + } |
|
| 1356 | + if (isset($data['latitude'])) { |
|
| 1357 | + $SI->add($data); |
|
| 1358 | + } |
|
| 1004 | 1359 | unset($data); |
| 1005 | 1360 | } |
| 1006 | 1361 | } elseif (is_array($all_data)) { |
@@ -1017,17 +1372,26 @@ discard block |
||
| 1017 | 1372 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1018 | 1373 | $data['squawk'] = $line['squawk']; // squawk |
| 1019 | 1374 | $data['emergency'] = ''; // emergency |
| 1020 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1021 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1375 | + if (isset($line['PosTime'])) { |
|
| 1376 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1377 | + } else { |
|
| 1378 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1379 | + } |
|
| 1022 | 1380 | $data['format_source'] = 'aircraftlistjson'; |
| 1023 | 1381 | $data['id_source'] = $id_source; |
| 1024 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1025 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1382 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1383 | + $data['noarchive'] = true; |
|
| 1384 | + } |
|
| 1385 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1386 | + $data['source_name'] = $value['name']; |
|
| 1387 | + } |
|
| 1026 | 1388 | $SI->add($data); |
| 1027 | 1389 | unset($data); |
| 1028 | 1390 | } |
| 1029 | 1391 | } |
| 1030 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1392 | + } elseif ($globalDebug) { |
|
| 1393 | + echo 'No data'."\n"; |
|
| 1394 | + } |
|
| 1031 | 1395 | //$last_exec['aircraftlistjson'] = time(); |
| 1032 | 1396 | $last_exec[$id]['last'] = time(); |
| 1033 | 1397 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1063,8 +1427,12 @@ discard block |
||
| 1063 | 1427 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1064 | 1428 | $data['format_source'] = 'planeupdatefaa'; |
| 1065 | 1429 | $data['id_source'] = $id_source; |
| 1066 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1067 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1430 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1431 | + $data['noarchive'] = true; |
|
| 1432 | + } |
|
| 1433 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1434 | + $data['source_name'] = $value['name']; |
|
| 1435 | + } |
|
| 1068 | 1436 | $SI->add($data); |
| 1069 | 1437 | unset($data); |
| 1070 | 1438 | } |
@@ -1098,7 +1466,9 @@ discard block |
||
| 1098 | 1466 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1099 | 1467 | $data['format_source'] = 'opensky'; |
| 1100 | 1468 | $data['id_source'] = $id_source; |
| 1101 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1469 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1470 | + $data['noarchive'] = true; |
|
| 1471 | + } |
|
| 1102 | 1472 | $SI->add($data); |
| 1103 | 1473 | unset($data); |
| 1104 | 1474 | } |
@@ -1118,15 +1488,42 @@ discard block |
||
| 1118 | 1488 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1119 | 1489 | $data = array(); |
| 1120 | 1490 | // add support for ground vehicule with ~ in front of hex |
| 1121 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1122 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1123 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1124 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1125 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1126 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1127 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1128 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1129 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1491 | + if (isset($line['hex'])) { |
|
| 1492 | + $data['hex'] = $line['hex']; |
|
| 1493 | + } |
|
| 1494 | + // hex |
|
| 1495 | + if (isset($line['flight'])) { |
|
| 1496 | + $data['ident'] = trim($line['flight']); |
|
| 1497 | + } |
|
| 1498 | + // ident |
|
| 1499 | + if (isset($line['altitude'])) { |
|
| 1500 | + $data['altitude'] = $line['altitude']; |
|
| 1501 | + } |
|
| 1502 | + // altitude |
|
| 1503 | + if (isset($line['speed'])) { |
|
| 1504 | + $data['speed'] = $line['speed']; |
|
| 1505 | + } |
|
| 1506 | + // speed |
|
| 1507 | + if (isset($line['track'])) { |
|
| 1508 | + $data['heading'] = $line['track']; |
|
| 1509 | + } |
|
| 1510 | + // heading |
|
| 1511 | + if (isset($line['lat'])) { |
|
| 1512 | + $data['latitude'] = $line['lat']; |
|
| 1513 | + } |
|
| 1514 | + // lat |
|
| 1515 | + if (isset($line['lon'])) { |
|
| 1516 | + $data['longitude'] = $line['lon']; |
|
| 1517 | + } |
|
| 1518 | + // long |
|
| 1519 | + if (isset($line['vert_rate'])) { |
|
| 1520 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1521 | + } |
|
| 1522 | + // verticale rate |
|
| 1523 | + if (isset($line['squawk'])) { |
|
| 1524 | + $data['squawk'] = $line['squawk']; |
|
| 1525 | + } |
|
| 1526 | + // squawk |
|
| 1130 | 1527 | //$data['emergency'] = ''; // emergency |
| 1131 | 1528 | //$data['registration'] = $line[2]; |
| 1132 | 1529 | //$data['aircraft_icao'] = $line[0]; |
@@ -1134,10 +1531,17 @@ discard block |
||
| 1134 | 1531 | $data['format_source'] = 'aircraftjson'; |
| 1135 | 1532 | $data['id_source'] = $id_source; |
| 1136 | 1533 | if (isset($value['name']) && $value['name'] != '') { |
| 1137 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1138 | - else $data['source_name'] = $value['name']; |
|
| 1139 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1140 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1534 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1535 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1536 | + } else { |
|
| 1537 | + $data['source_name'] = $value['name']; |
|
| 1538 | + } |
|
| 1539 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1540 | + $data['source_name'] = 'MLAT'; |
|
| 1541 | + } |
|
| 1542 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1543 | + $data['noarchive'] = true; |
|
| 1544 | + } |
|
| 1141 | 1545 | $SI->add($data); |
| 1142 | 1546 | unset($data); |
| 1143 | 1547 | } |
@@ -1157,22 +1561,54 @@ discard block |
||
| 1157 | 1561 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1158 | 1562 | $data = array(); |
| 1159 | 1563 | $data['hex'] = $key; // hex |
| 1160 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1161 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1162 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1163 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1164 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1165 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1166 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1167 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1564 | + if (isset($line['callsign'])) { |
|
| 1565 | + $data['ident'] = trim($line['callsign']); |
|
| 1566 | + } |
|
| 1567 | + // ident |
|
| 1568 | + if (isset($line['altitude'])) { |
|
| 1569 | + $data['altitude'] = $line['altitude']; |
|
| 1570 | + } |
|
| 1571 | + // altitude |
|
| 1572 | + if (isset($line['speed'])) { |
|
| 1573 | + $data['speed'] = $line['speed']; |
|
| 1574 | + } |
|
| 1575 | + // speed |
|
| 1576 | + if (isset($line['heading'])) { |
|
| 1577 | + $data['heading'] = $line['heading']; |
|
| 1578 | + } |
|
| 1579 | + // heading |
|
| 1580 | + if (isset($line['lat'])) { |
|
| 1581 | + $data['latitude'] = $line['lat']; |
|
| 1582 | + } |
|
| 1583 | + // lat |
|
| 1584 | + if (isset($line['lon'])) { |
|
| 1585 | + $data['longitude'] = $line['lon']; |
|
| 1586 | + } |
|
| 1587 | + // long |
|
| 1588 | + if (isset($line['vert_rate'])) { |
|
| 1589 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1590 | + } |
|
| 1591 | + // verticale rate |
|
| 1592 | + if (isset($line['squawk'])) { |
|
| 1593 | + $data['squawk'] = $line['squawk']; |
|
| 1594 | + } |
|
| 1595 | + // squawk |
|
| 1168 | 1596 | //$data['emergency'] = ''; // emergency |
| 1169 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1170 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1597 | + if (isset($line['reg'])) { |
|
| 1598 | + $data['registration'] = $line['reg']; |
|
| 1599 | + } |
|
| 1600 | + if (isset($line['type'])) { |
|
| 1601 | + $data['aircraft_icao'] = $line['type']; |
|
| 1602 | + } |
|
| 1171 | 1603 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1172 | 1604 | $data['format_source'] = 'planefinderclient'; |
| 1173 | 1605 | $data['id_source'] = $id_source; |
| 1174 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1175 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1606 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1607 | + $data['source_name'] = $value['name']; |
|
| 1608 | + } |
|
| 1609 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1610 | + $data['noarchive'] = true; |
|
| 1611 | + } |
|
| 1176 | 1612 | $SI->add($data); |
| 1177 | 1613 | unset($data); |
| 1178 | 1614 | } |
@@ -1188,7 +1624,9 @@ discard block |
||
| 1188 | 1624 | //$buffer = $Common->getData($hosts[$id]); |
| 1189 | 1625 | $buffer = $Common->getData($value['host']); |
| 1190 | 1626 | $all_data = json_decode($buffer,true); |
| 1191 | - if (!empty($all_data)) $reset = 0; |
|
| 1627 | + if (!empty($all_data)) { |
|
| 1628 | + $reset = 0; |
|
| 1629 | + } |
|
| 1192 | 1630 | foreach ($all_data as $key => $line) { |
| 1193 | 1631 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1194 | 1632 | $data = array(); |
@@ -1209,8 +1647,12 @@ discard block |
||
| 1209 | 1647 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1210 | 1648 | $data['format_source'] = 'fr24json'; |
| 1211 | 1649 | $data['id_source'] = $id_source; |
| 1212 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1213 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1650 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1651 | + $data['noarchive'] = true; |
|
| 1652 | + } |
|
| 1653 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1654 | + $data['source_name'] = $value['name']; |
|
| 1655 | + } |
|
| 1214 | 1656 | $SI->add($data); |
| 1215 | 1657 | unset($data); |
| 1216 | 1658 | } |
@@ -1239,24 +1681,42 @@ discard block |
||
| 1239 | 1681 | if (isset($line['inf'])) { |
| 1240 | 1682 | $data = array(); |
| 1241 | 1683 | $data['hex'] = $line['inf']['ia']; |
| 1242 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1684 | + if (isset($line['inf']['cs'])) { |
|
| 1685 | + $data['ident'] = $line['inf']['cs']; |
|
| 1686 | + } |
|
| 1687 | + //$line[13] |
|
| 1243 | 1688 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1244 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1245 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1689 | + if (isset($line['inf']['gs'])) { |
|
| 1690 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1691 | + } |
|
| 1692 | + // speed |
|
| 1693 | + if (isset($line['inf']['tr'])) { |
|
| 1694 | + $data['heading'] = $line['inf']['tr']; |
|
| 1695 | + } |
|
| 1696 | + // heading |
|
| 1246 | 1697 | $data['latitude'] = $line['pt'][0]; // lat |
| 1247 | 1698 | $data['longitude'] = $line['pt'][1]; // long |
| 1248 | 1699 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1249 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1700 | + if (isset($line['inf']['sq'])) { |
|
| 1701 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1702 | + } |
|
| 1703 | + // squawk |
|
| 1250 | 1704 | //$data['aircraft_icao'] = $line[8]; |
| 1251 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1705 | + if (isset($line['inf']['rc'])) { |
|
| 1706 | + $data['registration'] = $line['inf']['rc']; |
|
| 1707 | + } |
|
| 1252 | 1708 | //$data['departure_airport_iata'] = $line[11]; |
| 1253 | 1709 | //$data['arrival_airport_iata'] = $line[12]; |
| 1254 | 1710 | //$data['emergency'] = ''; // emergency |
| 1255 | 1711 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1256 | 1712 | $data['format_source'] = 'radarvirtueljson'; |
| 1257 | 1713 | $data['id_source'] = $id_source; |
| 1258 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1259 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1714 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1715 | + $data['noarchive'] = true; |
|
| 1716 | + } |
|
| 1717 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1718 | + $data['source_name'] = $value['name']; |
|
| 1719 | + } |
|
| 1260 | 1720 | $SI->add($data); |
| 1261 | 1721 | unset($data); |
| 1262 | 1722 | } |
@@ -1282,30 +1742,65 @@ discard block |
||
| 1282 | 1742 | $data['id'] = $line['id']; |
| 1283 | 1743 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1284 | 1744 | $data['ident'] = $line['callsign']; // ident |
| 1285 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1286 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1287 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1288 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1289 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1290 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1745 | + if (isset($line['pilotid'])) { |
|
| 1746 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1747 | + } |
|
| 1748 | + // pilot id |
|
| 1749 | + if (isset($line['name'])) { |
|
| 1750 | + $data['pilot_name'] = $line['name']; |
|
| 1751 | + } |
|
| 1752 | + // pilot name |
|
| 1753 | + if (isset($line['alt'])) { |
|
| 1754 | + $data['altitude'] = $line['alt']; |
|
| 1755 | + } |
|
| 1756 | + // altitude |
|
| 1757 | + if (isset($line['gs'])) { |
|
| 1758 | + $data['speed'] = $line['gs']; |
|
| 1759 | + } |
|
| 1760 | + // speed |
|
| 1761 | + if (isset($line['heading'])) { |
|
| 1762 | + $data['heading'] = $line['heading']; |
|
| 1763 | + } |
|
| 1764 | + // heading |
|
| 1765 | + if (isset($line['route'])) { |
|
| 1766 | + $data['waypoints'] = $line['route']; |
|
| 1767 | + } |
|
| 1768 | + // route |
|
| 1291 | 1769 | $data['latitude'] = $line['lat']; // lat |
| 1292 | 1770 | $data['longitude'] = $line['lon']; // long |
| 1293 | 1771 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1294 | 1772 | //$data['squawk'] = $line['squawk']; // squawk |
| 1295 | 1773 | //$data['emergency'] = ''; // emergency |
| 1296 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1297 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1298 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1774 | + if (isset($line['depicao'])) { |
|
| 1775 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1776 | + } |
|
| 1777 | + if (isset($line['deptime'])) { |
|
| 1778 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1779 | + } |
|
| 1780 | + if (isset($line['arricao'])) { |
|
| 1781 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1782 | + } |
|
| 1299 | 1783 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1300 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1301 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1302 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1303 | - else $data['info'] = ''; |
|
| 1784 | + if (isset($line['aircraft'])) { |
|
| 1785 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1786 | + } |
|
| 1787 | + if (isset($line['transponder'])) { |
|
| 1788 | + $data['squawk'] = $line['transponder']; |
|
| 1789 | + } |
|
| 1790 | + if (isset($line['atis'])) { |
|
| 1791 | + $data['info'] = $line['atis']; |
|
| 1792 | + } else { |
|
| 1793 | + $data['info'] = ''; |
|
| 1794 | + } |
|
| 1304 | 1795 | $data['format_source'] = 'pireps'; |
| 1305 | 1796 | $data['id_source'] = $id_source; |
| 1306 | 1797 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1307 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1308 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1798 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1799 | + $data['noarchive'] = true; |
|
| 1800 | + } |
|
| 1801 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1802 | + $data['source_name'] = $value['name']; |
|
| 1803 | + } |
|
| 1309 | 1804 | if ($line['icon'] === 'plane') { |
| 1310 | 1805 | $SI->add($data); |
| 1311 | 1806 | // print_r($data); |
@@ -1314,16 +1809,28 @@ discard block |
||
| 1314 | 1809 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1315 | 1810 | $typec = substr($data['ident'],-3); |
| 1316 | 1811 | $data['type'] = ''; |
| 1317 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1318 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1319 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1320 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1321 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1322 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1323 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1324 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1325 | - else $data['type'] = 'Observer'; |
|
| 1326 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1812 | + if ($typec === 'APP') { |
|
| 1813 | + $data['type'] = 'Approach'; |
|
| 1814 | + } elseif ($typec === 'TWR') { |
|
| 1815 | + $data['type'] = 'Tower'; |
|
| 1816 | + } elseif ($typec === 'OBS') { |
|
| 1817 | + $data['type'] = 'Observer'; |
|
| 1818 | + } elseif ($typec === 'GND') { |
|
| 1819 | + $data['type'] = 'Ground'; |
|
| 1820 | + } elseif ($typec === 'DEL') { |
|
| 1821 | + $data['type'] = 'Delivery'; |
|
| 1822 | + } elseif ($typec === 'DEP') { |
|
| 1823 | + $data['type'] = 'Departure'; |
|
| 1824 | + } elseif ($typec === 'FSS') { |
|
| 1825 | + $data['type'] = 'Flight Service Station'; |
|
| 1826 | + } elseif ($typec === 'CTR') { |
|
| 1827 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1828 | + } else { |
|
| 1829 | + $data['type'] = 'Observer'; |
|
| 1830 | + } |
|
| 1831 | + if (isset($ATC)) { |
|
| 1832 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1833 | + } |
|
| 1327 | 1834 | } |
| 1328 | 1835 | unset($data); |
| 1329 | 1836 | } |
@@ -1338,7 +1845,9 @@ discard block |
||
| 1338 | 1845 | ) |
| 1339 | 1846 | ) { |
| 1340 | 1847 | //$buffer = $Common->getData($hosts[$id]); |
| 1341 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1848 | + if ($globalDebug) { |
|
| 1849 | + echo 'Get Data...'."\n"; |
|
| 1850 | + } |
|
| 1342 | 1851 | $buffer = $Common->getData($value['host']); |
| 1343 | 1852 | $all_data = json_decode($buffer,true); |
| 1344 | 1853 | if ($buffer != '' && is_array($all_data)) { |
@@ -1346,10 +1855,16 @@ discard block |
||
| 1346 | 1855 | foreach ($all_data as $line) { |
| 1347 | 1856 | $data = array(); |
| 1348 | 1857 | //$data['id'] = $line['id']; // id not usable |
| 1349 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1858 | + if (isset($line['pilotid'])) { |
|
| 1859 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1860 | + } |
|
| 1350 | 1861 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1351 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1352 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1862 | + if (isset($line['pilotname'])) { |
|
| 1863 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1864 | + } |
|
| 1865 | + if (isset($line['pilotid'])) { |
|
| 1866 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1867 | + } |
|
| 1353 | 1868 | $data['ident'] = $line['flightnum']; // ident |
| 1354 | 1869 | $data['altitude'] = $line['alt']; // altitude |
| 1355 | 1870 | $data['speed'] = $line['gs']; // speed |
@@ -1365,7 +1880,9 @@ discard block |
||
| 1365 | 1880 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1366 | 1881 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1367 | 1882 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1368 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1883 | + } else { |
|
| 1884 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1885 | + } |
|
| 1369 | 1886 | $data['departure_airport_icao'] = $line['depicao']; |
| 1370 | 1887 | $data['departure_airport_time'] = $line['deptime']; |
| 1371 | 1888 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1373,29 +1890,47 @@ discard block |
||
| 1373 | 1890 | if (isset($line['registration'])) { |
| 1374 | 1891 | $data['registration'] = $line['registration']; |
| 1375 | 1892 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1376 | - } else $data['registration'] = $line['aircraft']; |
|
| 1377 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1378 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1893 | + } else { |
|
| 1894 | + $data['registration'] = $line['aircraft']; |
|
| 1895 | + } |
|
| 1896 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1897 | + $data['noarchive'] = true; |
|
| 1898 | + } |
|
| 1899 | + if (isset($line['route'])) { |
|
| 1900 | + $data['waypoints'] = $line['route']; |
|
| 1901 | + } |
|
| 1902 | + // route |
|
| 1379 | 1903 | if (isset($line['aircraftname'])) { |
| 1380 | 1904 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1381 | 1905 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1382 | 1906 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1383 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1384 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1385 | - else { |
|
| 1907 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1908 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1909 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1910 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1911 | + } else { |
|
| 1386 | 1912 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1387 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1388 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1913 | + if (isset($aircraft_data[1])) { |
|
| 1914 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1915 | + } else { |
|
| 1916 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1917 | + } |
|
| 1389 | 1918 | } |
| 1390 | 1919 | } |
| 1391 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1920 | + if (isset($line['route'])) { |
|
| 1921 | + $data['waypoints'] = $line['route']; |
|
| 1922 | + } |
|
| 1392 | 1923 | $data['id_source'] = $id_source; |
| 1393 | 1924 | $data['format_source'] = 'phpvmacars'; |
| 1394 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1925 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1926 | + $data['source_name'] = $value['name']; |
|
| 1927 | + } |
|
| 1395 | 1928 | $SI->add($data); |
| 1396 | 1929 | unset($data); |
| 1397 | 1930 | } |
| 1398 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1931 | + if ($globalDebug) { |
|
| 1932 | + echo 'No more data...'."\n"; |
|
| 1933 | + } |
|
| 1399 | 1934 | unset($buffer); |
| 1400 | 1935 | unset($all_data); |
| 1401 | 1936 | } |
@@ -1408,7 +1943,9 @@ discard block |
||
| 1408 | 1943 | ) |
| 1409 | 1944 | ) { |
| 1410 | 1945 | //$buffer = $Common->getData($hosts[$id]); |
| 1411 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1946 | + if ($globalDebug) { |
|
| 1947 | + echo 'Get Data...'."\n"; |
|
| 1948 | + } |
|
| 1412 | 1949 | $buffer = $Common->getData($value['host']); |
| 1413 | 1950 | $all_data = json_decode($buffer,true); |
| 1414 | 1951 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1419,10 +1956,16 @@ discard block |
||
| 1419 | 1956 | //$data['id'] = $line['id']; // id not usable |
| 1420 | 1957 | $data['id'] = $line['id']; |
| 1421 | 1958 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1422 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1423 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1959 | + if (isset($line['user']['username'])) { |
|
| 1960 | + $data['pilot_name'] = $line['user']['username']; |
|
| 1961 | + } |
|
| 1962 | + if (isset($line['user_id'])) { |
|
| 1963 | + $data['pilot_id'] = $line['user_id']; |
|
| 1964 | + } |
|
| 1424 | 1965 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1425 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1966 | + if (is_numeric($data['ident'])) { |
|
| 1967 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1968 | + } |
|
| 1426 | 1969 | $data['altitude'] = $line['altitude']; // altitude |
| 1427 | 1970 | $data['speed'] = $line['groundspeed']; // speed |
| 1428 | 1971 | $data['heading'] = $line['heading']; // heading |
@@ -1435,7 +1978,9 @@ discard block |
||
| 1435 | 1978 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1436 | 1979 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1437 | 1980 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1438 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1981 | + } else { |
|
| 1982 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1983 | + } |
|
| 1439 | 1984 | |
| 1440 | 1985 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1441 | 1986 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1443,17 +1988,26 @@ discard block |
||
| 1443 | 1988 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1444 | 1989 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1445 | 1990 | |
| 1446 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1447 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1991 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1992 | + $data['noarchive'] = true; |
|
| 1993 | + } |
|
| 1994 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 1995 | + $data['waypoints'] = $line['bid']['route']; |
|
| 1996 | + } |
|
| 1997 | + // route |
|
| 1448 | 1998 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1449 | 1999 | |
| 1450 | 2000 | $data['id_source'] = $id_source; |
| 1451 | 2001 | $data['format_source'] = 'vaos'; |
| 1452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2002 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2003 | + $data['source_name'] = $value['name']; |
|
| 2004 | + } |
|
| 1453 | 2005 | $SI->add($data); |
| 1454 | 2006 | unset($data); |
| 1455 | 2007 | } |
| 1456 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2008 | + if ($globalDebug) { |
|
| 2009 | + echo 'No more data...'."\n"; |
|
| 2010 | + } |
|
| 1457 | 2011 | unset($buffer); |
| 1458 | 2012 | unset($all_data); |
| 1459 | 2013 | } |
@@ -1466,7 +2020,9 @@ discard block |
||
| 1466 | 2020 | ) |
| 1467 | 2021 | ) { |
| 1468 | 2022 | //$buffer = $Common->getData($hosts[$id]); |
| 1469 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2023 | + if ($globalDebug) { |
|
| 2024 | + echo 'Get Data...'."\n"; |
|
| 2025 | + } |
|
| 1470 | 2026 | $buffer = $Common->getData($value['host']); |
| 1471 | 2027 | $all_data = json_decode($buffer,true); |
| 1472 | 2028 | if ($buffer != '' && is_array($all_data)) { |
@@ -1495,16 +2051,25 @@ discard block |
||
| 1495 | 2051 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1496 | 2052 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1497 | 2053 | //$data['registration'] = $line['aircraft']; |
| 1498 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2054 | + if (isset($line['route'])) { |
|
| 2055 | + $data['waypoints'] = $line['route']; |
|
| 2056 | + } |
|
| 2057 | + // route |
|
| 1499 | 2058 | $data['aircraft_icao'] = $line['plane_type']; |
| 1500 | 2059 | $data['id_source'] = $id_source; |
| 1501 | 2060 | $data['format_source'] = 'vam'; |
| 1502 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1503 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2061 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2062 | + $data['noarchive'] = true; |
|
| 2063 | + } |
|
| 2064 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2065 | + $data['source_name'] = $value['name']; |
|
| 2066 | + } |
|
| 1504 | 2067 | $SI->add($data); |
| 1505 | 2068 | unset($data); |
| 1506 | 2069 | } |
| 1507 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2070 | + if ($globalDebug) { |
|
| 2071 | + echo 'No more data...'."\n"; |
|
| 2072 | + } |
|
| 1508 | 2073 | unset($buffer); |
| 1509 | 2074 | unset($all_data); |
| 1510 | 2075 | } |
@@ -1517,7 +2082,9 @@ discard block |
||
| 1517 | 2082 | ) |
| 1518 | 2083 | ) { |
| 1519 | 2084 | //$buffer = $Common->getData($hosts[$id]); |
| 1520 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2085 | + if ($globalDebug) { |
|
| 2086 | + echo 'Get Data...'."\n"; |
|
| 2087 | + } |
|
| 1521 | 2088 | $buffer = $Common->getData($value['host']); |
| 1522 | 2089 | $all_data = json_decode($buffer,true); |
| 1523 | 2090 | if ($buffer != '') { |
@@ -1535,12 +2102,16 @@ discard block |
||
| 1535 | 2102 | $data['id_source'] = $id_source; |
| 1536 | 2103 | $data['format_source'] = 'blitzortung'; |
| 1537 | 2104 | $SI->add($data); |
| 1538 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2105 | + if ($globalDebug) { |
|
| 2106 | + echo '☈ Lightning added'."\n"; |
|
| 2107 | + } |
|
| 1539 | 2108 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1540 | 2109 | unset($data); |
| 1541 | 2110 | } |
| 1542 | 2111 | } |
| 1543 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo 'No more data...'."\n"; |
|
| 2114 | + } |
|
| 1544 | 2115 | unset($buffer); |
| 1545 | 2116 | } |
| 1546 | 2117 | $last_exec[$id]['last'] = time(); |
@@ -1552,7 +2123,9 @@ discard block |
||
| 1552 | 2123 | $write = NULL; |
| 1553 | 2124 | $e = NULL; |
| 1554 | 2125 | $n = socket_select($read, $write, $e, $timeout); |
| 1555 | - if ($e != NULL) var_dump($e); |
|
| 2126 | + if ($e != NULL) { |
|
| 2127 | + var_dump($e); |
|
| 2128 | + } |
|
| 1556 | 2129 | if ($n > 0) { |
| 1557 | 2130 | $reset = 0; |
| 1558 | 2131 | foreach ($read as $nb => $r) { |
@@ -1574,13 +2147,17 @@ discard block |
||
| 1574 | 2147 | if ($buffer !== FALSE) { |
| 1575 | 2148 | if ($format === 'vrstcp') { |
| 1576 | 2149 | $buffer = explode('},{',$buffer); |
| 1577 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2150 | + } else { |
|
| 2151 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2152 | + } |
|
| 1578 | 2153 | } |
| 1579 | 2154 | // SBS format is CSV format |
| 1580 | 2155 | if ($buffer !== FALSE && $buffer !== '') { |
| 1581 | 2156 | $tt[$format] = 0; |
| 1582 | 2157 | if ($format === 'acarssbs3') { |
| 1583 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2158 | + if ($globalDebug) { |
|
| 2159 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2160 | + } |
|
| 1584 | 2161 | $ACARS->add(trim($buffer)); |
| 1585 | 2162 | $ACARS->deleteLiveAcarsData(); |
| 1586 | 2163 | } elseif ($format === 'raw') { |
@@ -1589,30 +2166,70 @@ discard block |
||
| 1589 | 2166 | if (is_array($data)) { |
| 1590 | 2167 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1591 | 2168 | $data['format_source'] = 'raw'; |
| 1592 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1593 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1594 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1595 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2169 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2170 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2171 | + } |
|
| 2172 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2173 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2174 | + } |
|
| 2175 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2176 | + $data['noarchive'] = true; |
|
| 2177 | + } |
|
| 2178 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2179 | + $SI->add($data); |
|
| 2180 | + } |
|
| 1596 | 2181 | } |
| 1597 | 2182 | } elseif ($format === 'ais') { |
| 1598 | 2183 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1599 | 2184 | $data = array(); |
| 1600 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1601 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1602 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1603 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1604 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1605 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1606 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1607 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1608 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1609 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1610 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1611 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1612 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1613 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1614 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1615 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2185 | + if (isset($ais_data['ident'])) { |
|
| 2186 | + $data['ident'] = $ais_data['ident']; |
|
| 2187 | + } |
|
| 2188 | + if (isset($ais_data['mmsi'])) { |
|
| 2189 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2190 | + } |
|
| 2191 | + if (isset($ais_data['speed'])) { |
|
| 2192 | + $data['speed'] = $ais_data['speed']; |
|
| 2193 | + } |
|
| 2194 | + if (isset($ais_data['heading'])) { |
|
| 2195 | + $data['heading'] = $ais_data['heading']; |
|
| 2196 | + } |
|
| 2197 | + if (isset($ais_data['latitude'])) { |
|
| 2198 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2199 | + } |
|
| 2200 | + if (isset($ais_data['longitude'])) { |
|
| 2201 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2202 | + } |
|
| 2203 | + if (isset($ais_data['status'])) { |
|
| 2204 | + $data['status'] = $ais_data['status']; |
|
| 2205 | + } |
|
| 2206 | + if (isset($ais_data['statusid'])) { |
|
| 2207 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2208 | + } |
|
| 2209 | + if (isset($ais_data['type'])) { |
|
| 2210 | + $data['type'] = $ais_data['type']; |
|
| 2211 | + } |
|
| 2212 | + if (isset($ais_data['imo'])) { |
|
| 2213 | + $data['imo'] = $ais_data['imo']; |
|
| 2214 | + } |
|
| 2215 | + if (isset($ais_data['callsign'])) { |
|
| 2216 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2217 | + } |
|
| 2218 | + if (isset($ais_data['destination'])) { |
|
| 2219 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2220 | + } |
|
| 2221 | + if (isset($ais_data['eta_ts'])) { |
|
| 2222 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2223 | + } |
|
| 2224 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2225 | + $data['noarchive'] = true; |
|
| 2226 | + } |
|
| 2227 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2228 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2229 | + } |
|
| 2230 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2231 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2232 | + } |
|
| 1616 | 2233 | |
| 1617 | 2234 | if (isset($ais_data['timestamp'])) { |
| 1618 | 2235 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1621,7 +2238,9 @@ discard block |
||
| 1621 | 2238 | } |
| 1622 | 2239 | $data['format_source'] = 'aisnmea'; |
| 1623 | 2240 | $data['id_source'] = $id_source; |
| 1624 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2241 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2242 | + $MI->add($data); |
|
| 2243 | + } |
|
| 1625 | 2244 | unset($data); |
| 1626 | 2245 | } elseif ($format === 'flightgearsp') { |
| 1627 | 2246 | //echo $buffer."\n"; |
@@ -1639,12 +2258,18 @@ discard block |
||
| 1639 | 2258 | $data['speed'] = round($line[5]*1.94384); |
| 1640 | 2259 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1641 | 2260 | $data['format_source'] = 'flightgearsp'; |
| 1642 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1643 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2261 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2262 | + $data['noarchive'] = true; |
|
| 2263 | + } |
|
| 2264 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2265 | + $SI->add($data); |
|
| 2266 | + } |
|
| 1644 | 2267 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1645 | 2268 | } |
| 1646 | 2269 | } elseif ($format === 'acars') { |
| 1647 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2270 | + if ($globalDebug) { |
|
| 2271 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2272 | + } |
|
| 1648 | 2273 | $ACARS->add(trim($buffer)); |
| 1649 | 2274 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1650 | 2275 | $ACARS->deleteLiveAcarsData(); |
@@ -1665,8 +2290,12 @@ discard block |
||
| 1665 | 2290 | $aircraft_type = $line[10]; |
| 1666 | 2291 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1667 | 2292 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1668 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1669 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2293 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2294 | + $data['noarchive'] = true; |
|
| 2295 | + } |
|
| 2296 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2297 | + $SI->add($data); |
|
| 2298 | + } |
|
| 1670 | 2299 | } |
| 1671 | 2300 | } |
| 1672 | 2301 | } elseif ($format === 'beast') { |
@@ -1676,28 +2305,62 @@ discard block |
||
| 1676 | 2305 | foreach($buffer as $all_data) { |
| 1677 | 2306 | $line = json_decode('{'.$all_data.'}',true); |
| 1678 | 2307 | $data = array(); |
| 1679 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1680 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1681 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1682 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1683 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1684 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1685 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2308 | + if (isset($line['Icao'])) { |
|
| 2309 | + $data['hex'] = $line['Icao']; |
|
| 2310 | + } |
|
| 2311 | + // hex |
|
| 2312 | + if (isset($line['Call'])) { |
|
| 2313 | + $data['ident'] = $line['Call']; |
|
| 2314 | + } |
|
| 2315 | + // ident |
|
| 2316 | + if (isset($line['Alt'])) { |
|
| 2317 | + $data['altitude'] = $line['Alt']; |
|
| 2318 | + } |
|
| 2319 | + // altitude |
|
| 2320 | + if (isset($line['Spd'])) { |
|
| 2321 | + $data['speed'] = $line['Spd']; |
|
| 2322 | + } |
|
| 2323 | + // speed |
|
| 2324 | + if (isset($line['Trak'])) { |
|
| 2325 | + $data['heading'] = $line['Trak']; |
|
| 2326 | + } |
|
| 2327 | + // heading |
|
| 2328 | + if (isset($line['Lat'])) { |
|
| 2329 | + $data['latitude'] = $line['Lat']; |
|
| 2330 | + } |
|
| 2331 | + // lat |
|
| 2332 | + if (isset($line['Long'])) { |
|
| 2333 | + $data['longitude'] = $line['Long']; |
|
| 2334 | + } |
|
| 2335 | + // long |
|
| 1686 | 2336 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1687 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2337 | + if (isset($line['Sqk'])) { |
|
| 2338 | + $data['squawk'] = $line['Sqk']; |
|
| 2339 | + } |
|
| 2340 | + // squawk |
|
| 1688 | 2341 | $data['emergency'] = ''; // emergency |
| 1689 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2342 | + if (isset($line['Reg'])) { |
|
| 2343 | + $data['registration'] = $line['Reg']; |
|
| 2344 | + } |
|
| 1690 | 2345 | /* |
| 1691 | 2346 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1692 | 2347 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1693 | 2348 | */ |
| 1694 | 2349 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1695 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2350 | + if (isset($line['Type'])) { |
|
| 2351 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2352 | + } |
|
| 1696 | 2353 | $data['format_source'] = 'vrstcp'; |
| 1697 | 2354 | $data['id_source'] = $id_source; |
| 1698 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1699 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1700 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2355 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2356 | + $data['noarchive'] = true; |
|
| 2357 | + } |
|
| 2358 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2359 | + $data['source_name'] = $value['name']; |
|
| 2360 | + } |
|
| 2361 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2362 | + $SI->add($data); |
|
| 2363 | + } |
|
| 1701 | 2364 | unset($data); |
| 1702 | 2365 | } |
| 1703 | 2366 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1710,22 +2373,46 @@ discard block |
||
| 1710 | 2373 | $data['hex'] = $lined['hexid']; |
| 1711 | 2374 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1712 | 2375 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1713 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1714 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1715 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1716 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1717 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1718 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1719 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2376 | + if (isset($lined['ident'])) { |
|
| 2377 | + $data['ident'] = $lined['ident']; |
|
| 2378 | + } |
|
| 2379 | + if (isset($lined['lat'])) { |
|
| 2380 | + $data['latitude'] = $lined['lat']; |
|
| 2381 | + } |
|
| 2382 | + if (isset($lined['lon'])) { |
|
| 2383 | + $data['longitude'] = $lined['lon']; |
|
| 2384 | + } |
|
| 2385 | + if (isset($lined['speed'])) { |
|
| 2386 | + $data['speed'] = $lined['speed']; |
|
| 2387 | + } |
|
| 2388 | + if (isset($lined['squawk'])) { |
|
| 2389 | + $data['squawk'] = $lined['squawk']; |
|
| 2390 | + } |
|
| 2391 | + if (isset($lined['alt'])) { |
|
| 2392 | + $data['altitude'] = $lined['alt']; |
|
| 2393 | + } |
|
| 2394 | + if (isset($lined['heading'])) { |
|
| 2395 | + $data['heading'] = $lined['heading']; |
|
| 2396 | + } |
|
| 1720 | 2397 | $data['id_source'] = $id_source; |
| 1721 | 2398 | $data['format_source'] = 'tsv'; |
| 1722 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1723 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1724 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1725 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2399 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2400 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2401 | + } |
|
| 2402 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2403 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2404 | + } |
|
| 2405 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2406 | + $data['noarchive'] = true; |
|
| 2407 | + } |
|
| 2408 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2409 | + $SI->add($data); |
|
| 2410 | + } |
|
| 1726 | 2411 | unset($lined); |
| 1727 | 2412 | unset($data); |
| 1728 | - } else $error = true; |
|
| 2413 | + } else { |
|
| 2414 | + $error = true; |
|
| 2415 | + } |
|
| 1729 | 2416 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1730 | 2417 | if ($aprs_connect === 0) { |
| 1731 | 2418 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1751,47 +2438,96 @@ discard block |
||
| 1751 | 2438 | $aprs_last_tx = time(); |
| 1752 | 2439 | $data = array(); |
| 1753 | 2440 | //print_r($line); |
| 1754 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1755 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1756 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1757 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1758 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1759 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1760 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1761 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1762 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1763 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2441 | + if (isset($line['address'])) { |
|
| 2442 | + $data['hex'] = $line['address']; |
|
| 2443 | + } |
|
| 2444 | + if (isset($line['mmsi'])) { |
|
| 2445 | + $data['mmsi'] = $line['mmsi']; |
|
| 2446 | + } |
|
| 2447 | + if (isset($line['imo'])) { |
|
| 2448 | + $data['imo'] = $line['imo']; |
|
| 2449 | + } |
|
| 2450 | + if (isset($line['squawk'])) { |
|
| 2451 | + $data['squawk'] = $line['squawk']; |
|
| 2452 | + } |
|
| 2453 | + if (isset($line['arrival_code'])) { |
|
| 2454 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2455 | + } |
|
| 2456 | + if (isset($line['arrival_date'])) { |
|
| 2457 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2458 | + } |
|
| 2459 | + if (isset($line['typeid'])) { |
|
| 2460 | + $data['type_id'] = $line['typeid']; |
|
| 2461 | + } |
|
| 2462 | + if (isset($line['statusid'])) { |
|
| 2463 | + $data['status_id'] = $line['statusid']; |
|
| 2464 | + } |
|
| 2465 | + if (isset($line['timestamp'])) { |
|
| 2466 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2467 | + } else { |
|
| 2468 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2469 | + } |
|
| 1764 | 2470 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1765 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2471 | + if (isset($line['ident'])) { |
|
| 2472 | + $data['ident'] = $line['ident']; |
|
| 2473 | + } |
|
| 1766 | 2474 | $data['latitude'] = $line['latitude']; |
| 1767 | 2475 | $data['longitude'] = $line['longitude']; |
| 1768 | 2476 | //$data['verticalrate'] = $line[16]; |
| 1769 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2477 | + if (isset($line['speed'])) { |
|
| 2478 | + $data['speed'] = $line['speed']; |
|
| 2479 | + } |
|
| 1770 | 2480 | //else $data['speed'] = 0; |
| 1771 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1772 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1773 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2481 | + if (isset($line['altitude'])) { |
|
| 2482 | + $data['altitude'] = $line['altitude']; |
|
| 2483 | + } |
|
| 2484 | + if (isset($line['comment'])) { |
|
| 2485 | + $data['comment'] = $line['comment']; |
|
| 2486 | + } |
|
| 2487 | + if (isset($line['symbol'])) { |
|
| 2488 | + $data['type'] = $line['symbol']; |
|
| 2489 | + } |
|
| 1774 | 2490 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1775 | 2491 | |
| 1776 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2492 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2493 | + $data['heading'] = $line['heading']; |
|
| 2494 | + } |
|
| 1777 | 2495 | //else echo 'No heading...'."\n"; |
| 1778 | 2496 | //else $data['heading'] = 0; |
| 1779 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2497 | + if (isset($line['stealth'])) { |
|
| 2498 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2499 | + } |
|
| 1780 | 2500 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1781 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1782 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1783 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1784 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2501 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2502 | + $data['noarchive'] = true; |
|
| 2503 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2504 | + $data['noarchive'] = false; |
|
| 2505 | + } |
|
| 2506 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2507 | + $data['noarchive'] = true; |
|
| 2508 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2509 | + $data['noarchive'] = false; |
|
| 2510 | + } |
|
| 1785 | 2511 | $data['id_source'] = $id_source; |
| 1786 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1787 | - else $data['format_source'] = 'aprs'; |
|
| 2512 | + if (isset($line['format_source'])) { |
|
| 2513 | + $data['format_source'] = $line['format_source']; |
|
| 2514 | + } else { |
|
| 2515 | + $data['format_source'] = 'aprs'; |
|
| 2516 | + } |
|
| 1788 | 2517 | $data['source_name'] = $line['source']; |
| 1789 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1790 | - else $data['source_type'] = 'flarm'; |
|
| 1791 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2518 | + if (isset($line['source_type'])) { |
|
| 2519 | + $data['source_type'] = $line['source_type']; |
|
| 2520 | + } else { |
|
| 2521 | + $data['source_type'] = 'flarm'; |
|
| 2522 | + } |
|
| 2523 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2524 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2525 | + } |
|
| 1792 | 2526 | $currentdate = date('Y-m-d H:i:s'); |
| 1793 | 2527 | $aprsdate = strtotime($data['datetime']); |
| 1794 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2528 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2529 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2530 | + } |
|
| 1795 | 2531 | // Accept data if time <= system time + 20s |
| 1796 | 2532 | //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1797 | 2533 | if ( |
@@ -1803,7 +2539,9 @@ discard block |
||
| 1803 | 2539 | $send = $SI->add($data); |
| 1804 | 2540 | } elseif ($data['source_type'] === 'ais') { |
| 1805 | 2541 | $data['type'] = ''; |
| 1806 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2542 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2543 | + $send = $MI->add($data); |
|
| 2544 | + } |
|
| 1807 | 2545 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1808 | 2546 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1809 | 2547 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1811,8 +2549,12 @@ discard block |
||
| 1811 | 2549 | $line['symbol'] === 'Glider' || |
| 1812 | 2550 | $line['symbol'] === 'No. Plane' || |
| 1813 | 2551 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1814 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1815 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2552 | + if ($line['symbol'] === 'Ballon') { |
|
| 2553 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2554 | + } |
|
| 2555 | + if ($line['symbol'] === 'Glider') { |
|
| 2556 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2557 | + } |
|
| 1816 | 2558 | $send = $SI->add($data); |
| 1817 | 2559 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1818 | 2560 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1843,9 +2585,13 @@ discard block |
||
| 1843 | 2585 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1844 | 2586 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 1845 | 2587 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1846 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2588 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2589 | + $send = $TI->add($data); |
|
| 2590 | + } |
|
| 1847 | 2591 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1848 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2592 | + if (!isset($data['altitude'])) { |
|
| 2593 | + $data['altitude'] = 0; |
|
| 2594 | + } |
|
| 1849 | 2595 | $Source->deleteOldLocationByType('gs'); |
| 1850 | 2596 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1851 | 2597 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1854,7 +2600,9 @@ discard block |
||
| 1854 | 2600 | } |
| 1855 | 2601 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1856 | 2602 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1857 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2603 | + if ($globalDebug) { |
|
| 2604 | + echo '# Weather Station added'."\n"; |
|
| 2605 | + } |
|
| 1858 | 2606 | $Source->deleteOldLocationByType('wx'); |
| 1859 | 2607 | $weather_data = json_encode($line); |
| 1860 | 2608 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1864,7 +2612,9 @@ discard block |
||
| 1864 | 2612 | } |
| 1865 | 2613 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1866 | 2614 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1867 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2615 | + if ($globalDebug) { |
|
| 2616 | + echo '☈ Lightning added'."\n"; |
|
| 2617 | + } |
|
| 1868 | 2618 | $Source->deleteOldLocationByType('lightning'); |
| 1869 | 2619 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1870 | 2620 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1876,8 +2626,7 @@ discard block |
||
| 1876 | 2626 | print_r($line); |
| 1877 | 2627 | } |
| 1878 | 2628 | unset($data); |
| 1879 | - } |
|
| 1880 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2629 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1881 | 2630 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1882 | 2631 | } |
| 1883 | 2632 | /* |
@@ -1886,7 +2635,9 @@ discard block |
||
| 1886 | 2635 | } |
| 1887 | 2636 | */ |
| 1888 | 2637 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1889 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2638 | + elseif ($line === true && $globalDebug) { |
|
| 2639 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2640 | + } |
|
| 1890 | 2641 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 1891 | 2642 | $Source->deleteOldLocationByType('lightning'); |
| 1892 | 2643 | $Source->deleteOldLocationByType('wx'); |
@@ -1922,27 +2673,47 @@ discard block |
||
| 1922 | 2673 | $data['ground'] = $line[21]; |
| 1923 | 2674 | $data['emergency'] = $line[19]; |
| 1924 | 2675 | $data['format_source'] = 'sbs'; |
| 1925 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1926 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 1927 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1928 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2676 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2677 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2678 | + } elseif ($line[0] == 'MLAT') { |
|
| 2679 | + $data['source_name'] = 'MLAT'; |
|
| 2680 | + } |
|
| 2681 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2682 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2683 | + } |
|
| 2684 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2685 | + $data['noarchive'] = true; |
|
| 2686 | + } |
|
| 1929 | 2687 | $data['id_source'] = $id_source; |
| 1930 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1931 | - else $error = true; |
|
| 2688 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2689 | + $send = $SI->add($data); |
|
| 2690 | + } else { |
|
| 2691 | + $error = true; |
|
| 2692 | + } |
|
| 1932 | 2693 | unset($data); |
| 1933 | - } else $error = true; |
|
| 2694 | + } else { |
|
| 2695 | + $error = true; |
|
| 2696 | + } |
|
| 1934 | 2697 | if ($error) { |
| 1935 | 2698 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 1936 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2699 | + if ($globalDebug) { |
|
| 2700 | + echo "Not a message. Ignoring... \n"; |
|
| 2701 | + } |
|
| 1937 | 2702 | } else { |
| 1938 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2703 | + if ($globalDebug) { |
|
| 2704 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2705 | + } |
|
| 1939 | 2706 | if ($globalDebug) { |
| 1940 | 2707 | echo $buffer; |
| 1941 | 2708 | //print_r($line); |
| 1942 | 2709 | } |
| 1943 | 2710 | //socket_close($r); |
| 1944 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1945 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo "Reconnect after an error...\n"; |
|
| 2713 | + } |
|
| 2714 | + if ($format === 'aprs') { |
|
| 2715 | + $aprs_connect = 0; |
|
| 2716 | + } |
|
| 1946 | 2717 | $sourceer[$nb] = $globalSources[$nb]; |
| 1947 | 2718 | connect_all($sourceer); |
| 1948 | 2719 | $sourceer = array(); |
@@ -1950,10 +2721,14 @@ discard block |
||
| 1950 | 2721 | } |
| 1951 | 2722 | } |
| 1952 | 2723 | // Sleep for xxx microseconds |
| 1953 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2724 | + if (isset($globalSBSSleep)) { |
|
| 2725 | + usleep($globalSBSSleep); |
|
| 2726 | + } |
|
| 1954 | 2727 | } else { |
| 1955 | 2728 | if ($format === 'flightgearmp') { |
| 1956 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2729 | + if ($globalDebug) { |
|
| 2730 | + echo "Reconnect FlightGear MP..."; |
|
| 2731 | + } |
|
| 1957 | 2732 | //@socket_close($r); |
| 1958 | 2733 | sleep($globalMinFetch); |
| 1959 | 2734 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1962,10 +2737,15 @@ discard block |
||
| 1962 | 2737 | break; |
| 1963 | 2738 | |
| 1964 | 2739 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1965 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1966 | - else $tt[$format] = 0; |
|
| 2740 | + if (isset($tt[$format])) { |
|
| 2741 | + $tt[$format]++; |
|
| 2742 | + } else { |
|
| 2743 | + $tt[$format] = 0; |
|
| 2744 | + } |
|
| 1967 | 2745 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 1968 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2746 | + if ($globalDebug) { |
|
| 2747 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2748 | + } |
|
| 1969 | 2749 | //@socket_close($r); |
| 1970 | 2750 | sleep(2); |
| 1971 | 2751 | $aprs_connect = 0; |
@@ -1983,11 +2763,17 @@ discard block |
||
| 1983 | 2763 | } else { |
| 1984 | 2764 | $error = socket_strerror(socket_last_error()); |
| 1985 | 2765 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1986 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1987 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2766 | + if ($globalDebug) { |
|
| 2767 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2768 | + } |
|
| 2769 | + if (isset($globalDebug)) { |
|
| 2770 | + echo "Restarting...\n"; |
|
| 2771 | + } |
|
| 1988 | 2772 | // Restart the script if possible |
| 1989 | 2773 | if (is_array($sockets)) { |
| 1990 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2774 | + if ($globalDebug) { |
|
| 2775 | + echo "Shutdown all sockets..."; |
|
| 2776 | + } |
|
| 1991 | 2777 | |
| 1992 | 2778 | foreach ($sockets as $sock) { |
| 1993 | 2779 | @socket_shutdown($sock,2); |
@@ -1995,25 +2781,45 @@ discard block |
||
| 1995 | 2781 | } |
| 1996 | 2782 | |
| 1997 | 2783 | } |
| 1998 | - if ($globalDebug) echo "Waiting..."; |
|
| 2784 | + if ($globalDebug) { |
|
| 2785 | + echo "Waiting..."; |
|
| 2786 | + } |
|
| 1999 | 2787 | sleep(2); |
| 2000 | 2788 | $time = time(); |
| 2001 | 2789 | //connect_all($hosts); |
| 2002 | 2790 | $aprs_connect = 0; |
| 2003 | - if ($reset%5 === 0) sleep(20); |
|
| 2004 | - if ($reset%10 === 0) sleep(100); |
|
| 2005 | - if ($reset%20 === 0) sleep(200); |
|
| 2006 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2007 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2791 | + if ($reset%5 === 0) { |
|
| 2792 | + sleep(20); |
|
| 2793 | + } |
|
| 2794 | + if ($reset%10 === 0) { |
|
| 2795 | + sleep(100); |
|
| 2796 | + } |
|
| 2797 | + if ($reset%20 === 0) { |
|
| 2798 | + sleep(200); |
|
| 2799 | + } |
|
| 2800 | + if ($reset > 100) { |
|
| 2801 | + exit('Too many attempts...'); |
|
| 2802 | + } |
|
| 2803 | + if ($globalDebug) { |
|
| 2804 | + echo "Restart all connections..."; |
|
| 2805 | + } |
|
| 2008 | 2806 | connect_all($globalSources); |
| 2009 | 2807 | } |
| 2010 | 2808 | } |
| 2011 | 2809 | } |
| 2012 | 2810 | if ($globalDaemon === false) { |
| 2013 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2014 | - if (isset($SI)) $SI->checkAll(); |
|
| 2015 | - if (isset($TI)) $TI->checkAll(); |
|
| 2016 | - if (isset($MI)) $MI->checkAll(); |
|
| 2811 | + if ($globalDebug) { |
|
| 2812 | + echo 'Check all...'."\n"; |
|
| 2813 | + } |
|
| 2814 | + if (isset($SI)) { |
|
| 2815 | + $SI->checkAll(); |
|
| 2816 | + } |
|
| 2817 | + if (isset($TI)) { |
|
| 2818 | + $TI->checkAll(); |
|
| 2819 | + } |
|
| 2820 | + if (isset($MI)) { |
|
| 2821 | + $MI->checkAll(); |
|
| 2822 | + } |
|
| 2017 | 2823 | } |
| 2018 | 2824 | } |
| 2019 | 2825 | } |
@@ -7,8 +7,10 @@ discard block |
||
| 7 | 7 | $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
| 8 | 8 | if (isset($globalVM) && $globalVM) { |
| 9 | 9 | $showDuration = $Common->multiKeyExists($spotter_array,'race_time'); |
| 10 | - if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 11 | -} else { |
|
| 10 | + if ($showDuration === false) { |
|
| 11 | + $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 12 | + } |
|
| 13 | + } else { |
|
| 12 | 14 | $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
| 13 | 15 | } |
| 14 | 16 | if (isset($globalVM) && $globalVM) { |
@@ -16,7 +18,9 @@ discard block |
||
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | |
| 19 | -if (!isset($type)) $type = 'aircraft'; |
|
| 21 | +if (!isset($type)) { |
|
| 22 | + $type = 'aircraft'; |
|
| 23 | +} |
|
| 20 | 24 | |
| 21 | 25 | if (!isset($_GET['sort'])) |
| 22 | 26 | { |
@@ -589,7 +593,9 @@ discard block |
||
| 589 | 593 | if (isset($globalTimezone)) |
| 590 | 594 | { |
| 591 | 595 | date_default_timezone_set($globalTimezone); |
| 592 | - } else date_default_timezone_set('UTC'); |
|
| 596 | + } else { |
|
| 597 | + date_default_timezone_set('UTC'); |
|
| 598 | + } |
|
| 593 | 599 | if ($showSpecial === true) |
| 594 | 600 | { |
| 595 | 601 | print '<tr class="special">'."\n"; |
@@ -604,7 +610,9 @@ discard block |
||
| 604 | 610 | print '<tr class="active">'; |
| 605 | 611 | } elseif (isset($spotter_item['spotted_registration'])) { |
| 606 | 612 | print '<tr class="info">'; |
| 607 | - } else print '<tr>'; |
|
| 613 | + } else { |
|
| 614 | + print '<tr>'; |
|
| 615 | + } |
|
| 608 | 616 | } |
| 609 | 617 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") { |
| 610 | 618 | if ($type == 'aircraft') { |
@@ -612,8 +620,9 @@ discard block |
||
| 612 | 620 | { |
| 613 | 621 | print '<td class="aircraft_thumbnail">'."\n"; |
| 614 | 622 | if ($spotter_item['image_source'] == 'planespotters') { |
| 615 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 616 | - else { |
|
| 623 | + if ($spotter_item['image_source_website'] != '') { |
|
| 624 | + $image_src = $spotter_item['image_source_website']; |
|
| 625 | + } else { |
|
| 617 | 626 | $planespotter_url_array = explode("_", $spotter_item['image']); |
| 618 | 627 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 619 | 628 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -626,7 +635,9 @@ discard block |
||
| 626 | 635 | } else { |
| 627 | 636 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 628 | 637 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 629 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 638 | + } else { |
|
| 639 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 640 | + } |
|
| 630 | 641 | if (isset($spotter_item['airline_name'])) { |
| 631 | 642 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 632 | 643 | } else { |
@@ -652,7 +663,9 @@ discard block |
||
| 652 | 663 | print '<td class="aircraft_thumbnail">'."\n"; |
| 653 | 664 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 654 | 665 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 655 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 666 | + } else { |
|
| 667 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 668 | + } |
|
| 656 | 669 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 657 | 670 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 658 | 671 | } else { |
@@ -674,7 +687,9 @@ discard block |
||
| 674 | 687 | print '<td class="aircraft_thumbnail">'."\n"; |
| 675 | 688 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 676 | 689 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 677 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 690 | + } else { |
|
| 691 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 692 | + } |
|
| 678 | 693 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 679 | 694 | print '</td>'."\n"; |
| 680 | 695 | } else { |
@@ -727,8 +742,9 @@ discard block |
||
| 727 | 742 | print '<td class="aircraft_thumbnail">'."\n"; |
| 728 | 743 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
| 729 | 744 | if ($spotter_item['image_source'] == 'planespotters') { |
| 730 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 731 | - else { |
|
| 745 | + if ($spotter_item['image_source_website'] != '') { |
|
| 746 | + $image_src = $spotter_item['image_source_website']; |
|
| 747 | + } else { |
|
| 732 | 748 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
| 733 | 749 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 734 | 750 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -745,7 +761,9 @@ discard block |
||
| 745 | 761 | } else { |
| 746 | 762 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 747 | 763 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 748 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 764 | + } else { |
|
| 765 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 766 | + } |
|
| 749 | 767 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
| 750 | 768 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 751 | 769 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -785,7 +803,9 @@ discard block |
||
| 785 | 803 | print '<td class="aircraft_thumbnail">'."\n"; |
| 786 | 804 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 787 | 805 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 788 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 806 | + } else { |
|
| 807 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 808 | + } |
|
| 789 | 809 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 790 | 810 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 791 | 811 | } else { |
@@ -807,7 +827,9 @@ discard block |
||
| 807 | 827 | print '<td class="aircraft_thumbnail">'."\n"; |
| 808 | 828 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 809 | 829 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 810 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 830 | + } else { |
|
| 831 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 832 | + } |
|
| 811 | 833 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 812 | 834 | print '</td>'."\n"; |
| 813 | 835 | } else { |
@@ -925,8 +947,11 @@ discard block |
||
| 925 | 947 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 926 | 948 | } else { |
| 927 | 949 | $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
| 928 | - if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 929 | - else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 950 | + if (count($aircraft_names) == 1) { |
|
| 951 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 952 | + } else { |
|
| 953 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 954 | + } |
|
| 930 | 955 | } |
| 931 | 956 | print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 932 | 957 | } elseif ($type == 'marine') { |
@@ -969,15 +994,21 @@ discard block |
||
| 969 | 994 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
| 970 | 995 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 971 | 996 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
| 972 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 997 | + } else { |
|
| 998 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 999 | + } |
|
| 973 | 1000 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 974 | 1001 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 975 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1002 | + } else { |
|
| 1003 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1004 | + } |
|
| 976 | 1005 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
| 977 | 1006 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
| 978 | 1007 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 979 | 1008 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 980 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1009 | + } else { |
|
| 1010 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1011 | + } |
|
| 981 | 1012 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
| 982 | 1013 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
| 983 | 1014 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -999,7 +1030,9 @@ discard block |
||
| 999 | 1030 | $longitude = $spotter_item['longitude']; |
| 1000 | 1031 | } |
| 1001 | 1032 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
| 1002 | - } else $distance = ''; |
|
| 1033 | + } else { |
|
| 1034 | + $distance = ''; |
|
| 1035 | + } |
|
| 1003 | 1036 | if ($distance != '') { |
| 1004 | 1037 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1005 | 1038 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -1026,7 +1059,9 @@ discard block |
||
| 1026 | 1059 | } else { |
| 1027 | 1060 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
| 1028 | 1061 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
| 1029 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
| 1062 | + if (!isset($Spotter)) { |
|
| 1063 | + $Spotter = new Spotter(); |
|
| 1064 | + } |
|
| 1030 | 1065 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
| 1031 | 1066 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
| 1032 | 1067 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -1042,20 +1077,28 @@ discard block |
||
| 1042 | 1077 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
| 1043 | 1078 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1044 | 1079 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 1045 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1080 | + } else { |
|
| 1081 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1082 | + } |
|
| 1046 | 1083 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1047 | 1084 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 1048 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1085 | + } else { |
|
| 1086 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1087 | + } |
|
| 1049 | 1088 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
| 1050 | 1089 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
| 1051 | 1090 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1052 | 1091 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 1053 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1092 | + } else { |
|
| 1093 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1094 | + } |
|
| 1054 | 1095 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
| 1055 | 1096 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
| 1056 | 1097 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1057 | 1098 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 1058 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1099 | + } else { |
|
| 1100 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1101 | + } |
|
| 1059 | 1102 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
| 1060 | 1103 | } |
| 1061 | 1104 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -1068,7 +1111,9 @@ discard block |
||
| 1068 | 1111 | $longitude = $spotter_item['longitude']; |
| 1069 | 1112 | } |
| 1070 | 1113 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
| 1071 | - } else $distance = ''; |
|
| 1114 | + } else { |
|
| 1115 | + $distance = ''; |
|
| 1116 | + } |
|
| 1072 | 1117 | if ($distance != '') { |
| 1073 | 1118 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1074 | 1119 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |