@@ -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) { |
@@ -72,8 +76,11 @@ discard block |
||
| 72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 73 | 77 | } |
| 74 | 78 | } |
| 75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 79 | + if ($filter_query_where == '' && $where) { |
|
| 80 | + $filter_query_where = ' WHERE'; |
|
| 81 | + } elseif ($filter_query_where != '' && $and) { |
|
| 82 | + $filter_query_where .= ' AND'; |
|
| 83 | + } |
|
| 77 | 84 | if ($filter_query_where != '') { |
| 78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 79 | 86 | } |
@@ -127,32 +134,54 @@ discard block |
||
| 127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 130 | - */} |
|
| 131 | - elseif (isset($row['marineid'])) { |
|
| 137 | + */} elseif (isset($row['marineid'])) { |
|
| 132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
| 133 | 139 | } else { |
| 134 | 140 | $temp_array['marine_id'] = ''; |
| 135 | 141 | } |
| 136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 140 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 141 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 142 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 143 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 142 | + if (isset($row['fammarine_id'])) { |
|
| 143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['mmsi'])) { |
|
| 146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['type'])) { |
|
| 149 | + $temp_array['type'] = $row['type']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['type_id'])) { |
|
| 152 | + $temp_array['type_id'] = $row['type_id']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['ident'])) { |
|
| 155 | + $temp_array['ident'] = $row['ident']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['latitude'])) { |
|
| 158 | + $temp_array['latitude'] = $row['latitude']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['longitude'])) { |
|
| 161 | + $temp_array['longitude'] = $row['longitude']; |
|
| 162 | + } |
|
| 163 | + if (isset($row['format_source'])) { |
|
| 164 | + $temp_array['format_source'] = $row['format_source']; |
|
| 165 | + } |
|
| 144 | 166 | if (isset($row['heading'])) { |
| 145 | 167 | $temp_array['heading'] = $row['heading']; |
| 146 | 168 | $heading_direction = $this->parseDirection($row['heading']); |
| 147 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 169 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + if (isset($row['ground_speed'])) { |
|
| 174 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 148 | 175 | } |
| 149 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 150 | 176 | |
| 151 | 177 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 152 | 178 | { |
| 153 | 179 | $Image = new Image($this->db); |
| 154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 155 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 180 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 181 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 182 | + } else { |
|
| 183 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 184 | + } |
|
| 156 | 185 | unset($Image); |
| 157 | 186 | if (count($image_array) > 0) { |
| 158 | 187 | $temp_array['image'] = $image_array[0]['image']; |
@@ -204,13 +233,21 @@ discard block |
||
| 204 | 233 | } |
| 205 | 234 | |
| 206 | 235 | $fromsource = NULL; |
| 207 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 208 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 209 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 236 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 237 | + $temp_array['source_name'] = $row['source_name']; |
|
| 238 | + } |
|
| 239 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 240 | + $temp_array['over_country'] = $row['over_country']; |
|
| 241 | + } |
|
| 242 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 243 | + $temp_array['distance'] = $row['distance']; |
|
| 244 | + } |
|
| 210 | 245 | $temp_array['query_number_rows'] = $num_rows; |
| 211 | 246 | $spotter_array[] = $temp_array; |
| 212 | 247 | } |
| 213 | - if ($num_rows == 0) return array(); |
|
| 248 | + if ($num_rows == 0) { |
|
| 249 | + return array(); |
|
| 250 | + } |
|
| 214 | 251 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 215 | 252 | return $spotter_array; |
| 216 | 253 | } |
@@ -236,8 +273,12 @@ discard block |
||
| 236 | 273 | { |
| 237 | 274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 238 | 275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 239 | - } else $limit_query = ""; |
|
| 240 | - } else $limit_query = ""; |
|
| 276 | + } else { |
|
| 277 | + $limit_query = ""; |
|
| 278 | + } |
|
| 279 | + } else { |
|
| 280 | + $limit_query = ""; |
|
| 281 | + } |
|
| 241 | 282 | if ($sort != "") |
| 242 | 283 | { |
| 243 | 284 | $search_orderby_array = $this->getOrderBy(); |
@@ -261,7 +302,9 @@ discard block |
||
| 261 | 302 | global $global_query; |
| 262 | 303 | |
| 263 | 304 | date_default_timezone_set('UTC'); |
| 264 | - if ($id == '') return array(); |
|
| 305 | + if ($id == '') { |
|
| 306 | + return array(); |
|
| 307 | + } |
|
| 265 | 308 | $additional_query = "marine_output.fammarine_id = :id"; |
| 266 | 309 | $query_values = array(':id' => $id); |
| 267 | 310 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -404,8 +447,11 @@ discard block |
||
| 404 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 405 | 448 | |
| 406 | 449 | $sth = $this->db->prepare($query); |
| 407 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 408 | - else $sth->execute(); |
|
| 450 | + if (!empty($query_values)) { |
|
| 451 | + $sth->execute($query_values); |
|
| 452 | + } else { |
|
| 453 | + $sth->execute(); |
|
| 454 | + } |
|
| 409 | 455 | |
| 410 | 456 | $source_array = array(); |
| 411 | 457 | $temp_array = array(); |
@@ -460,8 +506,11 @@ discard block |
||
| 460 | 506 | $sth = $this->db->prepare($query); |
| 461 | 507 | $sth->execute(array(':mmsi' => $mmsi)); |
| 462 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 463 | - if (isset($result[0])) return $result[0]; |
|
| 464 | - else return array(); |
|
| 509 | + if (isset($result[0])) { |
|
| 510 | + return $result[0]; |
|
| 511 | + } else { |
|
| 512 | + return array(); |
|
| 513 | + } |
|
| 465 | 514 | } |
| 466 | 515 | |
| 467 | 516 | /** |
@@ -502,7 +551,9 @@ discard block |
||
| 502 | 551 | date_default_timezone_set($globalTimezone); |
| 503 | 552 | $datetime = new DateTime(); |
| 504 | 553 | $offset = $datetime->format('P'); |
| 505 | - } else $offset = '+00:00'; |
|
| 554 | + } else { |
|
| 555 | + $offset = '+00:00'; |
|
| 556 | + } |
|
| 506 | 557 | |
| 507 | 558 | if ($globalDBdriver == 'mysql') { |
| 508 | 559 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -725,9 +776,15 @@ discard block |
||
| 725 | 776 | $latitude = 0; |
| 726 | 777 | $longitude = 0; |
| 727 | 778 | } |
| 728 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 729 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 730 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 779 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 780 | + $heading = 0; |
|
| 781 | + } |
|
| 782 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 783 | + $groundspeed = 0; |
|
| 784 | + } |
|
| 785 | + if ($arrival_date == '') { |
|
| 786 | + $arrival_date = NULL; |
|
| 787 | + } |
|
| 731 | 788 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 732 | 789 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 733 | 790 | |
@@ -834,7 +891,9 @@ discard block |
||
| 834 | 891 | global $globalDBdriver, $globalArchive; |
| 835 | 892 | //$filter_query = $this->getFilter($filters,true,true); |
| 836 | 893 | $Connection= new Connection($this->db); |
| 837 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 894 | + if (!$Connection->tableExists('countries')) { |
|
| 895 | + return array(); |
|
| 896 | + } |
|
| 838 | 897 | require_once('class.SpotterLive.php'); |
| 839 | 898 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 840 | 899 | $MarineLive = new MarineLive($this->db); |
@@ -878,7 +937,9 @@ discard block |
||
| 878 | 937 | $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 "; |
| 879 | 938 | } |
| 880 | 939 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 881 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 940 | + if ($limit) { |
|
| 941 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 942 | + } |
|
| 882 | 943 | |
| 883 | 944 | $sth = $this->db->prepare($query); |
| 884 | 945 | $sth->execute(); |
@@ -912,12 +973,18 @@ discard block |
||
| 912 | 973 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 913 | 974 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 914 | 975 | if ($olderthanmonths > 0) { |
| 915 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 916 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 976 | + if ($globalDBdriver == 'mysql') { |
|
| 977 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 978 | + } else { |
|
| 979 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 980 | + } |
|
| 917 | 981 | } |
| 918 | 982 | if ($sincedate != '') { |
| 919 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 920 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 983 | + if ($globalDBdriver == 'mysql') { |
|
| 984 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 985 | + } else { |
|
| 986 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 987 | + } |
|
| 921 | 988 | } |
| 922 | 989 | $query_values = array(); |
| 923 | 990 | if ($year != '') { |
@@ -948,7 +1015,9 @@ discard block |
||
| 948 | 1015 | } |
| 949 | 1016 | } |
| 950 | 1017 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 951 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1018 | + if ($limit) { |
|
| 1019 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1020 | + } |
|
| 952 | 1021 | |
| 953 | 1022 | $sth = $this->db->prepare($query); |
| 954 | 1023 | $sth->execute($query_values); |
@@ -983,7 +1052,9 @@ discard block |
||
| 983 | 1052 | date_default_timezone_set($globalTimezone); |
| 984 | 1053 | $datetime = new DateTime(); |
| 985 | 1054 | $offset = $datetime->format('P'); |
| 986 | - } else $offset = '+00:00'; |
|
| 1055 | + } else { |
|
| 1056 | + $offset = '+00:00'; |
|
| 1057 | + } |
|
| 987 | 1058 | |
| 988 | 1059 | if ($globalDBdriver == 'mysql') { |
| 989 | 1060 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1033,7 +1104,9 @@ discard block |
||
| 1033 | 1104 | date_default_timezone_set($globalTimezone); |
| 1034 | 1105 | $datetime = new DateTime(); |
| 1035 | 1106 | $offset = $datetime->format('P'); |
| 1036 | - } else $offset = '+00:00'; |
|
| 1107 | + } else { |
|
| 1108 | + $offset = '+00:00'; |
|
| 1109 | + } |
|
| 1037 | 1110 | $filter_query = $this->getFilter($filters,true,true); |
| 1038 | 1111 | if ($globalDBdriver == 'mysql') { |
| 1039 | 1112 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1079,7 +1152,9 @@ discard block |
||
| 1079 | 1152 | date_default_timezone_set($globalTimezone); |
| 1080 | 1153 | $datetime = new DateTime(); |
| 1081 | 1154 | $offset = $datetime->format('P'); |
| 1082 | - } else $offset = '+00:00'; |
|
| 1155 | + } else { |
|
| 1156 | + $offset = '+00:00'; |
|
| 1157 | + } |
|
| 1083 | 1158 | $filter_query = $this->getFilter($filters,true,true); |
| 1084 | 1159 | if ($globalDBdriver == 'mysql') { |
| 1085 | 1160 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1127,7 +1202,9 @@ discard block |
||
| 1127 | 1202 | date_default_timezone_set($globalTimezone); |
| 1128 | 1203 | $datetime = new DateTime(); |
| 1129 | 1204 | $offset = $datetime->format('P'); |
| 1130 | - } else $offset = '+00:00'; |
|
| 1205 | + } else { |
|
| 1206 | + $offset = '+00:00'; |
|
| 1207 | + } |
|
| 1131 | 1208 | |
| 1132 | 1209 | if ($globalDBdriver == 'mysql') { |
| 1133 | 1210 | $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 |
@@ -1176,7 +1253,9 @@ discard block |
||
| 1176 | 1253 | date_default_timezone_set($globalTimezone); |
| 1177 | 1254 | $datetime = new DateTime(); |
| 1178 | 1255 | $offset = $datetime->format('P'); |
| 1179 | - } else $offset = '+00:00'; |
|
| 1256 | + } else { |
|
| 1257 | + $offset = '+00:00'; |
|
| 1258 | + } |
|
| 1180 | 1259 | $filter_query = $this->getFilter($filters,true,true); |
| 1181 | 1260 | if ($globalDBdriver == 'mysql') { |
| 1182 | 1261 | $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 |
@@ -1225,7 +1304,9 @@ discard block |
||
| 1225 | 1304 | date_default_timezone_set($globalTimezone); |
| 1226 | 1305 | $datetime = new DateTime(); |
| 1227 | 1306 | $offset = $datetime->format('P'); |
| 1228 | - } else $offset = '+00:00'; |
|
| 1307 | + } else { |
|
| 1308 | + $offset = '+00:00'; |
|
| 1309 | + } |
|
| 1229 | 1310 | |
| 1230 | 1311 | $orderby_sql = ''; |
| 1231 | 1312 | if ($orderby == "hour") |
@@ -1294,7 +1375,9 @@ discard block |
||
| 1294 | 1375 | date_default_timezone_set($globalTimezone); |
| 1295 | 1376 | $datetime = new DateTime($date); |
| 1296 | 1377 | $offset = $datetime->format('P'); |
| 1297 | - } else $offset = '+00:00'; |
|
| 1378 | + } else { |
|
| 1379 | + $offset = '+00:00'; |
|
| 1380 | + } |
|
| 1298 | 1381 | |
| 1299 | 1382 | if ($globalDBdriver == 'mysql') { |
| 1300 | 1383 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1342,7 +1425,9 @@ discard block |
||
| 1342 | 1425 | date_default_timezone_set($globalTimezone); |
| 1343 | 1426 | $datetime = new DateTime(); |
| 1344 | 1427 | $offset = $datetime->format('P'); |
| 1345 | - } else $offset = '+00:00'; |
|
| 1428 | + } else { |
|
| 1429 | + $offset = '+00:00'; |
|
| 1430 | + } |
|
| 1346 | 1431 | |
| 1347 | 1432 | if ($globalDBdriver == 'mysql') { |
| 1348 | 1433 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1407,8 +1492,11 @@ discard block |
||
| 1407 | 1492 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1408 | 1493 | } |
| 1409 | 1494 | } |
| 1410 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1411 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1495 | + if (empty($query_values)) { |
|
| 1496 | + $queryi .= $this->getFilter($filters); |
|
| 1497 | + } else { |
|
| 1498 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1499 | + } |
|
| 1412 | 1500 | |
| 1413 | 1501 | $sth = $this->db->prepare($queryi); |
| 1414 | 1502 | $sth->execute($query_values); |
@@ -1445,8 +1533,11 @@ discard block |
||
| 1445 | 1533 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1446 | 1534 | } |
| 1447 | 1535 | } |
| 1448 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1449 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1536 | + if (empty($query_values)) { |
|
| 1537 | + $queryi .= $this->getFilter($filters); |
|
| 1538 | + } else { |
|
| 1539 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1540 | + } |
|
| 1450 | 1541 | |
| 1451 | 1542 | $sth = $this->db->prepare($queryi); |
| 1452 | 1543 | $sth->execute($query_values); |
@@ -1468,7 +1559,9 @@ discard block |
||
| 1468 | 1559 | date_default_timezone_set($globalTimezone); |
| 1469 | 1560 | $datetime = new DateTime(); |
| 1470 | 1561 | $offset = $datetime->format('P'); |
| 1471 | - } else $offset = '+00:00'; |
|
| 1562 | + } else { |
|
| 1563 | + $offset = '+00:00'; |
|
| 1564 | + } |
|
| 1472 | 1565 | |
| 1473 | 1566 | if ($globalDBdriver == 'mysql') { |
| 1474 | 1567 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1572,7 +1665,9 @@ discard block |
||
| 1572 | 1665 | */ |
| 1573 | 1666 | public function parseDirection($direction = 0) |
| 1574 | 1667 | { |
| 1575 | - if ($direction == '') $direction = 0; |
|
| 1668 | + if ($direction == '') { |
|
| 1669 | + $direction = 0; |
|
| 1670 | + } |
|
| 1576 | 1671 | $direction_array = array(); |
| 1577 | 1672 | $temp_array = array(); |
| 1578 | 1673 | |
@@ -1661,7 +1756,9 @@ discard block |
||
| 1661 | 1756 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1662 | 1757 | |
| 1663 | 1758 | $Connection = new Connection($this->db); |
| 1664 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1759 | + if (!$Connection->tableExists('countries')) { |
|
| 1760 | + return ''; |
|
| 1761 | + } |
|
| 1665 | 1762 | |
| 1666 | 1763 | try { |
| 1667 | 1764 | /* |
@@ -1681,9 +1778,13 @@ discard block |
||
| 1681 | 1778 | $sth->closeCursor(); |
| 1682 | 1779 | if (count($row) > 0) { |
| 1683 | 1780 | return $row; |
| 1684 | - } else return ''; |
|
| 1781 | + } else { |
|
| 1782 | + return ''; |
|
| 1783 | + } |
|
| 1685 | 1784 | } catch (PDOException $e) { |
| 1686 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1785 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1786 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1787 | + } |
|
| 1687 | 1788 | return ''; |
| 1688 | 1789 | } |
| 1689 | 1790 | |
@@ -1701,7 +1802,9 @@ discard block |
||
| 1701 | 1802 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1702 | 1803 | |
| 1703 | 1804 | $Connection = new Connection($this->db); |
| 1704 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1805 | + if (!$Connection->tableExists('countries')) { |
|
| 1806 | + return ''; |
|
| 1807 | + } |
|
| 1705 | 1808 | |
| 1706 | 1809 | try { |
| 1707 | 1810 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1713,9 +1816,13 @@ discard block |
||
| 1713 | 1816 | $sth->closeCursor(); |
| 1714 | 1817 | if (count($row) > 0) { |
| 1715 | 1818 | return $row; |
| 1716 | - } else return ''; |
|
| 1819 | + } else { |
|
| 1820 | + return ''; |
|
| 1821 | + } |
|
| 1717 | 1822 | } catch (PDOException $e) { |
| 1718 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1823 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1824 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1825 | + } |
|
| 1719 | 1826 | return ''; |
| 1720 | 1827 | } |
| 1721 | 1828 | |
@@ -1733,7 +1840,9 @@ discard block |
||
| 1733 | 1840 | { |
| 1734 | 1841 | global $globalBitlyAccessToken; |
| 1735 | 1842 | |
| 1736 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1843 | + if ($globalBitlyAccessToken == '') { |
|
| 1844 | + return $url; |
|
| 1845 | + } |
|
| 1737 | 1846 | |
| 1738 | 1847 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1739 | 1848 | |
@@ -1809,7 +1918,9 @@ discard block |
||
| 1809 | 1918 | } |
| 1810 | 1919 | } |
| 1811 | 1920 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
| 1812 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1921 | + if ($limit) { |
|
| 1922 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1923 | + } |
|
| 1813 | 1924 | $sth = $this->db->prepare($query); |
| 1814 | 1925 | $sth->execute($query_values); |
| 1815 | 1926 | $marine_array = array(); |
@@ -1846,9 +1957,15 @@ discard block |
||
| 1846 | 1957 | foreach ($q_array as $q_item){ |
| 1847 | 1958 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 1848 | 1959 | $additional_query .= " AND ("; |
| 1849 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 1850 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 1851 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 1960 | + if (is_int($q_item)) { |
|
| 1961 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 1962 | + } |
|
| 1963 | + if (is_int($q_item)) { |
|
| 1964 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 1965 | + } |
|
| 1966 | + if (is_int($q_item)) { |
|
| 1967 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 1968 | + } |
|
| 1852 | 1969 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 1853 | 1970 | $additional_query .= ")"; |
| 1854 | 1971 | } |
@@ -1896,7 +2013,9 @@ discard block |
||
| 1896 | 2013 | date_default_timezone_set($globalTimezone); |
| 1897 | 2014 | $datetime = new DateTime(); |
| 1898 | 2015 | $offset = $datetime->format('P'); |
| 1899 | - } else $offset = '+00:00'; |
|
| 2016 | + } else { |
|
| 2017 | + $offset = '+00:00'; |
|
| 2018 | + } |
|
| 1900 | 2019 | if ($date_array[1] != "") |
| 1901 | 2020 | { |
| 1902 | 2021 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1923,8 +2042,12 @@ discard block |
||
| 1923 | 2042 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1924 | 2043 | { |
| 1925 | 2044 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1926 | - } else $limit_query = ""; |
|
| 1927 | - } else $limit_query = ""; |
|
| 2045 | + } else { |
|
| 2046 | + $limit_query = ""; |
|
| 2047 | + } |
|
| 2048 | + } else { |
|
| 2049 | + $limit_query = ""; |
|
| 2050 | + } |
|
| 1928 | 2051 | if ($sort != "") |
| 1929 | 2052 | { |
| 1930 | 2053 | $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"; |
@@ -68,13 +70,17 @@ discard block |
||
| 68 | 70 | public function del() { |
| 69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 70 | 72 | // Delete old infos |
| 71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 73 | + if ($globalDebug) { |
|
| 74 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 75 | + } |
|
| 72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
| 73 | 77 | if (isset($flight['lastupdate'])) { |
| 74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
| 75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
| 77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 81 | + if ($globalDebug) { |
|
| 82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 83 | + } |
|
| 78 | 84 | /* |
| 79 | 85 | $MarineLive = new MarineLive(); |
| 80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
| 84 | 90 | $Marine = new Marine($this->db); |
| 85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 86 | 92 | $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']); |
| 87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 93 | + if ($globalDebug && $result != 'success') { |
|
| 94 | + echo '!!! ERROR : '.$result."\n"; |
|
| 95 | + } |
|
| 88 | 96 | } |
| 89 | 97 | // Put in archive |
| 90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
| 98 | 106 | |
| 99 | 107 | public function add($line) { |
| 100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 110 | + $globalCoordMinChange = '0.02'; |
|
| 111 | + } |
|
| 102 | 112 | date_default_timezone_set('UTC'); |
| 103 | 113 | $dataFound = false; |
| 104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
| 112 | 122 | // Increment message number |
| 113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 114 | 124 | $current_date = date('Y-m-d'); |
| 115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 116 | - else $source = ''; |
|
| 117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 125 | + if (isset($line['source_name'])) { |
|
| 126 | + $source = $line['source_name']; |
|
| 127 | + } else { |
|
| 128 | + $source = ''; |
|
| 129 | + } |
|
| 130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 131 | + $source = $line['format_source']; |
|
| 132 | + } |
|
| 118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 136 | + } else { |
|
| 137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 138 | + } |
|
| 122 | 139 | } |
| 123 | 140 | |
| 124 | 141 | |
| 125 | 142 | $Common = new Common(); |
| 126 | 143 | $AIS = new AIS(); |
| 127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 128 | - else $id = trim($line['id']); |
|
| 144 | + if (!isset($line['id'])) { |
|
| 145 | + $id = trim($line['mmsi']); |
|
| 146 | + } else { |
|
| 147 | + $id = trim($line['id']); |
|
| 148 | + } |
|
| 129 | 149 | |
| 130 | 150 | if (!isset($this->all_tracked[$id])) { |
| 131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
| 133 | 153 | $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' => '')); |
| 134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 135 | 155 | if (!isset($line['id'])) { |
| 136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 156 | + if (!isset($globalDaemon)) { |
|
| 157 | + $globalDaemon = TRUE; |
|
| 158 | + } |
|
| 137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 160 | + } else { |
|
| 161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 162 | + } |
|
| 163 | + if ($globalAllTracked !== FALSE) { |
|
| 164 | + $dataFound = true; |
|
| 165 | + } |
|
| 140 | 166 | } |
| 141 | 167 | |
| 142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -173,7 +199,9 @@ discard block |
||
| 173 | 199 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 174 | 200 | } |
| 175 | 201 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 176 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 202 | + if (strtotime($line['arrival_date']) > time()) { |
|
| 203 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 204 | + } |
|
| 177 | 205 | } |
| 178 | 206 | |
| 179 | 207 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -186,35 +214,50 @@ discard block |
||
| 186 | 214 | $Marine = new Marine($this->db); |
| 187 | 215 | $fromsource = NULL; |
| 188 | 216 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 189 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 217 | + if ($globalDebug && $result != 'success') { |
|
| 218 | + echo '!!! ERROR : '.$result."\n"; |
|
| 219 | + } |
|
| 190 | 220 | $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
| 191 | 221 | $Marine->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 222 | + if ($globalDebugTimeElapsed) { |
|
| 223 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 224 | + } |
|
| 193 | 225 | } |
| 194 | 226 | } |
| 195 | 227 | } |
| 196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 228 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 230 | + } |
|
| 197 | 231 | } |
| 198 | 232 | |
| 199 | 233 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 200 | 234 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 201 | 235 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 202 | 236 | } else { |
| 203 | - 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"; |
|
| 204 | - 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"; |
|
| 237 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 238 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 239 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 240 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 241 | + } |
|
| 205 | 242 | return ''; |
| 206 | 243 | } |
| 207 | 244 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 208 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 247 | + } |
|
| 209 | 248 | return ''; |
| 210 | 249 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 211 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 250 | + if ($globalDebug) { |
|
| 251 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 252 | + } |
|
| 212 | 253 | return ''; |
| 213 | 254 | } elseif (!isset($line['datetime'])) { |
| 214 | 255 | date_default_timezone_set('UTC'); |
| 215 | 256 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 216 | 257 | } else { |
| 217 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 258 | + if ($globalDebug) { |
|
| 259 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 260 | + } |
|
| 218 | 261 | return ''; |
| 219 | 262 | } |
| 220 | 263 | |
@@ -227,14 +270,21 @@ discard block |
||
| 227 | 270 | if ($distance > 1000 && $distance < 10000) { |
| 228 | 271 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 229 | 272 | $speed = $speed*3.6; |
| 230 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 231 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 273 | + if ($speed < 1000) { |
|
| 274 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 275 | + } |
|
| 276 | + if ($globalDebug) { |
|
| 277 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 278 | + } |
|
| 232 | 279 | } |
| 233 | 280 | } |
| 234 | 281 | |
| 235 | 282 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 237 | - else unset($timediff); |
|
| 283 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 284 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 285 | + } else { |
|
| 286 | + unset($timediff); |
|
| 287 | + } |
|
| 238 | 288 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 239 | 289 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 240 | 290 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -242,22 +292,32 @@ discard block |
||
| 242 | 292 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 243 | 293 | $this->all_tracked[$id]['putinarchive'] = true; |
| 244 | 294 | |
| 245 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 295 | + if ($globalDebug) { |
|
| 296 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 297 | + } |
|
| 246 | 298 | $timeelapsed = microtime(true); |
| 247 | 299 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 248 | 300 | $Marine = new Marine($this->db); |
| 249 | 301 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 250 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 302 | + if (!empty($all_country)) { |
|
| 303 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 304 | + } |
|
| 251 | 305 | $Marine->db = null; |
| 252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 306 | + if ($globalDebugTimeElapsed) { |
|
| 307 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 308 | + } |
|
| 253 | 309 | } |
| 254 | 310 | $this->tmd = 0; |
| 255 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 311 | + if ($globalDebug) { |
|
| 312 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 313 | + } |
|
| 256 | 314 | } |
| 257 | 315 | } |
| 258 | 316 | |
| 259 | 317 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 260 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 318 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 319 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 320 | + } |
|
| 261 | 321 | 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') { |
| 262 | 322 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 263 | 323 | $dataFound = true; |
@@ -266,8 +326,12 @@ discard block |
||
| 266 | 326 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 267 | 327 | } |
| 268 | 328 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 269 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 270 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 329 | + if ($line['longitude'] > 180) { |
|
| 330 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 331 | + } |
|
| 332 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 333 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 334 | + } |
|
| 271 | 335 | 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') { |
| 272 | 336 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 273 | 337 | $dataFound = true; |
@@ -285,7 +349,9 @@ discard block |
||
| 285 | 349 | } |
| 286 | 350 | } |
| 287 | 351 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 288 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 352 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 353 | + $dataFound = true; |
|
| 354 | + } |
|
| 289 | 355 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 290 | 356 | } |
| 291 | 357 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -315,15 +381,21 @@ discard block |
||
| 315 | 381 | } |
| 316 | 382 | |
| 317 | 383 | if (isset($line['heading']) && $line['heading'] != '') { |
| 318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 384 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 385 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 386 | + } |
|
| 319 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 320 | 388 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 321 | 389 | //$dataFound = true; |
| 322 | 390 | } 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']) { |
| 323 | 391 | $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']); |
| 324 | 392 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 326 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 393 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 394 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 395 | + } |
|
| 396 | + if ($globalDebug) { |
|
| 397 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 398 | + } |
|
| 327 | 399 | } |
| 328 | 400 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 329 | 401 | |
@@ -335,23 +407,38 @@ discard block |
||
| 335 | 407 | 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'])) { |
| 336 | 408 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 337 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 338 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 410 | + if ($globalDebug) { |
|
| 411 | + echo "Check if vessel is already in DB..."; |
|
| 412 | + } |
|
| 339 | 413 | $timeelapsed = microtime(true); |
| 340 | 414 | $MarineLive = new MarineLive($this->db); |
| 341 | 415 | if (isset($line['id'])) { |
| 342 | 416 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 417 | + if ($globalDebugTimeElapsed) { |
|
| 418 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 419 | + } |
|
| 344 | 420 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 345 | 421 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 422 | + if ($globalDebugTimeElapsed) { |
|
| 423 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 424 | + } |
|
| 347 | 425 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 348 | 426 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 349 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 350 | - } else $recent_ident = ''; |
|
| 427 | + if ($globalDebugTimeElapsed) { |
|
| 428 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 429 | + } |
|
| 430 | + } else { |
|
| 431 | + $recent_ident = ''; |
|
| 432 | + } |
|
| 351 | 433 | $MarineLive->db=null; |
| 352 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 353 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 354 | - } else $recent_ident = ''; |
|
| 434 | + if ($globalDebug && $recent_ident == '') { |
|
| 435 | + echo " Not in DB.\n"; |
|
| 436 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 437 | + echo " Already in DB.\n"; |
|
| 438 | + } |
|
| 439 | + } else { |
|
| 440 | + $recent_ident = ''; |
|
| 441 | + } |
|
| 355 | 442 | } else { |
| 356 | 443 | $recent_ident = ''; |
| 357 | 444 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -359,30 +446,44 @@ discard block |
||
| 359 | 446 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
| 360 | 447 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 361 | 448 | { |
| 362 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 449 | + if ($globalDebug) { |
|
| 450 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 451 | + } |
|
| 363 | 452 | //adds the spotter data for the archive |
| 364 | 453 | $highlight = ''; |
| 365 | - 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'))); |
|
| 454 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 455 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 456 | + } |
|
| 366 | 457 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 367 | 458 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 368 | 459 | $timeelapsed = microtime(true); |
| 369 | 460 | $Marine = new Marine($this->db); |
| 370 | 461 | $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']); |
| 371 | 462 | $Marine->db = null; |
| 372 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 463 | + if ($globalDebug && isset($result)) { |
|
| 464 | + echo $result."\n"; |
|
| 465 | + } |
|
| 466 | + if ($globalDebugTimeElapsed) { |
|
| 467 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 468 | + } |
|
| 374 | 469 | } |
| 375 | 470 | } |
| 376 | 471 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 377 | 472 | // Add source stat in DB |
| 378 | 473 | $Stats = new Stats($this->db); |
| 379 | 474 | if (!empty($this->stats)) { |
| 380 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 475 | + if ($globalDebug) { |
|
| 476 | + echo 'Add source stats : '; |
|
| 477 | + } |
|
| 381 | 478 | foreach($this->stats as $date => $data) { |
| 382 | 479 | foreach($data as $source => $sourced) { |
| 383 | 480 | //print_r($sourced); |
| 384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 481 | + if (isset($sourced['polar'])) { |
|
| 482 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 483 | + } |
|
| 484 | + if (isset($sourced['hist'])) { |
|
| 485 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 486 | + } |
|
| 386 | 487 | if (isset($sourced['msg'])) { |
| 387 | 488 | if (time() - $sourced['msg']['date'] > 10) { |
| 388 | 489 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -395,7 +496,9 @@ discard block |
||
| 395 | 496 | unset($this->stats[$date]); |
| 396 | 497 | } |
| 397 | 498 | } |
| 398 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 499 | + if ($globalDebug) { |
|
| 500 | + echo 'Done'."\n"; |
|
| 501 | + } |
|
| 399 | 502 | } |
| 400 | 503 | $Stats->db = null; |
| 401 | 504 | } |
@@ -405,13 +508,17 @@ discard block |
||
| 405 | 508 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 406 | 509 | //print_r($this->all_tracked[$id]); |
| 407 | 510 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 408 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 511 | + if ($globalDebug) { |
|
| 512 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 513 | + } |
|
| 409 | 514 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 410 | 515 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 411 | 516 | $MarineLive = new MarineLive($this->db); |
| 412 | 517 | $MarineLive->deleteLiveMarineData(); |
| 413 | 518 | $MarineLive->db=null; |
| 414 | - if ($globalDebug) echo " Done\n"; |
|
| 519 | + if ($globalDebug) { |
|
| 520 | + echo " Done\n"; |
|
| 521 | + } |
|
| 415 | 522 | } |
| 416 | 523 | $this->last_delete = time(); |
| 417 | 524 | } |
@@ -437,15 +544,21 @@ discard block |
||
| 437 | 544 | |
| 438 | 545 | if (!$ignoreImport) { |
| 439 | 546 | 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'])) { |
| 440 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 547 | + if ($globalDebug) { |
|
| 548 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 549 | + } |
|
| 441 | 550 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 442 | 551 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 443 | 552 | $timeelapsed = microtime(true); |
| 444 | 553 | $MarineLive = new MarineLive($this->db); |
| 445 | 554 | $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']); |
| 446 | 555 | $MarineLive->db = null; |
| 447 | - if ($globalDebug) echo $result."\n"; |
|
| 448 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 556 | + if ($globalDebug) { |
|
| 557 | + echo $result."\n"; |
|
| 558 | + } |
|
| 559 | + if ($globalDebugTimeElapsed) { |
|
| 560 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 561 | + } |
|
| 449 | 562 | } |
| 450 | 563 | } |
| 451 | 564 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -457,7 +570,9 @@ discard block |
||
| 457 | 570 | |
| 458 | 571 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 459 | 572 | $source = $this->all_tracked[$id]['source_name']; |
| 460 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 573 | + if ($source == '') { |
|
| 574 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 575 | + } |
|
| 461 | 576 | if (!isset($this->source_location[$source])) { |
| 462 | 577 | $Location = new Source($this->db); |
| 463 | 578 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -478,7 +593,9 @@ discard block |
||
| 478 | 593 | $stats_heading = round($stats_heading/22.5); |
| 479 | 594 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 480 | 595 | $current_date = date('Y-m-d'); |
| 481 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 596 | + if ($stats_heading == 16) { |
|
| 597 | + $stats_heading = 0; |
|
| 598 | + } |
|
| 482 | 599 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 483 | 600 | for ($i=0;$i<=15;$i++) { |
| 484 | 601 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -496,7 +613,9 @@ discard block |
||
| 496 | 613 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 497 | 614 | end($this->stats[$current_date][$source]['hist']); |
| 498 | 615 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 499 | - } else $mini = 0; |
|
| 616 | + } else { |
|
| 617 | + $mini = 0; |
|
| 618 | + } |
|
| 500 | 619 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 501 | 620 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 502 | 621 | } |
@@ -508,19 +627,27 @@ discard block |
||
| 508 | 627 | |
| 509 | 628 | |
| 510 | 629 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 511 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 512 | - } 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"; |
|
| 630 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 631 | + $send = true; |
|
| 632 | + } |
|
| 633 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 634 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 635 | + } |
|
| 513 | 636 | //$this->del(); |
| 514 | 637 | |
| 515 | 638 | |
| 516 | 639 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 517 | 640 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 518 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 641 | + if ($globalDebug) { |
|
| 642 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 643 | + } |
|
| 519 | 644 | $MarineLive = new MarineLive($this->db); |
| 520 | 645 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 521 | 646 | $MarineLive->db = null; |
| 522 | 647 | //MarineLive->deleteLiveMarineData(); |
| 523 | - if ($globalDebug) echo " Done\n"; |
|
| 648 | + if ($globalDebug) { |
|
| 649 | + echo " Done\n"; |
|
| 650 | + } |
|
| 524 | 651 | } |
| 525 | 652 | $this->last_delete_hourly = time(); |
| 526 | 653 | } |
@@ -529,7 +656,9 @@ discard block |
||
| 529 | 656 | //$ignoreImport = false; |
| 530 | 657 | } |
| 531 | 658 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 532 | - if ($send) return $this->all_tracked[$id]; |
|
| 659 | + if ($send) { |
|
| 660 | + return $this->all_tracked[$id]; |
|
| 661 | + } |
|
| 533 | 662 | } |
| 534 | 663 | } |
| 535 | 664 | } |
@@ -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,22 +211,30 @@ 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('/opensky/i',$host)) { |
| 177 | 232 | //$formats[$id] = 'aircraftlistjson'; |
| 178 | 233 | $globalSources[$id]['format'] = 'opensky'; |
| 179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 237 | + } |
|
| 181 | 238 | /* |
| 182 | 239 | // Disabled for now, site change source format |
| 183 | 240 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -194,7 +251,9 @@ discard block |
||
| 194 | 251 | //$formats[$id] = 'planeupdatefaa'; |
| 195 | 252 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 196 | 253 | //$last_exec['planeupdatefaa'] = 0; |
| 197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 254 | + if ($globalDebug) { |
|
| 255 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 256 | + } |
|
| 198 | 257 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 199 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 200 | 259 | exit(0); |
@@ -203,37 +262,53 @@ discard block |
||
| 203 | 262 | //$formats[$id] = 'phpvmacars'; |
| 204 | 263 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 205 | 264 | //$last_exec['phpvmacars'] = 0; |
| 206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 265 | + if ($globalDebug) { |
|
| 266 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 267 | + } |
|
| 207 | 268 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 208 | 269 | //$formats[$id] = 'phpvmacars'; |
| 209 | 270 | $globalSources[$id]['format'] = 'vaos'; |
| 210 | 271 | //$last_exec['phpvmacars'] = 0; |
| 211 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 272 | + if ($globalDebug) { |
|
| 273 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 274 | + } |
|
| 212 | 275 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 213 | 276 | //$formats[$id] = 'phpvmacars'; |
| 214 | 277 | $globalSources[$id]['format'] = 'vam'; |
| 215 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 278 | + if ($globalDebug) { |
|
| 279 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 280 | + } |
|
| 216 | 281 | } else if (preg_match('/whazzup/i',$host)) { |
| 217 | 282 | //$formats[$id] = 'whazzup'; |
| 218 | 283 | $globalSources[$id]['format'] = 'whazzup'; |
| 219 | 284 | //$last_exec['whazzup'] = 0; |
| 220 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 285 | + if ($globalDebug) { |
|
| 286 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 287 | + } |
|
| 221 | 288 | } else if (preg_match('/blitzortung/i',$host)) { |
| 222 | 289 | $globalSources[$id]['format'] = 'blitzortung'; |
| 223 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 290 | + if ($globalDebug) { |
|
| 291 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 292 | + } |
|
| 224 | 293 | } else if (preg_match('/airwhere/i',$host)) { |
| 225 | 294 | $globalSources[$id]['format'] = 'airwhere'; |
| 226 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 295 | + if ($globalDebug) { |
|
| 296 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 297 | + } |
|
| 227 | 298 | } else if (preg_match('/recentpireps/i',$host)) { |
| 228 | 299 | //$formats[$id] = 'pirepsjson'; |
| 229 | 300 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 230 | 301 | //$last_exec['pirepsjson'] = 0; |
| 231 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 302 | + if ($globalDebug) { |
|
| 303 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 304 | + } |
|
| 232 | 305 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 233 | 306 | //$formats[$id] = 'fr24json'; |
| 234 | 307 | $globalSources[$id]['format'] = 'fr24json'; |
| 235 | 308 | //$last_exec['fr24json'] = 0; |
| 236 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 309 | + if ($globalDebug) { |
|
| 310 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 311 | + } |
|
| 237 | 312 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 238 | 313 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 239 | 314 | exit(0); |
@@ -242,7 +317,9 @@ discard block |
||
| 242 | 317 | //$formats[$id] = 'fr24json'; |
| 243 | 318 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 244 | 319 | //$last_exec['fr24json'] = 0; |
| 245 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 320 | + if ($globalDebug) { |
|
| 321 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 322 | + } |
|
| 246 | 323 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 247 | 324 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 248 | 325 | exit(0); |
@@ -251,16 +328,24 @@ discard block |
||
| 251 | 328 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 252 | 329 | //$formats[$id] = 'tsv'; |
| 253 | 330 | $globalSources[$id]['format'] = 'tsv'; |
| 254 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 333 | + } |
|
| 255 | 334 | } |
| 256 | 335 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 257 | 336 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 258 | 337 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 259 | 338 | if ($idf !== false) { |
| 260 | 339 | $httpfeeds[$id] = $idf; |
| 261 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 262 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 263 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 340 | + if ($globalDebug) { |
|
| 341 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 342 | + } |
|
| 343 | + } elseif ($globalDebug) { |
|
| 344 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 345 | + } |
|
| 346 | + } elseif ($globalDebug) { |
|
| 347 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 348 | + } |
|
| 264 | 349 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 265 | 350 | $hostport = explode(':',$host); |
| 266 | 351 | if (isset($hostport[1])) { |
@@ -300,17 +385,25 @@ discard block |
||
| 300 | 385 | //$formats[$id] = 'beast'; |
| 301 | 386 | $globalSources[$id]['format'] = 'beast'; |
| 302 | 387 | //} else $formats[$id] = 'sbs'; |
| 303 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 388 | + } else { |
|
| 389 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 390 | + } |
|
| 304 | 391 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 305 | 392 | } |
| 306 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 393 | + if ($globalDebug) { |
|
| 394 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 395 | + } |
|
| 307 | 396 | } else { |
| 308 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 397 | + if ($globalDebug) { |
|
| 398 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 399 | + } |
|
| 309 | 400 | } |
| 310 | 401 | } |
| 311 | 402 | } |
| 312 | 403 | } |
| 313 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 404 | +if (!isset($globalMinFetch)) { |
|
| 405 | + $globalMinFetch = 15; |
|
| 406 | +} |
|
| 314 | 407 | |
| 315 | 408 | // Initialize all |
| 316 | 409 | $status = array(); |
@@ -319,13 +412,19 @@ discard block |
||
| 319 | 412 | $formats = array(); |
| 320 | 413 | $last_exec = array(); |
| 321 | 414 | $time = time(); |
| 322 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 323 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 324 | -else $timeout = 20; |
|
| 415 | +if (isset($globalSourcesTimeout)) { |
|
| 416 | + $timeout = $globalSourcesTimeOut; |
|
| 417 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 418 | + $timeout = $globalSBS1TimeOut; |
|
| 419 | +} else { |
|
| 420 | + $timeout = 20; |
|
| 421 | +} |
|
| 325 | 422 | $errno = ''; |
| 326 | 423 | $errstr=''; |
| 327 | 424 | |
| 328 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 425 | +if (!isset($globalDaemon)) { |
|
| 426 | + $globalDaemon = TRUE; |
|
| 427 | +} |
|
| 329 | 428 | /* Initiate connections to all the hosts simultaneously */ |
| 330 | 429 | //connect_all($hosts); |
| 331 | 430 | //connect_all($globalSources); |
@@ -354,7 +453,9 @@ discard block |
||
| 354 | 453 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 355 | 454 | $aprs_connect = 0; |
| 356 | 455 | $use_aprs = true; |
| 357 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 456 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 457 | + $aprs_full = true; |
|
| 458 | + } |
|
| 358 | 459 | break; |
| 359 | 460 | } |
| 360 | 461 | } |
@@ -365,25 +466,46 @@ discard block |
||
| 365 | 466 | $aprs_connect = 0; |
| 366 | 467 | $aprs_keep = 120; |
| 367 | 468 | $aprs_last_tx = time(); |
| 368 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 369 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 370 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 371 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 372 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 373 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 374 | - if ($aprs_full) $aprs_filter = ''; |
|
| 375 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 376 | - else $aprs_pass = '-1'; |
|
| 469 | + if (isset($globalAPRSversion)) { |
|
| 470 | + $aprs_version = $globalAPRSversion; |
|
| 471 | + } else { |
|
| 472 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 473 | + } |
|
| 474 | + if (isset($globalAPRSssid)) { |
|
| 475 | + $aprs_ssid = $globalAPRSssid; |
|
| 476 | + } else { |
|
| 477 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 478 | + } |
|
| 479 | + if (isset($globalAPRSfilter)) { |
|
| 480 | + $aprs_filter = $globalAPRSfilter; |
|
| 481 | + } else { |
|
| 482 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 483 | + } |
|
| 484 | + if ($aprs_full) { |
|
| 485 | + $aprs_filter = ''; |
|
| 486 | + } |
|
| 487 | + if (isset($globalAPRSpass)) { |
|
| 488 | + $aprs_pass = $globalAPRSpass; |
|
| 489 | + } else { |
|
| 490 | + $aprs_pass = '-1'; |
|
| 491 | + } |
|
| 377 | 492 | |
| 378 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 379 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 380 | -} |
|
| 493 | + if ($aprs_filter != '') { |
|
| 494 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 495 | + } else { |
|
| 496 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 497 | + } |
|
| 498 | + } |
|
| 381 | 499 | |
| 382 | 500 | // connected - lets do some work |
| 383 | 501 | //if ($globalDebug) echo "Connected!\n"; |
| 384 | 502 | sleep(1); |
| 385 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 386 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 503 | +if ($globalDebug) { |
|
| 504 | + echo "SCAN MODE \n\n"; |
|
| 505 | +} |
|
| 506 | +if (!isset($globalCronEnd)) { |
|
| 507 | + $globalCronEnd = 60; |
|
| 508 | +} |
|
| 387 | 509 | $endtime = time()+$globalCronEnd; |
| 388 | 510 | $i = 1; |
| 389 | 511 | $tt = array(); |
@@ -397,20 +519,28 @@ discard block |
||
| 397 | 519 | |
| 398 | 520 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 399 | 521 | while ($i > 0) { |
| 400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 522 | + if (!$globalDaemon) { |
|
| 523 | + $i = $endtime-time(); |
|
| 524 | + } |
|
| 401 | 525 | // Delete old ATC |
| 402 | 526 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 403 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 527 | + if ($globalDebug) { |
|
| 528 | + echo 'Delete old ATC...'."\n"; |
|
| 529 | + } |
|
| 404 | 530 | $ATC->deleteOldATC(); |
| 405 | 531 | } |
| 406 | 532 | |
| 407 | 533 | if (count($last_exec) == count($globalSources)) { |
| 408 | 534 | $max = $globalMinFetch; |
| 409 | 535 | foreach ($last_exec as $last) { |
| 410 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 536 | + if ((time() - $last['last']) < $max) { |
|
| 537 | + $max = time() - $last['last']; |
|
| 538 | + } |
|
| 411 | 539 | } |
| 412 | 540 | if ($max != $globalMinFetch) { |
| 413 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 541 | + if ($globalDebug) { |
|
| 542 | + echo 'Sleeping...'."\n"; |
|
| 543 | + } |
|
| 414 | 544 | sleep($globalMinFetch-$max+2); |
| 415 | 545 | } |
| 416 | 546 | } |
@@ -420,7 +550,9 @@ discard block |
||
| 420 | 550 | foreach ($globalSources as $id => $value) { |
| 421 | 551 | date_default_timezone_set('UTC'); |
| 422 | 552 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 423 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 553 | + if (!isset($last_exec[$id]['last'])) { |
|
| 554 | + $last_exec[$id]['last'] = 0; |
|
| 555 | + } |
|
| 424 | 556 | if ($value['format'] == 'deltadbtxt' && |
| 425 | 557 | ( |
| 426 | 558 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -429,7 +561,9 @@ discard block |
||
| 429 | 561 | ) { |
| 430 | 562 | //$buffer = $Common->getData($hosts[$id]); |
| 431 | 563 | $buffer = $Common->getData($value['host']); |
| 432 | - if ($buffer != '') $reset = 0; |
|
| 564 | + if ($buffer != '') { |
|
| 565 | + $reset = 0; |
|
| 566 | + } |
|
| 433 | 567 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 434 | 568 | $buffer = explode('\n',$buffer); |
| 435 | 569 | foreach ($buffer as $line) { |
@@ -438,20 +572,41 @@ discard block |
||
| 438 | 572 | $data = array(); |
| 439 | 573 | $data['hex'] = $line[1]; // hex |
| 440 | 574 | $data['ident'] = $line[2]; // ident |
| 441 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 442 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 443 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 444 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 445 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 575 | + if (isset($line[3])) { |
|
| 576 | + $data['altitude'] = $line[3]; |
|
| 577 | + } |
|
| 578 | + // altitude |
|
| 579 | + if (isset($line[4])) { |
|
| 580 | + $data['speed'] = $line[4]; |
|
| 581 | + } |
|
| 582 | + // speed |
|
| 583 | + if (isset($line[5])) { |
|
| 584 | + $data['heading'] = $line[5]; |
|
| 585 | + } |
|
| 586 | + // heading |
|
| 587 | + if (isset($line[6])) { |
|
| 588 | + $data['latitude'] = $line[6]; |
|
| 589 | + } |
|
| 590 | + // lat |
|
| 591 | + if (isset($line[7])) { |
|
| 592 | + $data['longitude'] = $line[7]; |
|
| 593 | + } |
|
| 594 | + // long |
|
| 446 | 595 | $data['verticalrate'] = ''; // vertical rate |
| 447 | 596 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 448 | 597 | $data['emergency'] = ''; // emergency |
| 449 | 598 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 450 | 599 | $data['format_source'] = 'deltadbtxt'; |
| 451 | 600 | $data['id_source'] = $id_source; |
| 452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 453 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 454 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 601 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 602 | + $data['source_name'] = $value['name']; |
|
| 603 | + } |
|
| 604 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 605 | + $data['noarchive'] = true; |
|
| 606 | + } |
|
| 607 | + if (isset($value['sourcestats'])) { |
|
| 608 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 609 | + } |
|
| 455 | 610 | $SI->add($data); |
| 456 | 611 | unset($data); |
| 457 | 612 | } |
@@ -466,7 +621,9 @@ discard block |
||
| 466 | 621 | date_default_timezone_set('CET'); |
| 467 | 622 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 468 | 623 | date_default_timezone_set('UTC'); |
| 469 | - if ($buffer != '') $reset = 0; |
|
| 624 | + if ($buffer != '') { |
|
| 625 | + $reset = 0; |
|
| 626 | + } |
|
| 470 | 627 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 471 | 628 | $buffer = explode('\n',$buffer); |
| 472 | 629 | foreach ($buffer as $line) { |
@@ -475,16 +632,36 @@ discard block |
||
| 475 | 632 | $add = false; |
| 476 | 633 | $ais_data = $AIS->parse_line(trim($line)); |
| 477 | 634 | $data = array(); |
| 478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 485 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 486 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 487 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 635 | + if (isset($ais_data['ident'])) { |
|
| 636 | + $data['ident'] = $ais_data['ident']; |
|
| 637 | + } |
|
| 638 | + if (isset($ais_data['mmsi'])) { |
|
| 639 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 640 | + } |
|
| 641 | + if (isset($ais_data['speed'])) { |
|
| 642 | + $data['speed'] = $ais_data['speed']; |
|
| 643 | + } |
|
| 644 | + if (isset($ais_data['heading'])) { |
|
| 645 | + $data['heading'] = $ais_data['heading']; |
|
| 646 | + } |
|
| 647 | + if (isset($ais_data['latitude'])) { |
|
| 648 | + $data['latitude'] = $ais_data['latitude']; |
|
| 649 | + } |
|
| 650 | + if (isset($ais_data['longitude'])) { |
|
| 651 | + $data['longitude'] = $ais_data['longitude']; |
|
| 652 | + } |
|
| 653 | + if (isset($ais_data['status'])) { |
|
| 654 | + $data['status'] = $ais_data['status']; |
|
| 655 | + } |
|
| 656 | + if (isset($ais_data['type'])) { |
|
| 657 | + $data['type'] = $ais_data['type']; |
|
| 658 | + } |
|
| 659 | + if (isset($ais_data['imo'])) { |
|
| 660 | + $data['imo'] = $ais_data['imo']; |
|
| 661 | + } |
|
| 662 | + if (isset($ais_data['callsign'])) { |
|
| 663 | + $data['callsign'] = $ais_data['callsign']; |
|
| 664 | + } |
|
| 488 | 665 | if (isset($ais_data['timestamp'])) { |
| 489 | 666 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 490 | 667 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -498,8 +675,12 @@ discard block |
||
| 498 | 675 | $data['format_source'] = 'aisnmeatxt'; |
| 499 | 676 | $data['id_source'] = $id_source; |
| 500 | 677 | //print_r($data); |
| 501 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 502 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 678 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 679 | + $data['noarchive'] = true; |
|
| 680 | + } |
|
| 681 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 682 | + $MI->add($data); |
|
| 683 | + } |
|
| 503 | 684 | unset($data); |
| 504 | 685 | } |
| 505 | 686 | } |
@@ -522,20 +703,48 @@ discard block |
||
| 522 | 703 | if ($line != '') { |
| 523 | 704 | $ais_data = $AIS->parse_line(trim($line)); |
| 524 | 705 | $data = array(); |
| 525 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 526 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 527 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 528 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 529 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 530 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 531 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 532 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 533 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 534 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 535 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 536 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 537 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 538 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 706 | + if (isset($ais_data['ident'])) { |
|
| 707 | + $data['ident'] = $ais_data['ident']; |
|
| 708 | + } |
|
| 709 | + if (isset($ais_data['mmsi'])) { |
|
| 710 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 711 | + } |
|
| 712 | + if (isset($ais_data['speed'])) { |
|
| 713 | + $data['speed'] = $ais_data['speed']; |
|
| 714 | + } |
|
| 715 | + if (isset($ais_data['heading'])) { |
|
| 716 | + $data['heading'] = $ais_data['heading']; |
|
| 717 | + } |
|
| 718 | + if (isset($ais_data['latitude'])) { |
|
| 719 | + $data['latitude'] = $ais_data['latitude']; |
|
| 720 | + } |
|
| 721 | + if (isset($ais_data['longitude'])) { |
|
| 722 | + $data['longitude'] = $ais_data['longitude']; |
|
| 723 | + } |
|
| 724 | + if (isset($ais_data['status'])) { |
|
| 725 | + $data['status'] = $ais_data['status']; |
|
| 726 | + } |
|
| 727 | + if (isset($ais_data['statusid'])) { |
|
| 728 | + $data['status_id'] = $ais_data['statusid']; |
|
| 729 | + } |
|
| 730 | + if (isset($ais_data['type'])) { |
|
| 731 | + $data['type'] = $ais_data['type']; |
|
| 732 | + } |
|
| 733 | + if (isset($ais_data['typeid'])) { |
|
| 734 | + $data['type_id'] = $ais_data['typeid']; |
|
| 735 | + } |
|
| 736 | + if (isset($ais_data['imo'])) { |
|
| 737 | + $data['imo'] = $ais_data['imo']; |
|
| 738 | + } |
|
| 739 | + if (isset($ais_data['callsign'])) { |
|
| 740 | + $data['callsign'] = $ais_data['callsign']; |
|
| 741 | + } |
|
| 742 | + if (isset($ais_data['destination'])) { |
|
| 743 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 744 | + } |
|
| 745 | + if (isset($ais_data['eta_ts'])) { |
|
| 746 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 747 | + } |
|
| 539 | 748 | if (isset($ais_data['timestamp'])) { |
| 540 | 749 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 541 | 750 | } else { |
@@ -543,18 +752,27 @@ discard block |
||
| 543 | 752 | } |
| 544 | 753 | $data['format_source'] = 'aisnmeahttp'; |
| 545 | 754 | $data['id_source'] = $id_source; |
| 546 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 547 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 755 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 756 | + $data['noarchive'] = true; |
|
| 757 | + } |
|
| 758 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 759 | + $MI->add($data); |
|
| 760 | + } |
|
| 548 | 761 | unset($data); |
| 549 | 762 | } |
| 550 | 763 | } |
| 551 | 764 | } |
| 552 | 765 | } else { |
| 553 | 766 | $format = $value['format']; |
| 554 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 555 | - else $tt[$format] = 0; |
|
| 767 | + if (isset($tt[$format])) { |
|
| 768 | + $tt[$format]++; |
|
| 769 | + } else { |
|
| 770 | + $tt[$format] = 0; |
|
| 771 | + } |
|
| 556 | 772 | if ($tt[$format] > 30) { |
| 557 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 773 | + if ($globalDebug) { |
|
| 774 | + echo 'Reconnect...'."\n"; |
|
| 775 | + } |
|
| 558 | 776 | sleep(2); |
| 559 | 777 | //$sourceeen[] = $value; |
| 560 | 778 | //connect_all($sourceeen); |
@@ -590,12 +808,18 @@ discard block |
||
| 590 | 808 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 591 | 809 | $data['type_id'] = $line['TYPE']; |
| 592 | 810 | $data['imo'] = $line['IMO']; |
| 593 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 594 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 811 | + if ($line['DEST'] != '') { |
|
| 812 | + $data['arrival_code'] = $line['DEST']; |
|
| 813 | + } |
|
| 814 | + if ($line['ARV'] != '') { |
|
| 815 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 816 | + } |
|
| 595 | 817 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 596 | 818 | $data['format_source'] = 'myshiptracking'; |
| 597 | 819 | $data['id_source'] = $id_source; |
| 598 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 820 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 821 | + $data['noarchive'] = true; |
|
| 822 | + } |
|
| 599 | 823 | $MI->add($data); |
| 600 | 824 | unset($data); |
| 601 | 825 | } |
@@ -620,7 +844,9 @@ discard block |
||
| 620 | 844 | $data['callsign'] = $line['callsign']; |
| 621 | 845 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 622 | 846 | $data['speed'] = $line['sog']; |
| 623 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 847 | + if ($line['heading'] != '511') { |
|
| 848 | + $data['heading'] = $line['heading']; |
|
| 849 | + } |
|
| 624 | 850 | $data['latitude'] = $line['latitude']; |
| 625 | 851 | $data['longitude'] = $line['longitude']; |
| 626 | 852 | $data['type_id'] = $line['shiptype']; |
@@ -628,7 +854,9 @@ discard block |
||
| 628 | 854 | $data['datetime'] = $line['time']; |
| 629 | 855 | $data['format_source'] = 'boatbeaconapp'; |
| 630 | 856 | $data['id_source'] = $id_source; |
| 631 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 857 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 858 | + $data['noarchive'] = true; |
|
| 859 | + } |
|
| 632 | 860 | $MI->add($data); |
| 633 | 861 | unset($data); |
| 634 | 862 | } |
@@ -650,22 +878,44 @@ discard block |
||
| 650 | 878 | foreach ($all_data['features'] as $line) { |
| 651 | 879 | print_r($line); |
| 652 | 880 | $data = array(); |
| 653 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 654 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 655 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 656 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 657 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 658 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 881 | + if (isset($line['properties']['name'])) { |
|
| 882 | + $data['ident'] = $line['properties']['name']; |
|
| 883 | + } |
|
| 884 | + if (isset($line['properties']['callsign'])) { |
|
| 885 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 886 | + } |
|
| 887 | + if (isset($line['properties']['mmsi'])) { |
|
| 888 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 889 | + } |
|
| 890 | + if (isset($line['properties']['imo'])) { |
|
| 891 | + $data['imo'] = $line['properties']['imo']; |
|
| 892 | + } |
|
| 893 | + if (isset($line['properties']['speed'])) { |
|
| 894 | + $data['speed'] = $line['properties']['speed']; |
|
| 895 | + } |
|
| 896 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 897 | + $data['heading'] = $line['properties']['heading']; |
|
| 898 | + } |
|
| 659 | 899 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 660 | 900 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 661 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 662 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 663 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 901 | + if (isset($line['properties']['vesselType'])) { |
|
| 902 | + $data['type'] = $line['properties']['vesselType']; |
|
| 903 | + } |
|
| 904 | + if (isset($line['properties']['destination'])) { |
|
| 905 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 906 | + } |
|
| 907 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 908 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 909 | + } |
|
| 664 | 910 | $data['format_source'] = 'boatnerd'; |
| 665 | 911 | $data['id_source'] = $id_source; |
| 666 | 912 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 667 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 668 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 913 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 914 | + $data['noarchive'] = true; |
|
| 915 | + } |
|
| 916 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 917 | + $MI->add($data); |
|
| 918 | + } |
|
| 669 | 919 | unset($data); |
| 670 | 920 | } |
| 671 | 921 | } |
@@ -682,7 +932,9 @@ discard block |
||
| 682 | 932 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 683 | 933 | echo 'done !'."\n"; |
| 684 | 934 | // FIXME: Need more work |
| 685 | - if ($buffer != '') $reset = 0; |
|
| 935 | + if ($buffer != '') { |
|
| 936 | + $reset = 0; |
|
| 937 | + } |
|
| 686 | 938 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 687 | 939 | $buffer = explode('\n',$buffer); |
| 688 | 940 | foreach ($buffer as $line) { |
@@ -708,7 +960,9 @@ discard block |
||
| 708 | 960 | //$data['etaTime'] = substr($line,135,5); |
| 709 | 961 | $data['format_source'] = 'shipplotter'; |
| 710 | 962 | $data['id_source'] = $id_source; |
| 711 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 963 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 964 | + $data['noarchive'] = true; |
|
| 965 | + } |
|
| 712 | 966 | //print_r($data); |
| 713 | 967 | echo 'Add...'."\n"; |
| 714 | 968 | $MI->add($data); |
@@ -742,16 +996,28 @@ discard block |
||
| 742 | 996 | $line = explode(':', $line); |
| 743 | 997 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 744 | 998 | $data = array(); |
| 745 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 746 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 999 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1000 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1001 | + } else { |
|
| 1002 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1003 | + } |
|
| 747 | 1004 | $data['pilot_id'] = $line[1]; |
| 748 | 1005 | $data['pilot_name'] = $line[2]; |
| 749 | 1006 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 750 | 1007 | $data['ident'] = $line[0]; // ident |
| 751 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1008 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1009 | + $data['altitude'] = $line[7]; |
|
| 1010 | + } |
|
| 1011 | + // altitude |
|
| 752 | 1012 | $data['speed'] = $line[8]; // speed |
| 753 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 754 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1013 | + if (isset($line[45])) { |
|
| 1014 | + $data['heading'] = $line[45]; |
|
| 1015 | + } |
|
| 1016 | + // heading |
|
| 1017 | + elseif (isset($line[38])) { |
|
| 1018 | + $data['heading'] = $line[38]; |
|
| 1019 | + } |
|
| 1020 | + // heading |
|
| 755 | 1021 | $data['latitude'] = $line[5]; // lat |
| 756 | 1022 | $data['longitude'] = $line[6]; // long |
| 757 | 1023 | $data['verticalrate'] = ''; // vertical rate |
@@ -767,7 +1033,9 @@ discard block |
||
| 767 | 1033 | $data['frequency'] = $line[4]; |
| 768 | 1034 | $data['type'] = $line[18]; |
| 769 | 1035 | $data['range'] = $line[19]; |
| 770 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1036 | + if (isset($line[35])) { |
|
| 1037 | + $data['info'] = $line[35]; |
|
| 1038 | + } |
|
| 771 | 1039 | $data['id_source'] = $id_source; |
| 772 | 1040 | //$data['arrival_airport_time'] = ; |
| 773 | 1041 | if ($line[9] != '') { |
@@ -781,27 +1049,47 @@ discard block |
||
| 781 | 1049 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 782 | 1050 | */ |
| 783 | 1051 | $data['format_source'] = $value['format']; |
| 784 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 785 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 786 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 787 | - elseif ($line[3] == 'ATC') { |
|
| 1052 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1053 | + $data['noarchive'] = true; |
|
| 1054 | + } |
|
| 1055 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1056 | + $data['source_name'] = $value['name']; |
|
| 1057 | + } |
|
| 1058 | + if ($line[3] == 'PILOT') { |
|
| 1059 | + $SI->add($data); |
|
| 1060 | + } elseif ($line[3] == 'ATC') { |
|
| 788 | 1061 | //print_r($data); |
| 789 | 1062 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 790 | 1063 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 791 | 1064 | $typec = substr($data['ident'],-3); |
| 792 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 793 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 794 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 795 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 796 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 797 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 798 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 799 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 800 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 801 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1065 | + if ($typec == 'APP') { |
|
| 1066 | + $data['type'] = 'Approach'; |
|
| 1067 | + } elseif ($typec == 'TWR') { |
|
| 1068 | + $data['type'] = 'Tower'; |
|
| 1069 | + } elseif ($typec == 'OBS') { |
|
| 1070 | + $data['type'] = 'Observer'; |
|
| 1071 | + } elseif ($typec == 'GND') { |
|
| 1072 | + $data['type'] = 'Ground'; |
|
| 1073 | + } elseif ($typec == 'DEL') { |
|
| 1074 | + $data['type'] = 'Delivery'; |
|
| 1075 | + } elseif ($typec == 'DEP') { |
|
| 1076 | + $data['type'] = 'Departure'; |
|
| 1077 | + } elseif ($typec == 'FSS') { |
|
| 1078 | + $data['type'] = 'Flight Service Station'; |
|
| 1079 | + } elseif ($typec == 'CTR') { |
|
| 1080 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1081 | + } elseif ($data['type'] == '') { |
|
| 1082 | + $data['type'] = 'Observer'; |
|
| 1083 | + } |
|
| 1084 | + if (!isset($data['source_name'])) { |
|
| 1085 | + $data['source_name'] = ''; |
|
| 1086 | + } |
|
| 802 | 1087 | if (isset($ATC)) { |
| 803 | - 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']); |
|
| 804 | - 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']); |
|
| 1088 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1089 | + 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']); |
|
| 1090 | + } else { |
|
| 1091 | + 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']); |
|
| 1092 | + } |
|
| 805 | 1093 | } |
| 806 | 1094 | } |
| 807 | 1095 | unset($data); |
@@ -828,14 +1116,20 @@ discard block |
||
| 828 | 1116 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 829 | 1117 | $data['latitude'] = (float)$line['pktLatitude']; |
| 830 | 1118 | $data['longitude'] = (float)$line['pktLongitude']; |
| 831 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 832 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1119 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1120 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1121 | + } |
|
| 1122 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1123 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1124 | + } |
|
| 833 | 1125 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 834 | 1126 | $data['altitude_relative'] = 'AMSL'; |
| 835 | 1127 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 836 | 1128 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 837 | 1129 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 838 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1130 | + if (isset($pilot_data[4])) { |
|
| 1131 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1132 | + } |
|
| 839 | 1133 | $data['format_source'] = $value['format']; |
| 840 | 1134 | $SI->add($data); |
| 841 | 1135 | unset($data); |
@@ -883,25 +1177,59 @@ discard block |
||
| 883 | 1177 | foreach ($all_data['acList'] as $line) { |
| 884 | 1178 | $data = array(); |
| 885 | 1179 | $data['hex'] = $line['Icao']; // hex |
| 886 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 887 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 888 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 889 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 890 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 891 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1180 | + if (isset($line['Call'])) { |
|
| 1181 | + $data['ident'] = $line['Call']; |
|
| 1182 | + } |
|
| 1183 | + // ident |
|
| 1184 | + if (isset($line['Alt'])) { |
|
| 1185 | + $data['altitude'] = $line['Alt']; |
|
| 1186 | + } |
|
| 1187 | + // altitude |
|
| 1188 | + if (isset($line['Spd'])) { |
|
| 1189 | + $data['speed'] = $line['Spd']; |
|
| 1190 | + } |
|
| 1191 | + // speed |
|
| 1192 | + if (isset($line['Trak'])) { |
|
| 1193 | + $data['heading'] = $line['Trak']; |
|
| 1194 | + } |
|
| 1195 | + // heading |
|
| 1196 | + if (isset($line['Lat'])) { |
|
| 1197 | + $data['latitude'] = $line['Lat']; |
|
| 1198 | + } |
|
| 1199 | + // lat |
|
| 1200 | + if (isset($line['Long'])) { |
|
| 1201 | + $data['longitude'] = $line['Long']; |
|
| 1202 | + } |
|
| 1203 | + // long |
|
| 892 | 1204 | //$data['verticalrate'] = $line['']; // verticale rate |
| 893 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1205 | + if (isset($line['Sqk'])) { |
|
| 1206 | + $data['squawk'] = $line['Sqk']; |
|
| 1207 | + } |
|
| 1208 | + // squawk |
|
| 894 | 1209 | $data['emergency'] = ''; // emergency |
| 895 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 896 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 897 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1210 | + if (isset($line['Reg'])) { |
|
| 1211 | + $data['registration'] = $line['Reg']; |
|
| 1212 | + } |
|
| 1213 | + if (isset($line['PosTime'])) { |
|
| 1214 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1215 | + } else { |
|
| 1216 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1217 | + } |
|
| 898 | 1218 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 899 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1219 | + if (isset($line['Type'])) { |
|
| 1220 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1221 | + } |
|
| 900 | 1222 | $data['format_source'] = 'aircraftlistjson'; |
| 901 | 1223 | $data['id_source'] = $id_source; |
| 902 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 903 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 904 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1224 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1225 | + $data['source_name'] = $value['name']; |
|
| 1226 | + } |
|
| 1227 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1228 | + $data['noarchive'] = true; |
|
| 1229 | + } |
|
| 1230 | + if (isset($data['latitude'])) { |
|
| 1231 | + $SI->add($data); |
|
| 1232 | + } |
|
| 905 | 1233 | unset($data); |
| 906 | 1234 | } |
| 907 | 1235 | } elseif (is_array($all_data)) { |
@@ -918,17 +1246,26 @@ discard block |
||
| 918 | 1246 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 919 | 1247 | $data['squawk'] = $line['squawk']; // squawk |
| 920 | 1248 | $data['emergency'] = ''; // emergency |
| 921 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 922 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1249 | + if (isset($line['PosTime'])) { |
|
| 1250 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1251 | + } else { |
|
| 1252 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1253 | + } |
|
| 923 | 1254 | $data['format_source'] = 'aircraftlistjson'; |
| 924 | 1255 | $data['id_source'] = $id_source; |
| 925 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 926 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1256 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1257 | + $data['noarchive'] = true; |
|
| 1258 | + } |
|
| 1259 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1260 | + $data['source_name'] = $value['name']; |
|
| 1261 | + } |
|
| 927 | 1262 | $SI->add($data); |
| 928 | 1263 | unset($data); |
| 929 | 1264 | } |
| 930 | 1265 | } |
| 931 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1266 | + } elseif ($globalDebug) { |
|
| 1267 | + echo 'No data'."\n"; |
|
| 1268 | + } |
|
| 932 | 1269 | //$last_exec['aircraftlistjson'] = time(); |
| 933 | 1270 | $last_exec[$id]['last'] = time(); |
| 934 | 1271 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -964,8 +1301,12 @@ discard block |
||
| 964 | 1301 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 965 | 1302 | $data['format_source'] = 'planeupdatefaa'; |
| 966 | 1303 | $data['id_source'] = $id_source; |
| 967 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 968 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1304 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1305 | + $data['noarchive'] = true; |
|
| 1306 | + } |
|
| 1307 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1308 | + $data['source_name'] = $value['name']; |
|
| 1309 | + } |
|
| 969 | 1310 | $SI->add($data); |
| 970 | 1311 | unset($data); |
| 971 | 1312 | } |
@@ -999,7 +1340,9 @@ discard block |
||
| 999 | 1340 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1000 | 1341 | $data['format_source'] = 'opensky'; |
| 1001 | 1342 | $data['id_source'] = $id_source; |
| 1002 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1343 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1344 | + $data['noarchive'] = true; |
|
| 1345 | + } |
|
| 1003 | 1346 | $SI->add($data); |
| 1004 | 1347 | unset($data); |
| 1005 | 1348 | } |
@@ -1016,7 +1359,9 @@ discard block |
||
| 1016 | 1359 | //$buffer = $Common->getData($hosts[$id]); |
| 1017 | 1360 | $buffer = $Common->getData($value['host']); |
| 1018 | 1361 | $all_data = json_decode($buffer,true); |
| 1019 | - if (!empty($all_data)) $reset = 0; |
|
| 1362 | + if (!empty($all_data)) { |
|
| 1363 | + $reset = 0; |
|
| 1364 | + } |
|
| 1020 | 1365 | foreach ($all_data as $key => $line) { |
| 1021 | 1366 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1022 | 1367 | $data = array(); |
@@ -1037,8 +1382,12 @@ discard block |
||
| 1037 | 1382 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1038 | 1383 | $data['format_source'] = 'fr24json'; |
| 1039 | 1384 | $data['id_source'] = $id_source; |
| 1040 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1041 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1385 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1386 | + $data['noarchive'] = true; |
|
| 1387 | + } |
|
| 1388 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1389 | + $data['source_name'] = $value['name']; |
|
| 1390 | + } |
|
| 1042 | 1391 | $SI->add($data); |
| 1043 | 1392 | unset($data); |
| 1044 | 1393 | } |
@@ -1067,24 +1416,42 @@ discard block |
||
| 1067 | 1416 | if (isset($line['inf'])) { |
| 1068 | 1417 | $data = array(); |
| 1069 | 1418 | $data['hex'] = $line['inf']['ia']; |
| 1070 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1419 | + if (isset($line['inf']['cs'])) { |
|
| 1420 | + $data['ident'] = $line['inf']['cs']; |
|
| 1421 | + } |
|
| 1422 | + //$line[13] |
|
| 1071 | 1423 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1072 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1073 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1424 | + if (isset($line['inf']['gs'])) { |
|
| 1425 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1426 | + } |
|
| 1427 | + // speed |
|
| 1428 | + if (isset($line['inf']['tr'])) { |
|
| 1429 | + $data['heading'] = $line['inf']['tr']; |
|
| 1430 | + } |
|
| 1431 | + // heading |
|
| 1074 | 1432 | $data['latitude'] = $line['pt'][0]; // lat |
| 1075 | 1433 | $data['longitude'] = $line['pt'][1]; // long |
| 1076 | 1434 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1077 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1435 | + if (isset($line['inf']['sq'])) { |
|
| 1436 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1437 | + } |
|
| 1438 | + // squawk |
|
| 1078 | 1439 | //$data['aircraft_icao'] = $line[8]; |
| 1079 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1440 | + if (isset($line['inf']['rc'])) { |
|
| 1441 | + $data['registration'] = $line['inf']['rc']; |
|
| 1442 | + } |
|
| 1080 | 1443 | //$data['departure_airport_iata'] = $line[11]; |
| 1081 | 1444 | //$data['arrival_airport_iata'] = $line[12]; |
| 1082 | 1445 | //$data['emergency'] = ''; // emergency |
| 1083 | 1446 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1084 | 1447 | $data['format_source'] = 'radarvirtueljson'; |
| 1085 | 1448 | $data['id_source'] = $id_source; |
| 1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1450 | + $data['noarchive'] = true; |
|
| 1451 | + } |
|
| 1452 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1453 | + $data['source_name'] = $value['name']; |
|
| 1454 | + } |
|
| 1088 | 1455 | $SI->add($data); |
| 1089 | 1456 | unset($data); |
| 1090 | 1457 | } |
@@ -1110,30 +1477,65 @@ discard block |
||
| 1110 | 1477 | $data['id'] = $line['id']; |
| 1111 | 1478 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1112 | 1479 | $data['ident'] = $line['callsign']; // ident |
| 1113 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1114 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1115 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1116 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1117 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1118 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1480 | + if (isset($line['pilotid'])) { |
|
| 1481 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1482 | + } |
|
| 1483 | + // pilot id |
|
| 1484 | + if (isset($line['name'])) { |
|
| 1485 | + $data['pilot_name'] = $line['name']; |
|
| 1486 | + } |
|
| 1487 | + // pilot name |
|
| 1488 | + if (isset($line['alt'])) { |
|
| 1489 | + $data['altitude'] = $line['alt']; |
|
| 1490 | + } |
|
| 1491 | + // altitude |
|
| 1492 | + if (isset($line['gs'])) { |
|
| 1493 | + $data['speed'] = $line['gs']; |
|
| 1494 | + } |
|
| 1495 | + // speed |
|
| 1496 | + if (isset($line['heading'])) { |
|
| 1497 | + $data['heading'] = $line['heading']; |
|
| 1498 | + } |
|
| 1499 | + // heading |
|
| 1500 | + if (isset($line['route'])) { |
|
| 1501 | + $data['waypoints'] = $line['route']; |
|
| 1502 | + } |
|
| 1503 | + // route |
|
| 1119 | 1504 | $data['latitude'] = $line['lat']; // lat |
| 1120 | 1505 | $data['longitude'] = $line['lon']; // long |
| 1121 | 1506 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1122 | 1507 | //$data['squawk'] = $line['squawk']; // squawk |
| 1123 | 1508 | //$data['emergency'] = ''; // emergency |
| 1124 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1125 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1126 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1509 | + if (isset($line['depicao'])) { |
|
| 1510 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1511 | + } |
|
| 1512 | + if (isset($line['deptime'])) { |
|
| 1513 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1514 | + } |
|
| 1515 | + if (isset($line['arricao'])) { |
|
| 1516 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1517 | + } |
|
| 1127 | 1518 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1128 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1129 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1130 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1131 | - else $data['info'] = ''; |
|
| 1519 | + if (isset($line['aircraft'])) { |
|
| 1520 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1521 | + } |
|
| 1522 | + if (isset($line['transponder'])) { |
|
| 1523 | + $data['squawk'] = $line['transponder']; |
|
| 1524 | + } |
|
| 1525 | + if (isset($line['atis'])) { |
|
| 1526 | + $data['info'] = $line['atis']; |
|
| 1527 | + } else { |
|
| 1528 | + $data['info'] = ''; |
|
| 1529 | + } |
|
| 1132 | 1530 | $data['format_source'] = 'pireps'; |
| 1133 | 1531 | $data['id_source'] = $id_source; |
| 1134 | 1532 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1135 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1136 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1533 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1534 | + $data['noarchive'] = true; |
|
| 1535 | + } |
|
| 1536 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1537 | + $data['source_name'] = $value['name']; |
|
| 1538 | + } |
|
| 1137 | 1539 | if ($line['icon'] == 'plane') { |
| 1138 | 1540 | $SI->add($data); |
| 1139 | 1541 | // print_r($data); |
@@ -1142,16 +1544,28 @@ discard block |
||
| 1142 | 1544 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1143 | 1545 | $typec = substr($data['ident'],-3); |
| 1144 | 1546 | $data['type'] = ''; |
| 1145 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 1146 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 1147 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 1148 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 1149 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 1150 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 1151 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1152 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1153 | - else $data['type'] = 'Observer'; |
|
| 1154 | - 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']); |
|
| 1547 | + if ($typec == 'APP') { |
|
| 1548 | + $data['type'] = 'Approach'; |
|
| 1549 | + } elseif ($typec == 'TWR') { |
|
| 1550 | + $data['type'] = 'Tower'; |
|
| 1551 | + } elseif ($typec == 'OBS') { |
|
| 1552 | + $data['type'] = 'Observer'; |
|
| 1553 | + } elseif ($typec == 'GND') { |
|
| 1554 | + $data['type'] = 'Ground'; |
|
| 1555 | + } elseif ($typec == 'DEL') { |
|
| 1556 | + $data['type'] = 'Delivery'; |
|
| 1557 | + } elseif ($typec == 'DEP') { |
|
| 1558 | + $data['type'] = 'Departure'; |
|
| 1559 | + } elseif ($typec == 'FSS') { |
|
| 1560 | + $data['type'] = 'Flight Service Station'; |
|
| 1561 | + } elseif ($typec == 'CTR') { |
|
| 1562 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1563 | + } else { |
|
| 1564 | + $data['type'] = 'Observer'; |
|
| 1565 | + } |
|
| 1566 | + if (isset($ATC)) { |
|
| 1567 | + 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']); |
|
| 1568 | + } |
|
| 1155 | 1569 | } |
| 1156 | 1570 | unset($data); |
| 1157 | 1571 | } |
@@ -1166,7 +1580,9 @@ discard block |
||
| 1166 | 1580 | ) |
| 1167 | 1581 | ) { |
| 1168 | 1582 | //$buffer = $Common->getData($hosts[$id]); |
| 1169 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1583 | + if ($globalDebug) { |
|
| 1584 | + echo 'Get Data...'."\n"; |
|
| 1585 | + } |
|
| 1170 | 1586 | $buffer = $Common->getData($value['host']); |
| 1171 | 1587 | $all_data = json_decode($buffer,true); |
| 1172 | 1588 | if ($buffer != '' && is_array($all_data)) { |
@@ -1174,10 +1590,16 @@ discard block |
||
| 1174 | 1590 | foreach ($all_data as $line) { |
| 1175 | 1591 | $data = array(); |
| 1176 | 1592 | //$data['id'] = $line['id']; // id not usable |
| 1177 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1593 | + if (isset($line['pilotid'])) { |
|
| 1594 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1595 | + } |
|
| 1178 | 1596 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1179 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1180 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1597 | + if (isset($line['pilotname'])) { |
|
| 1598 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1599 | + } |
|
| 1600 | + if (isset($line['pilotid'])) { |
|
| 1601 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1602 | + } |
|
| 1181 | 1603 | $data['ident'] = $line['flightnum']; // ident |
| 1182 | 1604 | $data['altitude'] = $line['alt']; // altitude |
| 1183 | 1605 | $data['speed'] = $line['gs']; // speed |
@@ -1193,7 +1615,9 @@ discard block |
||
| 1193 | 1615 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1194 | 1616 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1195 | 1617 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1196 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1618 | + } else { |
|
| 1619 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1620 | + } |
|
| 1197 | 1621 | $data['departure_airport_icao'] = $line['depicao']; |
| 1198 | 1622 | $data['departure_airport_time'] = $line['deptime']; |
| 1199 | 1623 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1201,29 +1625,47 @@ discard block |
||
| 1201 | 1625 | if (isset($line['registration'])) { |
| 1202 | 1626 | $data['registration'] = $line['registration']; |
| 1203 | 1627 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1204 | - } else $data['registration'] = $line['aircraft']; |
|
| 1205 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1206 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1628 | + } else { |
|
| 1629 | + $data['registration'] = $line['aircraft']; |
|
| 1630 | + } |
|
| 1631 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1632 | + $data['noarchive'] = true; |
|
| 1633 | + } |
|
| 1634 | + if (isset($line['route'])) { |
|
| 1635 | + $data['waypoints'] = $line['route']; |
|
| 1636 | + } |
|
| 1637 | + // route |
|
| 1207 | 1638 | if (isset($line['aircraftname'])) { |
| 1208 | 1639 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1209 | 1640 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1210 | 1641 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1211 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1212 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1213 | - else { |
|
| 1642 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1643 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1644 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1645 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1646 | + } else { |
|
| 1214 | 1647 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1215 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1216 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1648 | + if (isset($aircraft_data[1])) { |
|
| 1649 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1650 | + } else { |
|
| 1651 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1652 | + } |
|
| 1217 | 1653 | } |
| 1218 | 1654 | } |
| 1219 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1655 | + if (isset($line['route'])) { |
|
| 1656 | + $data['waypoints'] = $line['route']; |
|
| 1657 | + } |
|
| 1220 | 1658 | $data['id_source'] = $id_source; |
| 1221 | 1659 | $data['format_source'] = 'phpvmacars'; |
| 1222 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1660 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1661 | + $data['source_name'] = $value['name']; |
|
| 1662 | + } |
|
| 1223 | 1663 | $SI->add($data); |
| 1224 | 1664 | unset($data); |
| 1225 | 1665 | } |
| 1226 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1666 | + if ($globalDebug) { |
|
| 1667 | + echo 'No more data...'."\n"; |
|
| 1668 | + } |
|
| 1227 | 1669 | unset($buffer); |
| 1228 | 1670 | unset($all_data); |
| 1229 | 1671 | } |
@@ -1236,7 +1678,9 @@ discard block |
||
| 1236 | 1678 | ) |
| 1237 | 1679 | ) { |
| 1238 | 1680 | //$buffer = $Common->getData($hosts[$id]); |
| 1239 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1681 | + if ($globalDebug) { |
|
| 1682 | + echo 'Get Data...'."\n"; |
|
| 1683 | + } |
|
| 1240 | 1684 | $buffer = $Common->getData($value['host']); |
| 1241 | 1685 | $all_data = json_decode($buffer,true); |
| 1242 | 1686 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1247,10 +1691,16 @@ discard block |
||
| 1247 | 1691 | //$data['id'] = $line['id']; // id not usable |
| 1248 | 1692 | $data['id'] = $line['id']; |
| 1249 | 1693 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1250 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1251 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1694 | + if (isset($line['user']['username'])) { |
|
| 1695 | + $data['pilot_name'] = $line['user']['username']; |
|
| 1696 | + } |
|
| 1697 | + if (isset($line['user_id'])) { |
|
| 1698 | + $data['pilot_id'] = $line['user_id']; |
|
| 1699 | + } |
|
| 1252 | 1700 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1253 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1701 | + if (is_numeric($data['ident'])) { |
|
| 1702 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1703 | + } |
|
| 1254 | 1704 | $data['altitude'] = $line['altitude']; // altitude |
| 1255 | 1705 | $data['speed'] = $line['groundspeed']; // speed |
| 1256 | 1706 | $data['heading'] = $line['heading']; // heading |
@@ -1263,7 +1713,9 @@ discard block |
||
| 1263 | 1713 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1264 | 1714 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1265 | 1715 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1266 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1716 | + } else { |
|
| 1717 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1718 | + } |
|
| 1267 | 1719 | |
| 1268 | 1720 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1269 | 1721 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1271,17 +1723,26 @@ discard block |
||
| 1271 | 1723 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1272 | 1724 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1273 | 1725 | |
| 1274 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1275 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1726 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1727 | + $data['noarchive'] = true; |
|
| 1728 | + } |
|
| 1729 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 1730 | + $data['waypoints'] = $line['bid']['route']; |
|
| 1731 | + } |
|
| 1732 | + // route |
|
| 1276 | 1733 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1277 | 1734 | |
| 1278 | 1735 | $data['id_source'] = $id_source; |
| 1279 | 1736 | $data['format_source'] = 'vaos'; |
| 1280 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1737 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1738 | + $data['source_name'] = $value['name']; |
|
| 1739 | + } |
|
| 1281 | 1740 | $SI->add($data); |
| 1282 | 1741 | unset($data); |
| 1283 | 1742 | } |
| 1284 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1743 | + if ($globalDebug) { |
|
| 1744 | + echo 'No more data...'."\n"; |
|
| 1745 | + } |
|
| 1285 | 1746 | unset($buffer); |
| 1286 | 1747 | unset($all_data); |
| 1287 | 1748 | } |
@@ -1294,7 +1755,9 @@ discard block |
||
| 1294 | 1755 | ) |
| 1295 | 1756 | ) { |
| 1296 | 1757 | //$buffer = $Common->getData($hosts[$id]); |
| 1297 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1758 | + if ($globalDebug) { |
|
| 1759 | + echo 'Get Data...'."\n"; |
|
| 1760 | + } |
|
| 1298 | 1761 | $buffer = $Common->getData($value['host']); |
| 1299 | 1762 | $all_data = json_decode($buffer,true); |
| 1300 | 1763 | if ($buffer != '' && is_array($all_data)) { |
@@ -1323,16 +1786,25 @@ discard block |
||
| 1323 | 1786 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1324 | 1787 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1325 | 1788 | //$data['registration'] = $line['aircraft']; |
| 1326 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1789 | + if (isset($line['route'])) { |
|
| 1790 | + $data['waypoints'] = $line['route']; |
|
| 1791 | + } |
|
| 1792 | + // route |
|
| 1327 | 1793 | $data['aircraft_icao'] = $line['plane_type']; |
| 1328 | 1794 | $data['id_source'] = $id_source; |
| 1329 | 1795 | $data['format_source'] = 'vam'; |
| 1330 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1331 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1796 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1797 | + $data['noarchive'] = true; |
|
| 1798 | + } |
|
| 1799 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1800 | + $data['source_name'] = $value['name']; |
|
| 1801 | + } |
|
| 1332 | 1802 | $SI->add($data); |
| 1333 | 1803 | unset($data); |
| 1334 | 1804 | } |
| 1335 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1805 | + if ($globalDebug) { |
|
| 1806 | + echo 'No more data...'."\n"; |
|
| 1807 | + } |
|
| 1336 | 1808 | unset($buffer); |
| 1337 | 1809 | unset($all_data); |
| 1338 | 1810 | } |
@@ -1345,7 +1817,9 @@ discard block |
||
| 1345 | 1817 | ) |
| 1346 | 1818 | ) { |
| 1347 | 1819 | //$buffer = $Common->getData($hosts[$id]); |
| 1348 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1820 | + if ($globalDebug) { |
|
| 1821 | + echo 'Get Data...'."\n"; |
|
| 1822 | + } |
|
| 1349 | 1823 | $buffer = $Common->getData($value['host']); |
| 1350 | 1824 | $all_data = json_decode($buffer,true); |
| 1351 | 1825 | if ($buffer != '') { |
@@ -1363,18 +1837,24 @@ discard block |
||
| 1363 | 1837 | $data['id_source'] = $id_source; |
| 1364 | 1838 | $data['format_source'] = 'blitzortung'; |
| 1365 | 1839 | $SI->add($data); |
| 1366 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 1840 | + if ($globalDebug) { |
|
| 1841 | + echo '☈ Lightning added'."\n"; |
|
| 1842 | + } |
|
| 1367 | 1843 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1368 | 1844 | unset($data); |
| 1369 | 1845 | } |
| 1370 | 1846 | } |
| 1371 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1847 | + if ($globalDebug) { |
|
| 1848 | + echo 'No more data...'."\n"; |
|
| 1849 | + } |
|
| 1372 | 1850 | unset($buffer); |
| 1373 | 1851 | } |
| 1374 | 1852 | $last_exec[$id]['last'] = time(); |
| 1375 | 1853 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1376 | 1854 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1377 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1855 | + if (function_exists('pcntl_fork')) { |
|
| 1856 | + pcntl_signal_dispatch(); |
|
| 1857 | + } |
|
| 1378 | 1858 | //$last_exec[$id]['last'] = time(); |
| 1379 | 1859 | |
| 1380 | 1860 | //$read = array( $sockets[$id] ); |
@@ -1382,7 +1862,9 @@ discard block |
||
| 1382 | 1862 | $write = NULL; |
| 1383 | 1863 | $e = NULL; |
| 1384 | 1864 | $n = socket_select($read, $write, $e, $timeout); |
| 1385 | - if ($e != NULL) var_dump($e); |
|
| 1865 | + if ($e != NULL) { |
|
| 1866 | + var_dump($e); |
|
| 1867 | + } |
|
| 1386 | 1868 | if ($n > 0) { |
| 1387 | 1869 | $reset = 0; |
| 1388 | 1870 | foreach ($read as $nb => $r) { |
@@ -1404,13 +1886,17 @@ discard block |
||
| 1404 | 1886 | if ($buffer !== FALSE) { |
| 1405 | 1887 | if ($format == 'vrstcp') { |
| 1406 | 1888 | $buffer = explode('},{',$buffer); |
| 1407 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1889 | + } else { |
|
| 1890 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1891 | + } |
|
| 1408 | 1892 | } |
| 1409 | 1893 | // SBS format is CSV format |
| 1410 | 1894 | if ($buffer !== FALSE && $buffer !== '') { |
| 1411 | 1895 | $tt[$format] = 0; |
| 1412 | 1896 | if ($format == 'acarssbs3') { |
| 1413 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1897 | + if ($globalDebug) { |
|
| 1898 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1899 | + } |
|
| 1414 | 1900 | $ACARS->add(trim($buffer)); |
| 1415 | 1901 | $ACARS->deleteLiveAcarsData(); |
| 1416 | 1902 | } elseif ($format == 'raw') { |
@@ -1419,30 +1905,70 @@ discard block |
||
| 1419 | 1905 | if (is_array($data)) { |
| 1420 | 1906 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1421 | 1907 | $data['format_source'] = 'raw'; |
| 1422 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1423 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1424 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1425 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1908 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1909 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1910 | + } |
|
| 1911 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1912 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1913 | + } |
|
| 1914 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1915 | + $data['noarchive'] = true; |
|
| 1916 | + } |
|
| 1917 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1918 | + $SI->add($data); |
|
| 1919 | + } |
|
| 1426 | 1920 | } |
| 1427 | 1921 | } elseif ($format == 'ais') { |
| 1428 | 1922 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1429 | 1923 | $data = array(); |
| 1430 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1431 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1432 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1433 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1434 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1435 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1436 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1437 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1438 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1439 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1440 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1441 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1442 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1443 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1444 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1445 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1924 | + if (isset($ais_data['ident'])) { |
|
| 1925 | + $data['ident'] = $ais_data['ident']; |
|
| 1926 | + } |
|
| 1927 | + if (isset($ais_data['mmsi'])) { |
|
| 1928 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1929 | + } |
|
| 1930 | + if (isset($ais_data['speed'])) { |
|
| 1931 | + $data['speed'] = $ais_data['speed']; |
|
| 1932 | + } |
|
| 1933 | + if (isset($ais_data['heading'])) { |
|
| 1934 | + $data['heading'] = $ais_data['heading']; |
|
| 1935 | + } |
|
| 1936 | + if (isset($ais_data['latitude'])) { |
|
| 1937 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1938 | + } |
|
| 1939 | + if (isset($ais_data['longitude'])) { |
|
| 1940 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1941 | + } |
|
| 1942 | + if (isset($ais_data['status'])) { |
|
| 1943 | + $data['status'] = $ais_data['status']; |
|
| 1944 | + } |
|
| 1945 | + if (isset($ais_data['statusid'])) { |
|
| 1946 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1947 | + } |
|
| 1948 | + if (isset($ais_data['type'])) { |
|
| 1949 | + $data['type'] = $ais_data['type']; |
|
| 1950 | + } |
|
| 1951 | + if (isset($ais_data['imo'])) { |
|
| 1952 | + $data['imo'] = $ais_data['imo']; |
|
| 1953 | + } |
|
| 1954 | + if (isset($ais_data['callsign'])) { |
|
| 1955 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1956 | + } |
|
| 1957 | + if (isset($ais_data['destination'])) { |
|
| 1958 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1959 | + } |
|
| 1960 | + if (isset($ais_data['eta_ts'])) { |
|
| 1961 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1962 | + } |
|
| 1963 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1964 | + $data['noarchive'] = true; |
|
| 1965 | + } |
|
| 1966 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1967 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1968 | + } |
|
| 1969 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1970 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1971 | + } |
|
| 1446 | 1972 | |
| 1447 | 1973 | if (isset($ais_data['timestamp'])) { |
| 1448 | 1974 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1451,7 +1977,9 @@ discard block |
||
| 1451 | 1977 | } |
| 1452 | 1978 | $data['format_source'] = 'aisnmea'; |
| 1453 | 1979 | $data['id_source'] = $id_source; |
| 1454 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1980 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1981 | + $MI->add($data); |
|
| 1982 | + } |
|
| 1455 | 1983 | unset($data); |
| 1456 | 1984 | } elseif ($format == 'flightgearsp') { |
| 1457 | 1985 | //echo $buffer."\n"; |
@@ -1469,12 +1997,18 @@ discard block |
||
| 1469 | 1997 | $data['speed'] = round($line[5]*1.94384); |
| 1470 | 1998 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1471 | 1999 | $data['format_source'] = 'flightgearsp'; |
| 1472 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1473 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2000 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2001 | + $data['noarchive'] = true; |
|
| 2002 | + } |
|
| 2003 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2004 | + $SI->add($data); |
|
| 2005 | + } |
|
| 1474 | 2006 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1475 | 2007 | } |
| 1476 | 2008 | } elseif ($format == 'acars') { |
| 1477 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2009 | + if ($globalDebug) { |
|
| 2010 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2011 | + } |
|
| 1478 | 2012 | $ACARS->add(trim($buffer)); |
| 1479 | 2013 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1480 | 2014 | $ACARS->deleteLiveAcarsData(); |
@@ -1495,8 +2029,12 @@ discard block |
||
| 1495 | 2029 | $aircraft_type = $line[10]; |
| 1496 | 2030 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1497 | 2031 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1498 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1499 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2032 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2033 | + $data['noarchive'] = true; |
|
| 2034 | + } |
|
| 2035 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2036 | + $SI->add($data); |
|
| 2037 | + } |
|
| 1500 | 2038 | } |
| 1501 | 2039 | } |
| 1502 | 2040 | } elseif ($format == 'beast') { |
@@ -1506,28 +2044,62 @@ discard block |
||
| 1506 | 2044 | foreach($buffer as $all_data) { |
| 1507 | 2045 | $line = json_decode('{'.$all_data.'}',true); |
| 1508 | 2046 | $data = array(); |
| 1509 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1510 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1511 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1512 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1513 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1514 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1515 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2047 | + if (isset($line['Icao'])) { |
|
| 2048 | + $data['hex'] = $line['Icao']; |
|
| 2049 | + } |
|
| 2050 | + // hex |
|
| 2051 | + if (isset($line['Call'])) { |
|
| 2052 | + $data['ident'] = $line['Call']; |
|
| 2053 | + } |
|
| 2054 | + // ident |
|
| 2055 | + if (isset($line['Alt'])) { |
|
| 2056 | + $data['altitude'] = $line['Alt']; |
|
| 2057 | + } |
|
| 2058 | + // altitude |
|
| 2059 | + if (isset($line['Spd'])) { |
|
| 2060 | + $data['speed'] = $line['Spd']; |
|
| 2061 | + } |
|
| 2062 | + // speed |
|
| 2063 | + if (isset($line['Trak'])) { |
|
| 2064 | + $data['heading'] = $line['Trak']; |
|
| 2065 | + } |
|
| 2066 | + // heading |
|
| 2067 | + if (isset($line['Lat'])) { |
|
| 2068 | + $data['latitude'] = $line['Lat']; |
|
| 2069 | + } |
|
| 2070 | + // lat |
|
| 2071 | + if (isset($line['Long'])) { |
|
| 2072 | + $data['longitude'] = $line['Long']; |
|
| 2073 | + } |
|
| 2074 | + // long |
|
| 1516 | 2075 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1517 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2076 | + if (isset($line['Sqk'])) { |
|
| 2077 | + $data['squawk'] = $line['Sqk']; |
|
| 2078 | + } |
|
| 2079 | + // squawk |
|
| 1518 | 2080 | $data['emergency'] = ''; // emergency |
| 1519 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2081 | + if (isset($line['Reg'])) { |
|
| 2082 | + $data['registration'] = $line['Reg']; |
|
| 2083 | + } |
|
| 1520 | 2084 | /* |
| 1521 | 2085 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1522 | 2086 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1523 | 2087 | */ |
| 1524 | 2088 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1525 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2089 | + if (isset($line['Type'])) { |
|
| 2090 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2091 | + } |
|
| 1526 | 2092 | $data['format_source'] = 'vrstcp'; |
| 1527 | 2093 | $data['id_source'] = $id_source; |
| 1528 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1529 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1530 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2094 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2095 | + $data['noarchive'] = true; |
|
| 2096 | + } |
|
| 2097 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2098 | + $data['source_name'] = $value['name']; |
|
| 2099 | + } |
|
| 2100 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2101 | + $SI->add($data); |
|
| 2102 | + } |
|
| 1531 | 2103 | unset($data); |
| 1532 | 2104 | } |
| 1533 | 2105 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1540,22 +2112,46 @@ discard block |
||
| 1540 | 2112 | $data['hex'] = $lined['hexid']; |
| 1541 | 2113 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1542 | 2114 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1543 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1544 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1545 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1546 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1547 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1548 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1549 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2115 | + if (isset($lined['ident'])) { |
|
| 2116 | + $data['ident'] = $lined['ident']; |
|
| 2117 | + } |
|
| 2118 | + if (isset($lined['lat'])) { |
|
| 2119 | + $data['latitude'] = $lined['lat']; |
|
| 2120 | + } |
|
| 2121 | + if (isset($lined['lon'])) { |
|
| 2122 | + $data['longitude'] = $lined['lon']; |
|
| 2123 | + } |
|
| 2124 | + if (isset($lined['speed'])) { |
|
| 2125 | + $data['speed'] = $lined['speed']; |
|
| 2126 | + } |
|
| 2127 | + if (isset($lined['squawk'])) { |
|
| 2128 | + $data['squawk'] = $lined['squawk']; |
|
| 2129 | + } |
|
| 2130 | + if (isset($lined['alt'])) { |
|
| 2131 | + $data['altitude'] = $lined['alt']; |
|
| 2132 | + } |
|
| 2133 | + if (isset($lined['heading'])) { |
|
| 2134 | + $data['heading'] = $lined['heading']; |
|
| 2135 | + } |
|
| 1550 | 2136 | $data['id_source'] = $id_source; |
| 1551 | 2137 | $data['format_source'] = 'tsv'; |
| 1552 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1553 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1554 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1555 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2138 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2139 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2140 | + } |
|
| 2141 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2142 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2143 | + } |
|
| 2144 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2145 | + $data['noarchive'] = true; |
|
| 2146 | + } |
|
| 2147 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2148 | + $SI->add($data); |
|
| 2149 | + } |
|
| 1556 | 2150 | unset($lined); |
| 1557 | 2151 | unset($data); |
| 1558 | - } else $error = true; |
|
| 2152 | + } else { |
|
| 2153 | + $error = true; |
|
| 2154 | + } |
|
| 1559 | 2155 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1560 | 2156 | if ($aprs_connect == 0) { |
| 1561 | 2157 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1581,63 +2177,121 @@ discard block |
||
| 1581 | 2177 | $aprs_last_tx = time(); |
| 1582 | 2178 | $data = array(); |
| 1583 | 2179 | //print_r($line); |
| 1584 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1585 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1586 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1587 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1588 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1589 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1590 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1591 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1592 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1593 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2180 | + if (isset($line['address'])) { |
|
| 2181 | + $data['hex'] = $line['address']; |
|
| 2182 | + } |
|
| 2183 | + if (isset($line['mmsi'])) { |
|
| 2184 | + $data['mmsi'] = $line['mmsi']; |
|
| 2185 | + } |
|
| 2186 | + if (isset($line['imo'])) { |
|
| 2187 | + $data['imo'] = $line['imo']; |
|
| 2188 | + } |
|
| 2189 | + if (isset($line['squawk'])) { |
|
| 2190 | + $data['squawk'] = $line['squawk']; |
|
| 2191 | + } |
|
| 2192 | + if (isset($line['arrival_code'])) { |
|
| 2193 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2194 | + } |
|
| 2195 | + if (isset($line['arrival_date'])) { |
|
| 2196 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2197 | + } |
|
| 2198 | + if (isset($line['type_id'])) { |
|
| 2199 | + $data['type_id'] = $line['typeid']; |
|
| 2200 | + } |
|
| 2201 | + if (isset($line['status_id'])) { |
|
| 2202 | + $data['status_id'] = $line['statusid']; |
|
| 2203 | + } |
|
| 2204 | + if (isset($line['timestamp'])) { |
|
| 2205 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2206 | + } else { |
|
| 2207 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2208 | + } |
|
| 1594 | 2209 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1595 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2210 | + if (isset($line['ident'])) { |
|
| 2211 | + $data['ident'] = $line['ident']; |
|
| 2212 | + } |
|
| 1596 | 2213 | $data['latitude'] = $line['latitude']; |
| 1597 | 2214 | $data['longitude'] = $line['longitude']; |
| 1598 | 2215 | //$data['verticalrate'] = $line[16]; |
| 1599 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2216 | + if (isset($line['speed'])) { |
|
| 2217 | + $data['speed'] = $line['speed']; |
|
| 2218 | + } |
|
| 1600 | 2219 | //else $data['speed'] = 0; |
| 1601 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1602 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1603 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2220 | + if (isset($line['altitude'])) { |
|
| 2221 | + $data['altitude'] = $line['altitude']; |
|
| 2222 | + } |
|
| 2223 | + if (isset($line['comment'])) { |
|
| 2224 | + $data['comment'] = $line['comment']; |
|
| 2225 | + } |
|
| 2226 | + if (isset($line['symbol'])) { |
|
| 2227 | + $data['type'] = $line['symbol']; |
|
| 2228 | + } |
|
| 1604 | 2229 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1605 | 2230 | |
| 1606 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2231 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2232 | + $data['heading'] = $line['heading']; |
|
| 2233 | + } |
|
| 1607 | 2234 | //else echo 'No heading...'."\n"; |
| 1608 | 2235 | //else $data['heading'] = 0; |
| 1609 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2236 | + if (isset($line['stealth'])) { |
|
| 2237 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2238 | + } |
|
| 1610 | 2239 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1611 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1612 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1613 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1614 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2240 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2241 | + $data['noarchive'] = true; |
|
| 2242 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2243 | + $data['noarchive'] = false; |
|
| 2244 | + } |
|
| 2245 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2246 | + $data['noarchive'] = true; |
|
| 2247 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2248 | + $data['noarchive'] = false; |
|
| 2249 | + } |
|
| 1615 | 2250 | $data['id_source'] = $id_source; |
| 1616 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1617 | - else $data['format_source'] = 'aprs'; |
|
| 2251 | + if (isset($line['format_source'])) { |
|
| 2252 | + $data['format_source'] = $line['format_source']; |
|
| 2253 | + } else { |
|
| 2254 | + $data['format_source'] = 'aprs'; |
|
| 2255 | + } |
|
| 1618 | 2256 | $data['source_name'] = $line['source']; |
| 1619 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1620 | - else $data['source_type'] = 'flarm'; |
|
| 1621 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2257 | + if (isset($line['source_type'])) { |
|
| 2258 | + $data['source_type'] = $line['source_type']; |
|
| 2259 | + } else { |
|
| 2260 | + $data['source_type'] = 'flarm'; |
|
| 2261 | + } |
|
| 2262 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2263 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2264 | + } |
|
| 1622 | 2265 | $currentdate = date('Y-m-d H:i:s'); |
| 1623 | 2266 | $aprsdate = strtotime($data['datetime']); |
| 1624 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2267 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2268 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2269 | + } |
|
| 1625 | 2270 | // Accept data if time <= system time + 20s |
| 1626 | 2271 | //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'])))) { |
| 1627 | 2272 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1628 | 2273 | $send = $SI->add($data); |
| 1629 | 2274 | } elseif ($data['source_type'] == 'ais') { |
| 1630 | 2275 | $data['type'] = ''; |
| 1631 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2276 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2277 | + $send = $MI->add($data); |
|
| 2278 | + } |
|
| 1632 | 2279 | } elseif (isset($line['stealth'])) { |
| 1633 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1634 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 2280 | + if ($line['stealth'] != 0) { |
|
| 2281 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 2282 | + } else { |
|
| 2283 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 2284 | + } |
|
| 1635 | 2285 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1636 | 2286 | //$line['symbol'] == 'Balloon' || |
| 1637 | 2287 | $line['symbol'] == 'Glider' || |
| 1638 | 2288 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1639 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1640 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2289 | + if ($line['symbol'] == 'Ballon') { |
|
| 2290 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2291 | + } |
|
| 2292 | + if ($line['symbol'] == 'Glider') { |
|
| 2293 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2294 | + } |
|
| 1641 | 2295 | $send = $SI->add($data); |
| 1642 | 2296 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1643 | 2297 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1668,9 +2322,13 @@ discard block |
||
| 1668 | 2322 | //} 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') { |
| 1669 | 2323 | // } 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') { |
| 1670 | 2324 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1671 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2325 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2326 | + $send = $TI->add($data); |
|
| 2327 | + } |
|
| 1672 | 2328 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1673 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2329 | + if (!isset($data['altitude'])) { |
|
| 2330 | + $data['altitude'] = 0; |
|
| 2331 | + } |
|
| 1674 | 2332 | $Source->deleteOldLocationByType('gs'); |
| 1675 | 2333 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1676 | 2334 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1679,7 +2337,9 @@ discard block |
||
| 1679 | 2337 | } |
| 1680 | 2338 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1681 | 2339 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1682 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2340 | + if ($globalDebug) { |
|
| 2341 | + echo '# Weather Station added'."\n"; |
|
| 2342 | + } |
|
| 1683 | 2343 | $Source->deleteOldLocationByType('wx'); |
| 1684 | 2344 | $weather_data = json_encode($line); |
| 1685 | 2345 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1689,7 +2349,9 @@ discard block |
||
| 1689 | 2349 | } |
| 1690 | 2350 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
| 1691 | 2351 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1692 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2352 | + if ($globalDebug) { |
|
| 2353 | + echo '☈ Lightning added'."\n"; |
|
| 2354 | + } |
|
| 1693 | 2355 | $Source->deleteOldLocationByType('lightning'); |
| 1694 | 2356 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1695 | 2357 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1701,8 +2363,7 @@ discard block |
||
| 1701 | 2363 | print_r($line); |
| 1702 | 2364 | } |
| 1703 | 2365 | unset($data); |
| 1704 | - } |
|
| 1705 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2366 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1706 | 2367 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1707 | 2368 | } |
| 1708 | 2369 | /* |
@@ -1711,7 +2372,9 @@ discard block |
||
| 1711 | 2372 | } |
| 1712 | 2373 | */ |
| 1713 | 2374 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1714 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2375 | + elseif ($line == true && $globalDebug) { |
|
| 2376 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2377 | + } |
|
| 1715 | 2378 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 1716 | 2379 | $Source->deleteOldLocationByType('lightning'); |
| 1717 | 2380 | $Source->deleteOldLocationByType('wx'); |
@@ -1747,26 +2410,45 @@ discard block |
||
| 1747 | 2410 | $data['ground'] = $line[21]; |
| 1748 | 2411 | $data['emergency'] = $line[19]; |
| 1749 | 2412 | $data['format_source'] = 'sbs'; |
| 1750 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1751 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1752 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2413 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2414 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2415 | + } |
|
| 2416 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2417 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2418 | + } |
|
| 2419 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2420 | + $data['noarchive'] = true; |
|
| 2421 | + } |
|
| 1753 | 2422 | $data['id_source'] = $id_source; |
| 1754 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1755 | - else $error = true; |
|
| 2423 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2424 | + $send = $SI->add($data); |
|
| 2425 | + } else { |
|
| 2426 | + $error = true; |
|
| 2427 | + } |
|
| 1756 | 2428 | unset($data); |
| 1757 | - } else $error = true; |
|
| 2429 | + } else { |
|
| 2430 | + $error = true; |
|
| 2431 | + } |
|
| 1758 | 2432 | if ($error) { |
| 1759 | 2433 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1760 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2434 | + if ($globalDebug) { |
|
| 2435 | + echo "Not a message. Ignoring... \n"; |
|
| 2436 | + } |
|
| 1761 | 2437 | } else { |
| 1762 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2438 | + if ($globalDebug) { |
|
| 2439 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2440 | + } |
|
| 1763 | 2441 | if ($globalDebug) { |
| 1764 | 2442 | echo $buffer; |
| 1765 | 2443 | //print_r($line); |
| 1766 | 2444 | } |
| 1767 | 2445 | //socket_close($r); |
| 1768 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1769 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 2446 | + if ($globalDebug) { |
|
| 2447 | + echo "Reconnect after an error...\n"; |
|
| 2448 | + } |
|
| 2449 | + if ($format == 'aprs') { |
|
| 2450 | + $aprs_connect = 0; |
|
| 2451 | + } |
|
| 1770 | 2452 | $sourceer[$nb] = $globalSources[$nb]; |
| 1771 | 2453 | connect_all($sourceer); |
| 1772 | 2454 | $sourceer = array(); |
@@ -1774,10 +2456,14 @@ discard block |
||
| 1774 | 2456 | } |
| 1775 | 2457 | } |
| 1776 | 2458 | // Sleep for xxx microseconds |
| 1777 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2459 | + if (isset($globalSBSSleep)) { |
|
| 2460 | + usleep($globalSBSSleep); |
|
| 2461 | + } |
|
| 1778 | 2462 | } else { |
| 1779 | 2463 | if ($format == 'flightgearmp') { |
| 1780 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2464 | + if ($globalDebug) { |
|
| 2465 | + echo "Reconnect FlightGear MP..."; |
|
| 2466 | + } |
|
| 1781 | 2467 | //@socket_close($r); |
| 1782 | 2468 | sleep($globalMinFetch); |
| 1783 | 2469 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1786,10 +2472,15 @@ discard block |
||
| 1786 | 2472 | break; |
| 1787 | 2473 | |
| 1788 | 2474 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1789 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1790 | - else $tt[$format] = 0; |
|
| 2475 | + if (isset($tt[$format])) { |
|
| 2476 | + $tt[$format]++; |
|
| 2477 | + } else { |
|
| 2478 | + $tt[$format] = 0; |
|
| 2479 | + } |
|
| 1791 | 2480 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 1792 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2481 | + if ($globalDebug) { |
|
| 2482 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2483 | + } |
|
| 1793 | 2484 | //@socket_close($r); |
| 1794 | 2485 | sleep(2); |
| 1795 | 2486 | $aprs_connect = 0; |
@@ -1807,11 +2498,17 @@ discard block |
||
| 1807 | 2498 | } else { |
| 1808 | 2499 | $error = socket_strerror(socket_last_error()); |
| 1809 | 2500 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1810 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1811 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2501 | + if ($globalDebug) { |
|
| 2502 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2503 | + } |
|
| 2504 | + if (isset($globalDebug)) { |
|
| 2505 | + echo "Restarting...\n"; |
|
| 2506 | + } |
|
| 1812 | 2507 | // Restart the script if possible |
| 1813 | 2508 | if (is_array($sockets)) { |
| 1814 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2509 | + if ($globalDebug) { |
|
| 2510 | + echo "Shutdown all sockets..."; |
|
| 2511 | + } |
|
| 1815 | 2512 | |
| 1816 | 2513 | foreach ($sockets as $sock) { |
| 1817 | 2514 | @socket_shutdown($sock,2); |
@@ -1819,25 +2516,45 @@ discard block |
||
| 1819 | 2516 | } |
| 1820 | 2517 | |
| 1821 | 2518 | } |
| 1822 | - if ($globalDebug) echo "Waiting..."; |
|
| 2519 | + if ($globalDebug) { |
|
| 2520 | + echo "Waiting..."; |
|
| 2521 | + } |
|
| 1823 | 2522 | sleep(2); |
| 1824 | 2523 | $time = time(); |
| 1825 | 2524 | //connect_all($hosts); |
| 1826 | 2525 | $aprs_connect = 0; |
| 1827 | - if ($reset%5 == 0) sleep(20); |
|
| 1828 | - if ($reset%10 == 0) sleep(100); |
|
| 1829 | - if ($reset%20 == 0) sleep(200); |
|
| 1830 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1831 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2526 | + if ($reset%5 == 0) { |
|
| 2527 | + sleep(20); |
|
| 2528 | + } |
|
| 2529 | + if ($reset%10 == 0) { |
|
| 2530 | + sleep(100); |
|
| 2531 | + } |
|
| 2532 | + if ($reset%20 == 0) { |
|
| 2533 | + sleep(200); |
|
| 2534 | + } |
|
| 2535 | + if ($reset > 100) { |
|
| 2536 | + exit('Too many attempts...'); |
|
| 2537 | + } |
|
| 2538 | + if ($globalDebug) { |
|
| 2539 | + echo "Restart all connections..."; |
|
| 2540 | + } |
|
| 1832 | 2541 | connect_all($globalSources); |
| 1833 | 2542 | } |
| 1834 | 2543 | } |
| 1835 | 2544 | } |
| 1836 | 2545 | if ($globalDaemon === false) { |
| 1837 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1838 | - if (isset($SI)) $SI->checkAll(); |
|
| 1839 | - if (isset($TI)) $TI->checkAll(); |
|
| 1840 | - if (isset($MI)) $MI->checkAll(); |
|
| 2546 | + if ($globalDebug) { |
|
| 2547 | + echo 'Check all...'."\n"; |
|
| 2548 | + } |
|
| 2549 | + if (isset($SI)) { |
|
| 2550 | + $SI->checkAll(); |
|
| 2551 | + } |
|
| 2552 | + if (isset($TI)) { |
|
| 2553 | + $TI->checkAll(); |
|
| 2554 | + } |
|
| 2555 | + if (isset($MI)) { |
|
| 2556 | + $MI->checkAll(); |
|
| 2557 | + } |
|
| 1841 | 2558 | } |
| 1842 | 2559 | } |
| 1843 | 2560 | } |