@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | if (isset($filter[0]['source'])) { |
32 | 32 | $filters = array_merge($filters,$filter); |
33 | 33 | } |
34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
34 | + if (is_array($globalFilter)) { |
|
35 | + $filter = array_merge($filter,$globalFilter); |
|
36 | + } |
|
35 | 37 | $filter_query_join = ''; |
36 | 38 | $filter_query_where = ''; |
37 | 39 | foreach($filters as $flt) { |
@@ -70,8 +72,11 @@ discard block |
||
70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
71 | 73 | } |
72 | 74 | } |
73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
75 | + if ($filter_query_where == '' && $where) { |
|
76 | + $filter_query_where = ' WHERE'; |
|
77 | + } elseif ($filter_query_where != '' && $and) { |
|
78 | + $filter_query_where .= ' AND'; |
|
79 | + } |
|
75 | 80 | if ($filter_query_where != '') { |
76 | 81 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
77 | 82 | } |
@@ -125,26 +130,43 @@ discard block |
||
125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
126 | 131 | } elseif (isset($row['spotter_archive_output_id'])) { |
127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
128 | - */} |
|
129 | - elseif (isset($row['trackerid'])) { |
|
133 | + */} elseif (isset($row['trackerid'])) { |
|
130 | 134 | $temp_array['trackerid'] = $row['trackerid']; |
131 | 135 | } else { |
132 | 136 | $temp_array['trackerid'] = ''; |
133 | 137 | } |
134 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
136 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
138 | + if (isset($row['famtrackid'])) { |
|
139 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
140 | + } |
|
141 | + if (isset($row['type'])) { |
|
142 | + $temp_array['type'] = $row['type']; |
|
143 | + } |
|
144 | + if (isset($row['comment'])) { |
|
145 | + $temp_array['comment'] = $row['comment']; |
|
146 | + } |
|
137 | 147 | $temp_array['ident'] = $row['ident']; |
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
141 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
148 | + if (isset($row['latitude'])) { |
|
149 | + $temp_array['latitude'] = $row['latitude']; |
|
150 | + } |
|
151 | + if (isset($row['longitude'])) { |
|
152 | + $temp_array['longitude'] = $row['longitude']; |
|
153 | + } |
|
154 | + if (isset($row['format_source'])) { |
|
155 | + $temp_array['format_source'] = $row['format_source']; |
|
156 | + } |
|
157 | + if (isset($row['altitude'])) { |
|
158 | + $temp_array['altitude'] = $row['altitude']; |
|
159 | + } |
|
142 | 160 | if (isset($row['heading'])) { |
143 | 161 | $temp_array['heading'] = $row['heading']; |
144 | 162 | $heading_direction = $this->parseDirection($row['heading']); |
145 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
163 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
165 | + } |
|
166 | + } |
|
167 | + if (isset($row['ground_speed'])) { |
|
168 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
146 | 169 | } |
147 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
148 | 170 | |
149 | 171 | if (isset($row['date'])) { |
150 | 172 | $dateArray = $this->parseDateString($row['date']); |
@@ -187,13 +209,21 @@ discard block |
||
187 | 209 | } |
188 | 210 | |
189 | 211 | $fromsource = NULL; |
190 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
191 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
192 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
212 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
213 | + $temp_array['source_name'] = $row['source_name']; |
|
214 | + } |
|
215 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
216 | + $temp_array['over_country'] = $row['over_country']; |
|
217 | + } |
|
218 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
219 | + $temp_array['distance'] = $row['distance']; |
|
220 | + } |
|
193 | 221 | $temp_array['query_number_rows'] = $num_rows; |
194 | 222 | $spotter_array[] = $temp_array; |
195 | 223 | } |
196 | - if ($num_rows == 0) return array(); |
|
224 | + if ($num_rows == 0) { |
|
225 | + return array(); |
|
226 | + } |
|
197 | 227 | $spotter_array[0]['query_number_rows'] = $num_rows; |
198 | 228 | return $spotter_array; |
199 | 229 | } |
@@ -224,8 +254,12 @@ discard block |
||
224 | 254 | { |
225 | 255 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
226 | 256 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
227 | - } else $limit_query = ""; |
|
228 | - } else $limit_query = ""; |
|
257 | + } else { |
|
258 | + $limit_query = ""; |
|
259 | + } |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
229 | 263 | |
230 | 264 | if ($sort != "") |
231 | 265 | { |
@@ -253,7 +287,9 @@ discard block |
||
253 | 287 | global $global_query; |
254 | 288 | |
255 | 289 | date_default_timezone_set('UTC'); |
256 | - if ($id == '') return array(); |
|
290 | + if ($id == '') { |
|
291 | + return array(); |
|
292 | + } |
|
257 | 293 | $additional_query = "tracker_output.famtrackid = :id"; |
258 | 294 | $query_values = array(':id' => $id); |
259 | 295 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -396,8 +432,11 @@ discard block |
||
396 | 432 | $query .= " ORDER BY tracker_output.source_name ASC"; |
397 | 433 | |
398 | 434 | $sth = $this->db->prepare($query); |
399 | - if (!empty($query_values)) $sth->execute($query_values); |
|
400 | - else $sth->execute(); |
|
435 | + if (!empty($query_values)) { |
|
436 | + $sth->execute($query_values); |
|
437 | + } else { |
|
438 | + $sth->execute(); |
|
439 | + } |
|
401 | 440 | |
402 | 441 | $source_array = array(); |
403 | 442 | $temp_array = array(); |
@@ -452,7 +491,9 @@ discard block |
||
452 | 491 | date_default_timezone_set($globalTimezone); |
453 | 492 | $datetime = new DateTime(); |
454 | 493 | $offset = $datetime->format('P'); |
455 | - } else $offset = '+00:00'; |
|
494 | + } else { |
|
495 | + $offset = '+00:00'; |
|
496 | + } |
|
456 | 497 | |
457 | 498 | if ($globalDBdriver == 'mysql') { |
458 | 499 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -608,7 +649,9 @@ discard block |
||
608 | 649 | { |
609 | 650 | return false; |
610 | 651 | } |
611 | - } else $altitude = 0; |
|
652 | + } else { |
|
653 | + $altitude = 0; |
|
654 | + } |
|
612 | 655 | |
613 | 656 | if ($heading != "") |
614 | 657 | { |
@@ -647,8 +690,12 @@ discard block |
||
647 | 690 | $latitude = 0; |
648 | 691 | $longitude = 0; |
649 | 692 | } |
650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
651 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
693 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
694 | + $heading = 0; |
|
695 | + } |
|
696 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
697 | + $groundspeed = 0; |
|
698 | + } |
|
652 | 699 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
653 | 700 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
654 | 701 | |
@@ -813,12 +860,18 @@ discard block |
||
813 | 860 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
814 | 861 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
815 | 862 | if ($olderthanmonths > 0) { |
816 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
817 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
863 | + if ($globalDBdriver == 'mysql') { |
|
864 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
865 | + } else { |
|
866 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
867 | + } |
|
818 | 868 | } |
819 | 869 | if ($sincedate != '') { |
820 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
821 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
870 | + if ($globalDBdriver == 'mysql') { |
|
871 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
872 | + } else { |
|
873 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
874 | + } |
|
822 | 875 | } |
823 | 876 | $query_values = array(); |
824 | 877 | if ($year != '') { |
@@ -849,7 +902,9 @@ discard block |
||
849 | 902 | } |
850 | 903 | } |
851 | 904 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
852 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
905 | + if ($limit) { |
|
906 | + $query .= " LIMIT 10 OFFSET 0"; |
|
907 | + } |
|
853 | 908 | |
854 | 909 | $sth = $this->db->prepare($query); |
855 | 910 | $sth->execute($query_values); |
@@ -884,7 +939,9 @@ discard block |
||
884 | 939 | date_default_timezone_set($globalTimezone); |
885 | 940 | $datetime = new DateTime(); |
886 | 941 | $offset = $datetime->format('P'); |
887 | - } else $offset = '+00:00'; |
|
942 | + } else { |
|
943 | + $offset = '+00:00'; |
|
944 | + } |
|
888 | 945 | |
889 | 946 | if ($globalDBdriver == 'mysql') { |
890 | 947 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -934,7 +991,9 @@ discard block |
||
934 | 991 | date_default_timezone_set($globalTimezone); |
935 | 992 | $datetime = new DateTime(); |
936 | 993 | $offset = $datetime->format('P'); |
937 | - } else $offset = '+00:00'; |
|
994 | + } else { |
|
995 | + $offset = '+00:00'; |
|
996 | + } |
|
938 | 997 | $filter_query = $this->getFilter($filters,true,true); |
939 | 998 | if ($globalDBdriver == 'mysql') { |
940 | 999 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -980,7 +1039,9 @@ discard block |
||
980 | 1039 | date_default_timezone_set($globalTimezone); |
981 | 1040 | $datetime = new DateTime(); |
982 | 1041 | $offset = $datetime->format('P'); |
983 | - } else $offset = '+00:00'; |
|
1042 | + } else { |
|
1043 | + $offset = '+00:00'; |
|
1044 | + } |
|
984 | 1045 | $filter_query = $this->getFilter($filters,true,true); |
985 | 1046 | if ($globalDBdriver == 'mysql') { |
986 | 1047 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1028,7 +1089,9 @@ discard block |
||
1028 | 1089 | date_default_timezone_set($globalTimezone); |
1029 | 1090 | $datetime = new DateTime(); |
1030 | 1091 | $offset = $datetime->format('P'); |
1031 | - } else $offset = '+00:00'; |
|
1092 | + } else { |
|
1093 | + $offset = '+00:00'; |
|
1094 | + } |
|
1032 | 1095 | |
1033 | 1096 | if ($globalDBdriver == 'mysql') { |
1034 | 1097 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1077,7 +1140,9 @@ discard block |
||
1077 | 1140 | date_default_timezone_set($globalTimezone); |
1078 | 1141 | $datetime = new DateTime(); |
1079 | 1142 | $offset = $datetime->format('P'); |
1080 | - } else $offset = '+00:00'; |
|
1143 | + } else { |
|
1144 | + $offset = '+00:00'; |
|
1145 | + } |
|
1081 | 1146 | $filter_query = $this->getFilter($filters,true,true); |
1082 | 1147 | if ($globalDBdriver == 'mysql') { |
1083 | 1148 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1126,7 +1191,9 @@ discard block |
||
1126 | 1191 | date_default_timezone_set($globalTimezone); |
1127 | 1192 | $datetime = new DateTime(); |
1128 | 1193 | $offset = $datetime->format('P'); |
1129 | - } else $offset = '+00:00'; |
|
1194 | + } else { |
|
1195 | + $offset = '+00:00'; |
|
1196 | + } |
|
1130 | 1197 | |
1131 | 1198 | $orderby_sql = ''; |
1132 | 1199 | if ($orderby == "hour") |
@@ -1195,7 +1262,9 @@ discard block |
||
1195 | 1262 | date_default_timezone_set($globalTimezone); |
1196 | 1263 | $datetime = new DateTime($date); |
1197 | 1264 | $offset = $datetime->format('P'); |
1198 | - } else $offset = '+00:00'; |
|
1265 | + } else { |
|
1266 | + $offset = '+00:00'; |
|
1267 | + } |
|
1199 | 1268 | |
1200 | 1269 | if ($globalDBdriver == 'mysql') { |
1201 | 1270 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1243,7 +1312,9 @@ discard block |
||
1243 | 1312 | date_default_timezone_set($globalTimezone); |
1244 | 1313 | $datetime = new DateTime(); |
1245 | 1314 | $offset = $datetime->format('P'); |
1246 | - } else $offset = '+00:00'; |
|
1315 | + } else { |
|
1316 | + $offset = '+00:00'; |
|
1317 | + } |
|
1247 | 1318 | |
1248 | 1319 | if ($globalDBdriver == 'mysql') { |
1249 | 1320 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1307,8 +1378,11 @@ discard block |
||
1307 | 1378 | $query_values = array_merge($query_values,array(':month' => $month)); |
1308 | 1379 | } |
1309 | 1380 | } |
1310 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1311 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1381 | + if (empty($query_values)) { |
|
1382 | + $queryi .= $this->getFilter($filters); |
|
1383 | + } else { |
|
1384 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1385 | + } |
|
1312 | 1386 | |
1313 | 1387 | $sth = $this->db->prepare($queryi); |
1314 | 1388 | $sth->execute($query_values); |
@@ -1330,7 +1404,9 @@ discard block |
||
1330 | 1404 | date_default_timezone_set($globalTimezone); |
1331 | 1405 | $datetime = new DateTime(); |
1332 | 1406 | $offset = $datetime->format('P'); |
1333 | - } else $offset = '+00:00'; |
|
1407 | + } else { |
|
1408 | + $offset = '+00:00'; |
|
1409 | + } |
|
1334 | 1410 | |
1335 | 1411 | if ($globalDBdriver == 'mysql') { |
1336 | 1412 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1434,7 +1510,9 @@ discard block |
||
1434 | 1510 | */ |
1435 | 1511 | public function parseDirection($direction = 0) |
1436 | 1512 | { |
1437 | - if ($direction == '') $direction = 0; |
|
1513 | + if ($direction == '') { |
|
1514 | + $direction = 0; |
|
1515 | + } |
|
1438 | 1516 | $direction_array = array(); |
1439 | 1517 | $temp_array = array(); |
1440 | 1518 | |
@@ -1523,7 +1601,9 @@ discard block |
||
1523 | 1601 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1524 | 1602 | |
1525 | 1603 | $Connection = new Connection($this->db); |
1526 | - if (!$Connection->tableExists('countries')) return ''; |
|
1604 | + if (!$Connection->tableExists('countries')) { |
|
1605 | + return ''; |
|
1606 | + } |
|
1527 | 1607 | |
1528 | 1608 | try { |
1529 | 1609 | /* |
@@ -1543,9 +1623,13 @@ discard block |
||
1543 | 1623 | $sth->closeCursor(); |
1544 | 1624 | if (count($row) > 0) { |
1545 | 1625 | return $row; |
1546 | - } else return ''; |
|
1626 | + } else { |
|
1627 | + return ''; |
|
1628 | + } |
|
1547 | 1629 | } catch (PDOException $e) { |
1548 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1630 | + if (isset($globalDebug) && $globalDebug) { |
|
1631 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1632 | + } |
|
1549 | 1633 | return ''; |
1550 | 1634 | } |
1551 | 1635 | |
@@ -1563,7 +1647,9 @@ discard block |
||
1563 | 1647 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1564 | 1648 | |
1565 | 1649 | $Connection = new Connection($this->db); |
1566 | - if (!$Connection->tableExists('countries')) return ''; |
|
1650 | + if (!$Connection->tableExists('countries')) { |
|
1651 | + return ''; |
|
1652 | + } |
|
1567 | 1653 | |
1568 | 1654 | try { |
1569 | 1655 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1575,9 +1661,13 @@ discard block |
||
1575 | 1661 | $sth->closeCursor(); |
1576 | 1662 | if (count($row) > 0) { |
1577 | 1663 | return $row; |
1578 | - } else return ''; |
|
1664 | + } else { |
|
1665 | + return ''; |
|
1666 | + } |
|
1579 | 1667 | } catch (PDOException $e) { |
1580 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1668 | + if (isset($globalDebug) && $globalDebug) { |
|
1669 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1670 | + } |
|
1581 | 1671 | return ''; |
1582 | 1672 | } |
1583 | 1673 | |
@@ -1595,7 +1685,9 @@ discard block |
||
1595 | 1685 | { |
1596 | 1686 | global $globalBitlyAccessToken; |
1597 | 1687 | |
1598 | - if ($globalBitlyAccessToken == '') return $url; |
|
1688 | + if ($globalBitlyAccessToken == '') { |
|
1689 | + return $url; |
|
1690 | + } |
|
1599 | 1691 | |
1600 | 1692 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1601 | 1693 |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
78 | 80 | } |
79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
81 | + if ($filter_query_where == '' && $where) { |
|
82 | + $filter_query_where = ' WHERE'; |
|
83 | + } elseif ($filter_query_where != '' && $and) { |
|
84 | + $filter_query_where .= ' AND'; |
|
85 | + } |
|
81 | 86 | if ($filter_query_where != '') { |
82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
119 | 124 | } |
120 | 125 | } |
121 | 126 | |
122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
127 | + if (!isset($globalLiveInterval)) { |
|
128 | + $globalLiveInterval = '200'; |
|
129 | + } |
|
123 | 130 | if ($globalDBdriver == 'mysql') { |
124 | 131 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
125 | 132 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
144 | 151 | |
145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
146 | 153 | |
147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
154 | + if (!isset($globalLiveInterval)) { |
|
155 | + $globalLiveInterval = '200'; |
|
156 | + } |
|
148 | 157 | if ($globalDBdriver == 'mysql') { |
149 | 158 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
150 | 159 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -182,7 +191,9 @@ discard block |
||
182 | 191 | |
183 | 192 | $filter_query = $this->getFilter($filter,true,true); |
184 | 193 | |
185 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
194 | + if (!isset($globalLiveInterval)) { |
|
195 | + $globalLiveInterval = '200'; |
|
196 | + } |
|
186 | 197 | if ($globalDBdriver == 'mysql') { |
187 | 198 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 199 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
@@ -215,7 +226,9 @@ discard block |
||
215 | 226 | global $globalDBdriver, $globalLiveInterval; |
216 | 227 | $filter_query = $this->getFilter($filter,true,true); |
217 | 228 | |
218 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
229 | + if (!isset($globalLiveInterval)) { |
|
230 | + $globalLiveInterval = '200'; |
|
231 | + } |
|
219 | 232 | if ($globalDBdriver == 'mysql') { |
220 | 233 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
221 | 234 | } else { |
@@ -243,7 +256,9 @@ discard block |
||
243 | 256 | { |
244 | 257 | global $globalDBdriver, $globalLiveInterval; |
245 | 258 | $Spotter = new Spotter($this->db); |
246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
259 | + if (!isset($globalLiveInterval)) { |
|
260 | + $globalLiveInterval = '200'; |
|
261 | + } |
|
247 | 262 | $filter_query = $this->getFilter($filter); |
248 | 263 | |
249 | 264 | if (is_array($coord)) { |
@@ -251,7 +266,9 @@ discard block |
||
251 | 266 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
252 | 267 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
253 | 268 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
254 | - } else return array(); |
|
269 | + } else { |
|
270 | + return array(); |
|
271 | + } |
|
255 | 272 | if ($globalDBdriver == 'mysql') { |
256 | 273 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
257 | 274 | } else { |
@@ -441,11 +458,15 @@ discard block |
||
441 | 458 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
442 | 459 | if ($globalDBdriver == 'mysql') { |
443 | 460 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
444 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
461 | + if ($liveinterval) { |
|
462 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
463 | + } |
|
445 | 464 | $query .= ' ORDER BY date'; |
446 | 465 | } else { |
447 | 466 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
448 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
467 | + if ($liveinterval) { |
|
468 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
469 | + } |
|
449 | 470 | $query .= ' ORDER BY date'; |
450 | 471 | } |
451 | 472 | |
@@ -540,7 +561,9 @@ discard block |
||
540 | 561 | $i++; |
541 | 562 | $j++; |
542 | 563 | if ($j == 30) { |
543 | - if ($globalDebug) echo "."; |
|
564 | + if ($globalDebug) { |
|
565 | + echo "."; |
|
566 | + } |
|
544 | 567 | try { |
545 | 568 | |
546 | 569 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -787,7 +810,9 @@ discard block |
||
787 | 810 | { |
788 | 811 | return false; |
789 | 812 | } |
790 | - } else return ''; |
|
813 | + } else { |
|
814 | + return ''; |
|
815 | + } |
|
791 | 816 | |
792 | 817 | if ($longitude != '') |
793 | 818 | { |
@@ -795,7 +820,9 @@ discard block |
||
795 | 820 | { |
796 | 821 | return false; |
797 | 822 | } |
798 | - } else return ''; |
|
823 | + } else { |
|
824 | + return ''; |
|
825 | + } |
|
799 | 826 | |
800 | 827 | if ($altitude != '') |
801 | 828 | { |
@@ -803,7 +830,9 @@ discard block |
||
803 | 830 | { |
804 | 831 | return false; |
805 | 832 | } |
806 | - } else $altitude = 0; |
|
833 | + } else { |
|
834 | + $altitude = 0; |
|
835 | + } |
|
807 | 836 | |
808 | 837 | if ($heading != '') |
809 | 838 | { |
@@ -811,7 +840,9 @@ discard block |
||
811 | 840 | { |
812 | 841 | return false; |
813 | 842 | } |
814 | - } else $heading = 0; |
|
843 | + } else { |
|
844 | + $heading = 0; |
|
845 | + } |
|
815 | 846 | |
816 | 847 | if ($groundspeed != '') |
817 | 848 | { |
@@ -819,9 +850,13 @@ discard block |
||
819 | 850 | { |
820 | 851 | return false; |
821 | 852 | } |
822 | - } else $groundspeed = 0; |
|
853 | + } else { |
|
854 | + $groundspeed = 0; |
|
855 | + } |
|
823 | 856 | date_default_timezone_set('UTC'); |
824 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
857 | + if ($date == '') { |
|
858 | + $date = date("Y-m-d H:i:s", time()); |
|
859 | + } |
|
825 | 860 | |
826 | 861 | |
827 | 862 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -837,8 +872,12 @@ discard block |
||
837 | 872 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
838 | 873 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
839 | 874 | |
840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
875 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
876 | + $groundspeed = 0; |
|
877 | + } |
|
878 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
879 | + $heading = 0; |
|
880 | + } |
|
842 | 881 | |
843 | 882 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
844 | 883 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -44,7 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | public function checkAll() { |
46 | 46 | global $globalDebug; |
47 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
47 | + if ($globalDebug) { |
|
48 | + echo "Update last seen tracked data...\n"; |
|
49 | + } |
|
48 | 50 | foreach ($this->all_tracked as $key => $flight) { |
49 | 51 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 52 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -57,12 +59,16 @@ discard block |
||
57 | 59 | public function del() { |
58 | 60 | global $globalDebug; |
59 | 61 | // Delete old infos |
60 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
62 | + if ($globalDebug) { |
|
63 | + echo 'Delete old values and update latest data...'."\n"; |
|
64 | + } |
|
61 | 65 | foreach ($this->all_tracked as $key => $flight) { |
62 | 66 | if (isset($flight['lastupdate'])) { |
63 | 67 | if ($flight['lastupdate'] < (time()-3000)) { |
64 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
71 | + } |
|
66 | 72 | /* |
67 | 73 | $TrackerLive = new TrackerLive(); |
68 | 74 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -72,7 +78,9 @@ discard block |
||
72 | 78 | $Tracker = new Tracker($this->db); |
73 | 79 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | 80 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
81 | + if ($globalDebug && $result != 'success') { |
|
82 | + echo '!!! ERROR : '.$result."\n"; |
|
83 | + } |
|
76 | 84 | } |
77 | 85 | // Put in archive |
78 | 86 | // $Tracker->db = null; |
@@ -85,7 +93,9 @@ discard block |
||
85 | 93 | |
86 | 94 | public function add($line) { |
87 | 95 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
96 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
97 | + $globalCoordMinChange = '0.02'; |
|
98 | + } |
|
89 | 99 | date_default_timezone_set('UTC'); |
90 | 100 | $dataFound = false; |
91 | 101 | $send = false; |
@@ -109,8 +119,11 @@ discard block |
||
109 | 119 | */ |
110 | 120 | |
111 | 121 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
122 | + if (!isset($line['id'])) { |
|
123 | + $id = trim($line['ident']); |
|
124 | + } else { |
|
125 | + $id = trim($line['id']); |
|
126 | + } |
|
114 | 127 | |
115 | 128 | if (!isset($this->all_tracked[$id])) { |
116 | 129 | $this->all_tracked[$id] = array(); |
@@ -118,18 +131,27 @@ discard block |
||
118 | 131 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
119 | 132 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
120 | 133 | if (!isset($line['id'])) { |
121 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
134 | + if (!isset($globalDaemon)) { |
|
135 | + $globalDaemon = TRUE; |
|
136 | + } |
|
122 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else { |
|
139 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
140 | + } |
|
141 | + if ($globalAllTracked !== FALSE) { |
|
142 | + $dataFound = true; |
|
143 | + } |
|
125 | 144 | } |
126 | 145 | |
127 | 146 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
128 | 147 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
129 | 148 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | 149 | } else { |
131 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
132 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
150 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
151 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
152 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
153 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
154 | + } |
|
133 | 155 | return ''; |
134 | 156 | } |
135 | 157 | } else { |
@@ -145,11 +167,17 @@ discard block |
||
145 | 167 | $Tracker = new Tracker($this->db); |
146 | 168 | $fromsource = NULL; |
147 | 169 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
148 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
170 | + if ($globalDebug && $result != 'success') { |
|
171 | + echo '!!! ERROR : '.$result."\n"; |
|
172 | + } |
|
149 | 173 | $Tracker->db = null; |
150 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
174 | + if ($globalDebugTimeElapsed) { |
|
175 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
176 | + } |
|
177 | + } |
|
178 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
151 | 180 | } |
152 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | 181 | } |
154 | 182 | |
155 | 183 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -160,14 +188,21 @@ discard block |
||
160 | 188 | if ($distance > 1000 && $distance < 10000) { |
161 | 189 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
162 | 190 | $speed = $speed*3.6; |
163 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
164 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
191 | + if ($speed < 1000) { |
|
192 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
193 | + } |
|
194 | + if ($globalDebug) { |
|
195 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
196 | + } |
|
165 | 197 | } |
166 | 198 | } |
167 | 199 | |
168 | 200 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
169 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | - else unset($timediff); |
|
201 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
202 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
203 | + } else { |
|
204 | + unset($timediff); |
|
205 | + } |
|
171 | 206 | 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')))) { |
172 | 207 | 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'])) { |
173 | 208 | 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'])) { |
@@ -175,20 +210,30 @@ discard block |
||
175 | 210 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
176 | 211 | $this->all_tracked[$id]['putinarchive'] = true; |
177 | 212 | |
178 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
213 | + if ($globalDebug) { |
|
214 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
215 | + } |
|
179 | 216 | $timeelapsed = microtime(true); |
180 | 217 | $Tracker = new Tracker($this->db); |
181 | 218 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
182 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
219 | + if (!empty($all_country)) { |
|
220 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
221 | + } |
|
183 | 222 | $Tracker->db = null; |
184 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
223 | + if ($globalDebugTimeElapsed) { |
|
224 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
225 | + } |
|
185 | 226 | $this->tmd = 0; |
186 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
227 | + if ($globalDebug) { |
|
228 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
229 | + } |
|
187 | 230 | } |
188 | 231 | } |
189 | 232 | |
190 | 233 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
191 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
234 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
235 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
236 | + } |
|
192 | 237 | 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') { |
193 | 238 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
194 | 239 | $dataFound = true; |
@@ -197,8 +242,12 @@ discard block |
||
197 | 242 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
198 | 243 | } |
199 | 244 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
200 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
201 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
245 | + if ($line['longitude'] > 180) { |
|
246 | + $line['longitude'] = $line['longitude'] - 360; |
|
247 | + } |
|
248 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
249 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
250 | + } |
|
202 | 251 | 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') { |
203 | 252 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
204 | 253 | $dataFound = true; |
@@ -216,7 +265,9 @@ discard block |
||
216 | 265 | } |
217 | 266 | } |
218 | 267 | if (isset($line['last_update']) && $line['last_update'] != '') { |
219 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
268 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
269 | + $dataFound = true; |
|
270 | + } |
|
220 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
221 | 272 | } |
222 | 273 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -236,7 +287,9 @@ discard block |
||
236 | 287 | |
237 | 288 | if (isset($line['altitude']) && $line['altitude'] != '') { |
238 | 289 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
239 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
290 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
291 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
292 | + } |
|
240 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
241 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
242 | 295 | //$dataFound = true; |
@@ -248,15 +301,21 @@ discard block |
||
248 | 301 | } |
249 | 302 | |
250 | 303 | if (isset($line['heading']) && $line['heading'] != '') { |
251 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
304 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
305 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
306 | + } |
|
252 | 307 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
253 | 308 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
254 | 309 | //$dataFound = true; |
255 | 310 | } 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']) { |
256 | 311 | $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']); |
257 | 312 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
258 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
313 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
315 | + } |
|
316 | + if ($globalDebug) { |
|
317 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
318 | + } |
|
260 | 319 | } |
261 | 320 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
262 | 321 | |
@@ -265,20 +324,31 @@ discard block |
||
265 | 324 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
266 | 325 | 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'])) { |
267 | 326 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
268 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Check if aircraft is already in DB..."; |
|
329 | + } |
|
269 | 330 | $timeelapsed = microtime(true); |
270 | 331 | $TrackerLive = new TrackerLive($this->db); |
271 | 332 | if (isset($line['id'])) { |
272 | 333 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
273 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
334 | + if ($globalDebugTimeElapsed) { |
|
335 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
336 | + } |
|
274 | 337 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
275 | 338 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
276 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
277 | - } else $recent_ident = ''; |
|
339 | + if ($globalDebugTimeElapsed) { |
|
340 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
341 | + } |
|
342 | + } else { |
|
343 | + $recent_ident = ''; |
|
344 | + } |
|
278 | 345 | $TrackerLive->db=null; |
279 | 346 | |
280 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
281 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
347 | + if ($globalDebug && $recent_ident == '') { |
|
348 | + echo " Not in DB.\n"; |
|
349 | + } elseif ($globalDebug && $recent_ident != '') { |
|
350 | + echo " Already in DB.\n"; |
|
351 | + } |
|
282 | 352 | } else { |
283 | 353 | $recent_ident = ''; |
284 | 354 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -286,16 +356,24 @@ discard block |
||
286 | 356 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
287 | 357 | if($recent_ident == "") |
288 | 358 | { |
289 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
359 | + if ($globalDebug) { |
|
360 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
361 | + } |
|
290 | 362 | //adds the spotter data for the archive |
291 | 363 | $highlight = ''; |
292 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
365 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
366 | + } |
|
293 | 367 | $timeelapsed = microtime(true); |
294 | 368 | $Tracker = new Tracker($this->db); |
295 | 369 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
296 | 370 | $Tracker->db = null; |
297 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
371 | + if ($globalDebug && isset($result)) { |
|
372 | + echo $result."\n"; |
|
373 | + } |
|
374 | + if ($globalDebugTimeElapsed) { |
|
375 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + } |
|
299 | 377 | |
300 | 378 | /* |
301 | 379 | // Add source stat in DB |
@@ -329,12 +407,16 @@ discard block |
||
329 | 407 | $this->all_tracked[$id]['addedTracker'] = 1; |
330 | 408 | //print_r($this->all_tracked[$id]); |
331 | 409 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
332 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
410 | + if ($globalDebug) { |
|
411 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
412 | + } |
|
333 | 413 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
334 | 414 | $TrackerLive = new TrackerLive($this->db); |
335 | 415 | $TrackerLive->deleteLiveTrackerData(); |
336 | 416 | $TrackerLive->db=null; |
337 | - if ($globalDebug) echo " Done\n"; |
|
417 | + if ($globalDebug) { |
|
418 | + echo " Done\n"; |
|
419 | + } |
|
338 | 420 | $this->last_delete = time(); |
339 | 421 | } |
340 | 422 | } else { |
@@ -357,13 +439,17 @@ discard block |
||
357 | 439 | |
358 | 440 | if (!$ignoreImport) { |
359 | 441 | 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'])) { |
360 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
442 | + if ($globalDebug) { |
|
443 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
444 | + } |
|
361 | 445 | $timeelapsed = microtime(true); |
362 | 446 | $TrackerLive = new TrackerLive($this->db); |
363 | 447 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
364 | 448 | $TrackerLive->db = null; |
365 | 449 | $this->all_tracked[$id]['putinarchive'] = false; |
366 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
450 | + if ($globalDebugTimeElapsed) { |
|
451 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
452 | + } |
|
367 | 453 | |
368 | 454 | // Put statistics in $this->stats variable |
369 | 455 | /* |
@@ -420,19 +506,29 @@ discard block |
||
420 | 506 | */ |
421 | 507 | |
422 | 508 | $this->all_tracked[$id]['lastupdate'] = time(); |
423 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
424 | - if ($globalDebug) echo $result."\n"; |
|
425 | - } 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"; |
|
509 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
510 | + $send = true; |
|
511 | + } |
|
512 | + if ($globalDebug) { |
|
513 | + echo $result."\n"; |
|
514 | + } |
|
515 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
516 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
517 | + } |
|
426 | 518 | //$this->del(); |
427 | 519 | |
428 | 520 | |
429 | 521 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
430 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
522 | + if ($globalDebug) { |
|
523 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
524 | + } |
|
431 | 525 | $TrackerLive = new TrackerLive($this->db); |
432 | 526 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
433 | 527 | $TrackerLive->db = null; |
434 | 528 | //TrackerLive->deleteLiveTrackerData(); |
435 | - if ($globalDebug) echo " Done\n"; |
|
529 | + if ($globalDebug) { |
|
530 | + echo " Done\n"; |
|
531 | + } |
|
436 | 532 | $this->last_delete_hourly = time(); |
437 | 533 | } |
438 | 534 | |
@@ -440,7 +536,9 @@ discard block |
||
440 | 536 | //$ignoreImport = false; |
441 | 537 | } |
442 | 538 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
443 | - if ($send) return $this->all_tracked[$id]; |
|
539 | + if ($send) { |
|
540 | + return $this->all_tracked[$id]; |
|
541 | + } |
|
444 | 542 | } |
445 | 543 | } |
446 | 544 | } |
@@ -63,7 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
65 | 65 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
66 | - } else $image = $spotter_item['image_thumbnail']; |
|
66 | + } else { |
|
67 | + $image = $spotter_item['image_thumbnail']; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | } |
69 | 71 | /* else { |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
19 | + if ($referer != '') { |
|
20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
21 | + } |
|
20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 31 | $buffer_size = 4096; // read 4kb at a time |
30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
32 | + if ($out_file_name == '') { |
|
33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
34 | + } |
|
31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
35 | - else { |
|
37 | + if (function_exists('gzopen')) { |
|
38 | + $file = gzopen($in_file,'rb'); |
|
39 | + } elseif (function_exists('gzopen64')) { |
|
40 | + $file = gzopen64($in_file,'rb'); |
|
41 | + } else { |
|
36 | 42 | echo 'gzopen not available'; |
37 | 43 | die; |
38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
53 | 59 | if ($res === TRUE) { |
54 | 60 | $zip->extractTo($path); |
55 | 61 | $zip->close(); |
56 | - } else return false; |
|
57 | - } else return false; |
|
62 | + } else { |
|
63 | + return false; |
|
64 | + } |
|
65 | + } else { |
|
66 | + return false; |
|
67 | + } |
|
58 | 68 | } |
59 | 69 | |
60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
70 | 80 | global $globalDebug, $globalTransaction; |
71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
82 | + if ($globalDebug) { |
|
83 | + echo " - Delete previous routes from DB -"; |
|
84 | + } |
|
73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
74 | 86 | $Connection = new Connection(); |
75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
80 | 92 | return "error : ".$e->getMessage(); |
81 | 93 | } |
82 | 94 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
95 | + if ($globalDebug) { |
|
96 | + echo " - Add routes to DB -"; |
|
97 | + } |
|
84 | 98 | update_db::connect_sqlite($database_file); |
85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
95 | 109 | $Connection = new Connection(); |
96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 111 | try { |
98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
112 | + if ($globalTransaction) { |
|
113 | + $Connection->db->beginTransaction(); |
|
114 | + } |
|
99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 118 | $sth_dest->execute($query_dest_values); |
103 | 119 | } |
104 | - if ($globalTransaction) $Connection->db->commit(); |
|
120 | + if ($globalTransaction) { |
|
121 | + $Connection->db->commit(); |
|
122 | + } |
|
105 | 123 | } catch(PDOException $e) { |
106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
124 | + if ($globalTransaction) { |
|
125 | + $Connection->db->rollBack(); |
|
126 | + } |
|
107 | 127 | return "error : ".$e->getMessage(); |
108 | 128 | } |
109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
111 | 131 | public static function retrieve_route_oneworld($database_file) { |
112 | 132 | global $globalDebug, $globalTransaction; |
113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
134 | + if ($globalDebug) { |
|
135 | + echo " - Delete previous routes from DB -"; |
|
136 | + } |
|
115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
116 | 138 | $Connection = new Connection(); |
117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
122 | 144 | return "error : ".$e->getMessage(); |
123 | 145 | } |
124 | 146 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
147 | + if ($globalDebug) { |
|
148 | + echo " - Add routes to DB -"; |
|
149 | + } |
|
126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 151 | $Spotter = new Spotter(); |
128 | 152 | if ($fh = fopen($database_file,"r")) { |
129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 154 | $Connection = new Connection(); |
131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
156 | + if ($globalTransaction) { |
|
157 | + $Connection->db->beginTransaction(); |
|
158 | + } |
|
133 | 159 | while (!feof($fh)) { |
134 | 160 | $line = fgetcsv($fh,9999,','); |
135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
139 | 165 | $sth_dest->execute($query_dest_values); |
140 | 166 | } catch(PDOException $e) { |
141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
167 | + if ($globalTransaction) { |
|
168 | + $Connection->db->rollBack(); |
|
169 | + } |
|
142 | 170 | return "error : ".$e->getMessage(); |
143 | 171 | } |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | - if ($globalTransaction) $Connection->db->commit(); |
|
175 | + if ($globalTransaction) { |
|
176 | + $Connection->db->commit(); |
|
177 | + } |
|
148 | 178 | } |
149 | 179 | return ''; |
150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
152 | 182 | public static function retrieve_route_skyteam($database_file) { |
153 | 183 | global $globalDebug, $globalTransaction; |
154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo " - Delete previous routes from DB -"; |
|
187 | + } |
|
156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
157 | 189 | $Connection = new Connection(); |
158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
163 | 195 | return "error : ".$e->getMessage(); |
164 | 196 | } |
165 | 197 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo " - Add routes to DB -"; |
|
200 | + } |
|
167 | 201 | |
168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
172 | 206 | $Connection = new Connection(); |
173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 208 | try { |
175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
209 | + if ($globalTransaction) { |
|
210 | + $Connection->db->beginTransaction(); |
|
211 | + } |
|
176 | 212 | while (!feof($fh)) { |
177 | 213 | $line = fgetcsv($fh,9999,','); |
178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
183 | 219 | } |
184 | 220 | } |
185 | 221 | } |
186 | - if ($globalTransaction) $Connection->db->commit(); |
|
222 | + if ($globalTransaction) { |
|
223 | + $Connection->db->commit(); |
|
224 | + } |
|
187 | 225 | } catch(PDOException $e) { |
188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
226 | + if ($globalTransaction) { |
|
227 | + $Connection->db->rollBack(); |
|
228 | + } |
|
189 | 229 | return "error : ".$e->getMessage(); |
190 | 230 | } |
191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 270 | try { |
231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
271 | + if ($globalTransaction) { |
|
272 | + $Connection->db->beginTransaction(); |
|
273 | + } |
|
232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
235 | - else $type = null; |
|
276 | + if ($values['UserString4'] == 'M') { |
|
277 | + $type = 'military'; |
|
278 | + } else { |
|
279 | + $type = null; |
|
280 | + } |
|
236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
237 | 282 | $sth_dest->execute($query_dest_values); |
238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 286 | } |
242 | 287 | } |
243 | - if ($globalTransaction) $Connection->db->commit(); |
|
288 | + if ($globalTransaction) { |
|
289 | + $Connection->db->commit(); |
|
290 | + } |
|
244 | 291 | } catch(PDOException $e) { |
245 | 292 | return "error : ".$e->getMessage(); |
246 | 293 | } |
@@ -277,7 +324,9 @@ discard block |
||
277 | 324 | $Connection = new Connection(); |
278 | 325 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 326 | try { |
280 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
327 | + if ($globalTransaction) { |
|
328 | + $Connection->db->beginTransaction(); |
|
329 | + } |
|
281 | 330 | while (!feof($fh)) { |
282 | 331 | $values = array(); |
283 | 332 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -288,7 +337,9 @@ discard block |
||
288 | 337 | // Check if we can find ICAO, else set it to GLID |
289 | 338 | $aircraft_name_split = explode(' ',$aircraft_name); |
290 | 339 | $search_more = ''; |
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
340 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
341 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
342 | + } |
|
292 | 343 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
293 | 344 | $sth_search = $Connection->db->prepare($query_search); |
294 | 345 | try { |
@@ -301,7 +352,9 @@ discard block |
||
301 | 352 | } catch(PDOException $e) { |
302 | 353 | return "error : ".$e->getMessage(); |
303 | 354 | } |
304 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
355 | + if (!isset($values['ICAOTypeCode'])) { |
|
356 | + $values['ICAOTypeCode'] = 'GLID'; |
|
357 | + } |
|
305 | 358 | // Add data to db |
306 | 359 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
307 | 360 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -310,7 +363,9 @@ discard block |
||
310 | 363 | $sth_dest->execute($query_dest_values); |
311 | 364 | } |
312 | 365 | } |
313 | - if ($globalTransaction) $Connection->db->commit(); |
|
366 | + if ($globalTransaction) { |
|
367 | + $Connection->db->commit(); |
|
368 | + } |
|
314 | 369 | } catch(PDOException $e) { |
315 | 370 | return "error : ".$e->getMessage(); |
316 | 371 | } |
@@ -346,7 +401,9 @@ discard block |
||
346 | 401 | $Connection = new Connection(); |
347 | 402 | $sth_dest = $Connection->db->prepare($query_dest); |
348 | 403 | try { |
349 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
404 | + if ($globalTransaction) { |
|
405 | + $Connection->db->beginTransaction(); |
|
406 | + } |
|
350 | 407 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | 408 | while (!feof($fh)) { |
352 | 409 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -359,13 +416,17 @@ discard block |
||
359 | 416 | // Check if we can find ICAO, else set it to GLID |
360 | 417 | $aircraft_name_split = explode(' ',$aircraft_name); |
361 | 418 | $search_more = ''; |
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
419 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
420 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
421 | + } |
|
363 | 422 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
364 | 423 | $sth_search = $Connection->db->prepare($query_search); |
365 | 424 | try { |
366 | 425 | $sth_search->execute(); |
367 | 426 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
427 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
428 | + $values['ICAOTypeCode'] = $result['icao']; |
|
429 | + } |
|
369 | 430 | } catch(PDOException $e) { |
370 | 431 | return "error : ".$e->getMessage(); |
371 | 432 | } |
@@ -378,7 +439,9 @@ discard block |
||
378 | 439 | $sth_dest->execute($query_dest_values); |
379 | 440 | } |
380 | 441 | } |
381 | - if ($globalTransaction) $Connection->db->commit(); |
|
442 | + if ($globalTransaction) { |
|
443 | + $Connection->db->commit(); |
|
444 | + } |
|
382 | 445 | } catch(PDOException $e) { |
383 | 446 | return "error : ".$e->getMessage(); |
384 | 447 | } |
@@ -417,7 +480,9 @@ discard block |
||
417 | 480 | $sth_dest = $Connection->db->prepare($query_dest); |
418 | 481 | $sth_modes = $Connection->db->prepare($query_modes); |
419 | 482 | try { |
420 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
483 | + if ($globalTransaction) { |
|
484 | + $Connection->db->beginTransaction(); |
|
485 | + } |
|
421 | 486 | $tmp = fgetcsv($fh,9999,',','"'); |
422 | 487 | while (!feof($fh)) { |
423 | 488 | $line = fgetcsv($fh,9999,',','"'); |
@@ -427,16 +492,22 @@ discard block |
||
427 | 492 | $values['registration'] = $line[0]; |
428 | 493 | $values['base'] = $line[4]; |
429 | 494 | $values['owner'] = $line[5]; |
430 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
431 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | + if ($line[6] == '') { |
|
496 | + $values['date_first_reg'] = null; |
|
497 | + } else { |
|
498 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
499 | + } |
|
432 | 500 | $values['cancel'] = $line[7]; |
433 | 501 | } elseif ($country == 'EI') { |
434 | 502 | // TODO : add modeS & reg to aircraft_modes |
435 | 503 | $values['registration'] = $line[0]; |
436 | 504 | $values['base'] = $line[3]; |
437 | 505 | $values['owner'] = $line[2]; |
438 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
439 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
506 | + if ($line[1] == '') { |
|
507 | + $values['date_first_reg'] = null; |
|
508 | + } else { |
|
509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
510 | + } |
|
440 | 511 | $values['cancel'] = ''; |
441 | 512 | $values['modes'] = $line[7]; |
442 | 513 | $values['icao'] = $line[8]; |
@@ -455,16 +526,22 @@ discard block |
||
455 | 526 | $values['registration'] = $line[3]; |
456 | 527 | $values['base'] = null; |
457 | 528 | $values['owner'] = $line[5]; |
458 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
529 | + if ($line[18] == '') { |
|
530 | + $values['date_first_reg'] = null; |
|
531 | + } else { |
|
532 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
533 | + } |
|
460 | 534 | $values['cancel'] = ''; |
461 | 535 | } elseif ($country == 'VH') { |
462 | 536 | // TODO : add modeS & reg to aircraft_modes |
463 | 537 | $values['registration'] = $line[0]; |
464 | 538 | $values['base'] = null; |
465 | 539 | $values['owner'] = $line[12]; |
466 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
467 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
540 | + if ($line[28] == '') { |
|
541 | + $values['date_first_reg'] = null; |
|
542 | + } else { |
|
543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
544 | + } |
|
468 | 545 | |
469 | 546 | $values['cancel'] = $line[39]; |
470 | 547 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -483,29 +560,41 @@ discard block |
||
483 | 560 | $values['registration'] = $line[0]; |
484 | 561 | $values['base'] = null; |
485 | 562 | $values['owner'] = $line[8]; |
486 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
487 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
563 | + if ($line[7] == '') { |
|
564 | + $values['date_first_reg'] = null; |
|
565 | + } else { |
|
566 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
567 | + } |
|
488 | 568 | $values['cancel'] = ''; |
489 | 569 | } elseif ($country == 'PP') { |
490 | 570 | $values['registration'] = $line[0]; |
491 | 571 | $values['base'] = null; |
492 | 572 | $values['owner'] = $line[4]; |
493 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
494 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
573 | + if ($line[6] == '') { |
|
574 | + $values['date_first_reg'] = null; |
|
575 | + } else { |
|
576 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
577 | + } |
|
495 | 578 | $values['cancel'] = $line[7]; |
496 | 579 | } elseif ($country == 'E7') { |
497 | 580 | $values['registration'] = $line[0]; |
498 | 581 | $values['base'] = null; |
499 | 582 | $values['owner'] = $line[4]; |
500 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
501 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
583 | + if ($line[5] == '') { |
|
584 | + $values['date_first_reg'] = null; |
|
585 | + } else { |
|
586 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
587 | + } |
|
502 | 588 | $values['cancel'] = ''; |
503 | 589 | } elseif ($country == '8Q') { |
504 | 590 | $values['registration'] = $line[0]; |
505 | 591 | $values['base'] = null; |
506 | 592 | $values['owner'] = $line[3]; |
507 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
593 | + if ($line[7] == '') { |
|
594 | + $values['date_first_reg'] = null; |
|
595 | + } else { |
|
596 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
597 | + } |
|
509 | 598 | $values['cancel'] = ''; |
510 | 599 | } elseif ($country == 'ZK') { |
511 | 600 | $values['registration'] = $line[0]; |
@@ -550,7 +639,9 @@ discard block |
||
550 | 639 | $sth_modes->execute($query_modes_values); |
551 | 640 | } |
552 | 641 | } |
553 | - if ($globalTransaction) $Connection->db->commit(); |
|
642 | + if ($globalTransaction) { |
|
643 | + $Connection->db->commit(); |
|
644 | + } |
|
554 | 645 | } catch(PDOException $e) { |
555 | 646 | return "error : ".$e->getMessage(); |
556 | 647 | } |
@@ -684,25 +775,45 @@ discard block |
||
684 | 775 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
685 | 776 | $Connection = new Connection(); |
686 | 777 | $sth_dest = $Connection->db->prepare($query_dest); |
687 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
778 | + if ($globalTransaction) { |
|
779 | + $Connection->db->beginTransaction(); |
|
780 | + } |
|
688 | 781 | |
689 | 782 | $i = 0; |
690 | 783 | while($row = sparql_fetch_array($result)) |
691 | 784 | { |
692 | 785 | if ($i >= 1) { |
693 | 786 | //print_r($row); |
694 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
695 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
696 | - if (!isset($row['type'])) $row['type'] = ''; |
|
697 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
787 | + if (!isset($row['iata'])) { |
|
788 | + $row['iata'] = ''; |
|
789 | + } |
|
790 | + if (!isset($row['icao'])) { |
|
791 | + $row['icao'] = ''; |
|
792 | + } |
|
793 | + if (!isset($row['type'])) { |
|
794 | + $row['type'] = ''; |
|
795 | + } |
|
796 | + if (!isset($row['altitude'])) { |
|
797 | + $row['altitude'] = ''; |
|
798 | + } |
|
698 | 799 | if (isset($row['city_bis'])) { |
699 | 800 | $row['city'] = $row['city_bis']; |
700 | 801 | } |
701 | - if (!isset($row['city'])) $row['city'] = ''; |
|
702 | - if (!isset($row['country'])) $row['country'] = ''; |
|
703 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
704 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
705 | - if (!isset($row['name'])) continue; |
|
802 | + if (!isset($row['city'])) { |
|
803 | + $row['city'] = ''; |
|
804 | + } |
|
805 | + if (!isset($row['country'])) { |
|
806 | + $row['country'] = ''; |
|
807 | + } |
|
808 | + if (!isset($row['homepage'])) { |
|
809 | + $row['homepage'] = ''; |
|
810 | + } |
|
811 | + if (!isset($row['wikipedia_page'])) { |
|
812 | + $row['wikipedia_page'] = ''; |
|
813 | + } |
|
814 | + if (!isset($row['name'])) { |
|
815 | + continue; |
|
816 | + } |
|
706 | 817 | if (!isset($row['image'])) { |
707 | 818 | $row['image'] = ''; |
708 | 819 | $row['image_thumb'] = ''; |
@@ -738,7 +849,9 @@ discard block |
||
738 | 849 | |
739 | 850 | $i++; |
740 | 851 | } |
741 | - if ($globalTransaction) $Connection->db->commit(); |
|
852 | + if ($globalTransaction) { |
|
853 | + $Connection->db->commit(); |
|
854 | + } |
|
742 | 855 | echo "Delete duplicate rows...\n"; |
743 | 856 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
744 | 857 | try { |
@@ -750,7 +863,9 @@ discard block |
||
750 | 863 | } |
751 | 864 | |
752 | 865 | |
753 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
866 | + if ($globalDebug) { |
|
867 | + echo "Insert Not available Airport...\n"; |
|
868 | + } |
|
754 | 869 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
755 | 870 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
756 | 871 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -777,7 +892,9 @@ discard block |
||
777 | 892 | $delimiter = ','; |
778 | 893 | $out_file = $tmp_dir.'airports.csv'; |
779 | 894 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
780 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
895 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
896 | + return FALSE; |
|
897 | + } |
|
781 | 898 | echo "Add data from ourairports.com...\n"; |
782 | 899 | |
783 | 900 | $header = NULL; |
@@ -787,8 +904,9 @@ discard block |
||
787 | 904 | //$Connection->db->beginTransaction(); |
788 | 905 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
789 | 906 | { |
790 | - if(!$header) $header = $row; |
|
791 | - else { |
|
907 | + if(!$header) { |
|
908 | + $header = $row; |
|
909 | + } else { |
|
792 | 910 | $data = array(); |
793 | 911 | $data = array_combine($header, $row); |
794 | 912 | try { |
@@ -826,7 +944,9 @@ discard block |
||
826 | 944 | echo "Download data from another free database...\n"; |
827 | 945 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
828 | 946 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
829 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
947 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
948 | + return FALSE; |
|
949 | + } |
|
830 | 950 | update_db::unzip($out_file); |
831 | 951 | $header = NULL; |
832 | 952 | echo "Add data from another free database...\n"; |
@@ -837,8 +957,9 @@ discard block |
||
837 | 957 | //$Connection->db->beginTransaction(); |
838 | 958 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
839 | 959 | { |
840 | - if(!$header) $header = $row; |
|
841 | - else { |
|
960 | + if(!$header) { |
|
961 | + $header = $row; |
|
962 | + } else { |
|
842 | 963 | $data = $row; |
843 | 964 | |
844 | 965 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1014,7 +1135,9 @@ discard block |
||
1014 | 1135 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1015 | 1136 | { |
1016 | 1137 | $i = 0; |
1017 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1138 | + if ($globalTransaction) { |
|
1139 | + $Connection->db->beginTransaction(); |
|
1140 | + } |
|
1018 | 1141 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1019 | 1142 | { |
1020 | 1143 | if ($i > 0) { |
@@ -1027,7 +1150,9 @@ discard block |
||
1027 | 1150 | } |
1028 | 1151 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1029 | 1152 | if (!empty($result_search)) { |
1030 | - if ($globalDebug) echo '.'; |
|
1153 | + if ($globalDebug) { |
|
1154 | + echo '.'; |
|
1155 | + } |
|
1031 | 1156 | //if ($globalDBdriver == 'mysql') { |
1032 | 1157 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1033 | 1158 | //} else { |
@@ -1049,8 +1174,12 @@ discard block |
||
1049 | 1174 | } |
1050 | 1175 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1051 | 1176 | if (!empty($result_search_mfr)) { |
1052 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1053 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1177 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1178 | + $data[16] = $data[23]; |
|
1179 | + } |
|
1180 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1181 | + $data[16] = $data[15]; |
|
1182 | + } |
|
1054 | 1183 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1055 | 1184 | try { |
1056 | 1185 | $sthf = $Connection->db->prepare($queryf); |
@@ -1061,7 +1190,9 @@ discard block |
||
1061 | 1190 | } |
1062 | 1191 | } |
1063 | 1192 | if (strtotime($data[29]) > time()) { |
1064 | - if ($globalDebug) echo 'i'; |
|
1193 | + if ($globalDebug) { |
|
1194 | + echo 'i'; |
|
1195 | + } |
|
1065 | 1196 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1066 | 1197 | try { |
1067 | 1198 | $sth = $Connection->db->prepare($query); |
@@ -1072,13 +1203,19 @@ discard block |
||
1072 | 1203 | } |
1073 | 1204 | } |
1074 | 1205 | if ($i % 90 == 0) { |
1075 | - if ($globalTransaction) $Connection->db->commit(); |
|
1076 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1206 | + if ($globalTransaction) { |
|
1207 | + $Connection->db->commit(); |
|
1208 | + } |
|
1209 | + if ($globalTransaction) { |
|
1210 | + $Connection->db->beginTransaction(); |
|
1211 | + } |
|
1077 | 1212 | } |
1078 | 1213 | $i++; |
1079 | 1214 | } |
1080 | 1215 | fclose($handle); |
1081 | - if ($globalTransaction) $Connection->db->commit(); |
|
1216 | + if ($globalTransaction) { |
|
1217 | + $Connection->db->commit(); |
|
1218 | + } |
|
1082 | 1219 | } |
1083 | 1220 | print_r($mfr); |
1084 | 1221 | return ''; |
@@ -1103,11 +1240,15 @@ discard block |
||
1103 | 1240 | $i = 0; |
1104 | 1241 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1105 | 1242 | //$Connection->db->beginTransaction(); |
1106 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1243 | + if ($globalTransaction) { |
|
1244 | + $Connection->db->beginTransaction(); |
|
1245 | + } |
|
1107 | 1246 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1108 | 1247 | { |
1109 | 1248 | if ($i > 0) { |
1110 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1249 | + if ($data[1] == 'NULL') { |
|
1250 | + $data[1] = $data[0]; |
|
1251 | + } |
|
1111 | 1252 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1112 | 1253 | try { |
1113 | 1254 | $sth = $Connection->db->prepare($query); |
@@ -1119,7 +1260,9 @@ discard block |
||
1119 | 1260 | $i++; |
1120 | 1261 | } |
1121 | 1262 | fclose($handle); |
1122 | - if ($globalTransaction) $Connection->db->commit(); |
|
1263 | + if ($globalTransaction) { |
|
1264 | + $Connection->db->commit(); |
|
1265 | + } |
|
1123 | 1266 | } |
1124 | 1267 | return ''; |
1125 | 1268 | } |
@@ -1140,7 +1283,9 @@ discard block |
||
1140 | 1283 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1141 | 1284 | { |
1142 | 1285 | $i = 0; |
1143 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1286 | + if ($globalTransaction) { |
|
1287 | + $Connection->db->beginTransaction(); |
|
1288 | + } |
|
1144 | 1289 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1145 | 1290 | { |
1146 | 1291 | if ($i > 0) { |
@@ -1156,7 +1301,9 @@ discard block |
||
1156 | 1301 | $i++; |
1157 | 1302 | } |
1158 | 1303 | fclose($handle); |
1159 | - if ($globalTransaction) $Connection->db->commit(); |
|
1304 | + if ($globalTransaction) { |
|
1305 | + $Connection->db->commit(); |
|
1306 | + } |
|
1160 | 1307 | } |
1161 | 1308 | return ''; |
1162 | 1309 | } |
@@ -1181,7 +1328,9 @@ discard block |
||
1181 | 1328 | $i = 0; |
1182 | 1329 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1183 | 1330 | //$Connection->db->beginTransaction(); |
1184 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1331 | + if ($globalTransaction) { |
|
1332 | + $Connection->db->beginTransaction(); |
|
1333 | + } |
|
1185 | 1334 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1186 | 1335 | { |
1187 | 1336 | if ($i > 0) { |
@@ -1196,7 +1345,9 @@ discard block |
||
1196 | 1345 | $i++; |
1197 | 1346 | } |
1198 | 1347 | fclose($handle); |
1199 | - if ($globalTransaction) $Connection->db->commit(); |
|
1348 | + if ($globalTransaction) { |
|
1349 | + $Connection->db->commit(); |
|
1350 | + } |
|
1200 | 1351 | } |
1201 | 1352 | return ''; |
1202 | 1353 | } |
@@ -1215,7 +1366,9 @@ discard block |
||
1215 | 1366 | $Connection = new Connection(); |
1216 | 1367 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1217 | 1368 | { |
1218 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1369 | + if ($globalTransaction) { |
|
1370 | + $Connection->db->beginTransaction(); |
|
1371 | + } |
|
1219 | 1372 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1220 | 1373 | { |
1221 | 1374 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1230,7 +1383,9 @@ discard block |
||
1230 | 1383 | } |
1231 | 1384 | } |
1232 | 1385 | fclose($handle); |
1233 | - if ($globalTransaction) $Connection->db->commit(); |
|
1386 | + if ($globalTransaction) { |
|
1387 | + $Connection->db->commit(); |
|
1388 | + } |
|
1234 | 1389 | } |
1235 | 1390 | return ''; |
1236 | 1391 | } |
@@ -1381,7 +1536,9 @@ discard block |
||
1381 | 1536 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1382 | 1537 | { |
1383 | 1538 | $i = 0; |
1384 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1539 | + if ($globalTransaction) { |
|
1540 | + $Connection->db->beginTransaction(); |
|
1541 | + } |
|
1385 | 1542 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1386 | 1543 | { |
1387 | 1544 | $i++; |
@@ -1409,7 +1566,9 @@ discard block |
||
1409 | 1566 | } |
1410 | 1567 | } |
1411 | 1568 | fclose($handle); |
1412 | - if ($globalTransaction) $Connection->db->commit(); |
|
1569 | + if ($globalTransaction) { |
|
1570 | + $Connection->db->commit(); |
|
1571 | + } |
|
1413 | 1572 | } |
1414 | 1573 | return ''; |
1415 | 1574 | } |
@@ -1432,7 +1591,9 @@ discard block |
||
1432 | 1591 | $Connection = new Connection(); |
1433 | 1592 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1434 | 1593 | { |
1435 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1594 | + if ($globalTransaction) { |
|
1595 | + $Connection->db->beginTransaction(); |
|
1596 | + } |
|
1436 | 1597 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1437 | 1598 | { |
1438 | 1599 | if(count($row) > 1) { |
@@ -1446,7 +1607,9 @@ discard block |
||
1446 | 1607 | } |
1447 | 1608 | } |
1448 | 1609 | fclose($handle); |
1449 | - if ($globalTransaction) $Connection->db->commit(); |
|
1610 | + if ($globalTransaction) { |
|
1611 | + $Connection->db->commit(); |
|
1612 | + } |
|
1450 | 1613 | } |
1451 | 1614 | return ''; |
1452 | 1615 | } |
@@ -1466,8 +1629,9 @@ discard block |
||
1466 | 1629 | } |
1467 | 1630 | |
1468 | 1631 | |
1469 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1470 | - else { |
|
1632 | + if ($globalDBdriver == 'mysql') { |
|
1633 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1634 | + } else { |
|
1471 | 1635 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1472 | 1636 | $query = "CREATE EXTENSION postgis"; |
1473 | 1637 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1486,20 +1650,30 @@ discard block |
||
1486 | 1650 | global $tmp_dir, $globalDebug; |
1487 | 1651 | include_once('class.create_db.php'); |
1488 | 1652 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1489 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1653 | + if ($globalDebug) { |
|
1654 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1655 | + } |
|
1490 | 1656 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1491 | 1657 | $error = ''; |
1492 | 1658 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1493 | - if ($globalDebug) echo "Gunzip..."; |
|
1659 | + if ($globalDebug) { |
|
1660 | + echo "Gunzip..."; |
|
1661 | + } |
|
1494 | 1662 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1495 | - if ($globalDebug) echo "Add to DB..."; |
|
1663 | + if ($globalDebug) { |
|
1664 | + echo "Add to DB..."; |
|
1665 | + } |
|
1496 | 1666 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1497 | 1667 | $NOTAM = new NOTAM(); |
1498 | 1668 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1499 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1669 | + } else { |
|
1670 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1671 | + } |
|
1500 | 1672 | if ($error != '') { |
1501 | 1673 | return $error; |
1502 | - } elseif ($globalDebug) echo "Done\n"; |
|
1674 | + } elseif ($globalDebug) { |
|
1675 | + echo "Done\n"; |
|
1676 | + } |
|
1503 | 1677 | return ''; |
1504 | 1678 | } |
1505 | 1679 | |
@@ -1553,67 +1727,111 @@ discard block |
||
1553 | 1727 | //if ($globalDebug) echo "IVAO : Download..."; |
1554 | 1728 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1555 | 1729 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1556 | - if ($globalDebug) echo "Unzip..."; |
|
1730 | + if ($globalDebug) { |
|
1731 | + echo "Unzip..."; |
|
1732 | + } |
|
1557 | 1733 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1558 | - if ($globalDebug) echo "Add to DB..."; |
|
1734 | + if ($globalDebug) { |
|
1735 | + echo "Add to DB..."; |
|
1736 | + } |
|
1559 | 1737 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1560 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1738 | + if ($globalDebug) { |
|
1739 | + echo "Copy airlines logos to airlines images directory..."; |
|
1740 | + } |
|
1561 | 1741 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1562 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1563 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1564 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1742 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1743 | + $error = "Failed to copy airlines logo."; |
|
1744 | + } |
|
1745 | + } else { |
|
1746 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1747 | + } |
|
1748 | + } else { |
|
1749 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1750 | + } |
|
1565 | 1751 | if ($error != '') { |
1566 | 1752 | return $error; |
1567 | - } elseif ($globalDebug) echo "Done\n"; |
|
1753 | + } elseif ($globalDebug) { |
|
1754 | + echo "Done\n"; |
|
1755 | + } |
|
1568 | 1756 | return ''; |
1569 | 1757 | } |
1570 | 1758 | |
1571 | 1759 | public static function update_routes() { |
1572 | 1760 | global $tmp_dir, $globalDebug; |
1573 | 1761 | $error = ''; |
1574 | - if ($globalDebug) echo "Routes : Download..."; |
|
1762 | + if ($globalDebug) { |
|
1763 | + echo "Routes : Download..."; |
|
1764 | + } |
|
1575 | 1765 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1576 | 1766 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1577 | - if ($globalDebug) echo "Gunzip..."; |
|
1767 | + if ($globalDebug) { |
|
1768 | + echo "Gunzip..."; |
|
1769 | + } |
|
1578 | 1770 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1579 | - if ($globalDebug) echo "Add to DB..."; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo "Add to DB..."; |
|
1773 | + } |
|
1580 | 1774 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1581 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1775 | + } else { |
|
1776 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1777 | + } |
|
1582 | 1778 | if ($error != '') { |
1583 | 1779 | return $error; |
1584 | - } elseif ($globalDebug) echo "Done\n"; |
|
1780 | + } elseif ($globalDebug) { |
|
1781 | + echo "Done\n"; |
|
1782 | + } |
|
1585 | 1783 | return ''; |
1586 | 1784 | } |
1587 | 1785 | public static function update_oneworld() { |
1588 | 1786 | global $tmp_dir, $globalDebug; |
1589 | 1787 | $error = ''; |
1590 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1788 | + if ($globalDebug) { |
|
1789 | + echo "Schedules Oneworld : Download..."; |
|
1790 | + } |
|
1591 | 1791 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1592 | 1792 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1593 | - if ($globalDebug) echo "Gunzip..."; |
|
1793 | + if ($globalDebug) { |
|
1794 | + echo "Gunzip..."; |
|
1795 | + } |
|
1594 | 1796 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1595 | - if ($globalDebug) echo "Add to DB..."; |
|
1797 | + if ($globalDebug) { |
|
1798 | + echo "Add to DB..."; |
|
1799 | + } |
|
1596 | 1800 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1597 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1801 | + } else { |
|
1802 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1803 | + } |
|
1598 | 1804 | if ($error != '') { |
1599 | 1805 | return $error; |
1600 | - } elseif ($globalDebug) echo "Done\n"; |
|
1806 | + } elseif ($globalDebug) { |
|
1807 | + echo "Done\n"; |
|
1808 | + } |
|
1601 | 1809 | return ''; |
1602 | 1810 | } |
1603 | 1811 | public static function update_skyteam() { |
1604 | 1812 | global $tmp_dir, $globalDebug; |
1605 | 1813 | $error = ''; |
1606 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1814 | + if ($globalDebug) { |
|
1815 | + echo "Schedules Skyteam : Download..."; |
|
1816 | + } |
|
1607 | 1817 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1608 | 1818 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1609 | - if ($globalDebug) echo "Gunzip..."; |
|
1819 | + if ($globalDebug) { |
|
1820 | + echo "Gunzip..."; |
|
1821 | + } |
|
1610 | 1822 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1611 | - if ($globalDebug) echo "Add to DB..."; |
|
1823 | + if ($globalDebug) { |
|
1824 | + echo "Add to DB..."; |
|
1825 | + } |
|
1612 | 1826 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1613 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1827 | + } else { |
|
1828 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1829 | + } |
|
1614 | 1830 | if ($error != '') { |
1615 | 1831 | return $error; |
1616 | - } elseif ($globalDebug) echo "Done\n"; |
|
1832 | + } elseif ($globalDebug) { |
|
1833 | + echo "Done\n"; |
|
1834 | + } |
|
1617 | 1835 | return ''; |
1618 | 1836 | } |
1619 | 1837 | public static function update_ModeS() { |
@@ -1630,370 +1848,642 @@ discard block |
||
1630 | 1848 | exit; |
1631 | 1849 | } elseif ($globalDebug) echo "Done\n"; |
1632 | 1850 | */ |
1633 | - if ($globalDebug) echo "Modes : Download..."; |
|
1634 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1851 | + if ($globalDebug) { |
|
1852 | + echo "Modes : Download..."; |
|
1853 | + } |
|
1854 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1635 | 1855 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1636 | 1856 | |
1637 | 1857 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1638 | 1858 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1639 | - if ($globalDebug) echo "Unzip..."; |
|
1640 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo "Unzip..."; |
|
1861 | + } |
|
1862 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1641 | 1863 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1642 | - if ($globalDebug) echo "Add to DB..."; |
|
1864 | + if ($globalDebug) { |
|
1865 | + echo "Add to DB..."; |
|
1866 | + } |
|
1643 | 1867 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1644 | 1868 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1645 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1869 | + } else { |
|
1870 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1871 | + } |
|
1646 | 1872 | if ($error != '') { |
1647 | 1873 | return $error; |
1648 | - } elseif ($globalDebug) echo "Done\n"; |
|
1874 | + } elseif ($globalDebug) { |
|
1875 | + echo "Done\n"; |
|
1876 | + } |
|
1649 | 1877 | return ''; |
1650 | 1878 | } |
1651 | 1879 | |
1652 | 1880 | public static function update_ModeS_faa() { |
1653 | 1881 | global $tmp_dir, $globalDebug; |
1654 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1882 | + if ($globalDebug) { |
|
1883 | + echo "Modes FAA: Download..."; |
|
1884 | + } |
|
1655 | 1885 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1656 | 1886 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1657 | - if ($globalDebug) echo "Unzip..."; |
|
1887 | + if ($globalDebug) { |
|
1888 | + echo "Unzip..."; |
|
1889 | + } |
|
1658 | 1890 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1659 | - if ($globalDebug) echo "Add to DB..."; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo "Add to DB..."; |
|
1893 | + } |
|
1660 | 1894 | $error = update_db::modes_faa(); |
1661 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1895 | + } else { |
|
1896 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1897 | + } |
|
1662 | 1898 | if ($error != '') { |
1663 | 1899 | return $error; |
1664 | - } elseif ($globalDebug) echo "Done\n"; |
|
1900 | + } elseif ($globalDebug) { |
|
1901 | + echo "Done\n"; |
|
1902 | + } |
|
1665 | 1903 | return ''; |
1666 | 1904 | } |
1667 | 1905 | |
1668 | 1906 | public static function update_ModeS_flarm() { |
1669 | 1907 | global $tmp_dir, $globalDebug; |
1670 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo "Modes Flarmnet: Download..."; |
|
1910 | + } |
|
1671 | 1911 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1672 | 1912 | if (file_exists($tmp_dir.'data.fln')) { |
1673 | - if ($globalDebug) echo "Add to DB..."; |
|
1913 | + if ($globalDebug) { |
|
1914 | + echo "Add to DB..."; |
|
1915 | + } |
|
1674 | 1916 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1675 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1917 | + } else { |
|
1918 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1919 | + } |
|
1676 | 1920 | if ($error != '') { |
1677 | 1921 | return $error; |
1678 | - } elseif ($globalDebug) echo "Done\n"; |
|
1922 | + } elseif ($globalDebug) { |
|
1923 | + echo "Done\n"; |
|
1924 | + } |
|
1679 | 1925 | return ''; |
1680 | 1926 | } |
1681 | 1927 | |
1682 | 1928 | public static function update_ModeS_ogn() { |
1683 | 1929 | global $tmp_dir, $globalDebug; |
1684 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo "Modes OGN: Download..."; |
|
1932 | + } |
|
1685 | 1933 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1686 | 1934 | if (file_exists($tmp_dir.'ogn.csv')) { |
1687 | - if ($globalDebug) echo "Add to DB..."; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo "Add to DB..."; |
|
1937 | + } |
|
1688 | 1938 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1689 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1939 | + } else { |
|
1940 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1941 | + } |
|
1690 | 1942 | if ($error != '') { |
1691 | 1943 | return $error; |
1692 | - } elseif ($globalDebug) echo "Done\n"; |
|
1944 | + } elseif ($globalDebug) { |
|
1945 | + echo "Done\n"; |
|
1946 | + } |
|
1693 | 1947 | return ''; |
1694 | 1948 | } |
1695 | 1949 | |
1696 | 1950 | public static function update_owner() { |
1697 | 1951 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1698 | 1952 | |
1699 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1953 | + if ($globalDebug) { |
|
1954 | + echo "Owner France: Download..."; |
|
1955 | + } |
|
1700 | 1956 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1701 | 1957 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1702 | - if ($globalDebug) echo "Add to DB..."; |
|
1958 | + if ($globalDebug) { |
|
1959 | + echo "Add to DB..."; |
|
1960 | + } |
|
1703 | 1961 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1704 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1962 | + } else { |
|
1963 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1964 | + } |
|
1705 | 1965 | if ($error != '') { |
1706 | 1966 | return $error; |
1707 | - } elseif ($globalDebug) echo "Done\n"; |
|
1967 | + } elseif ($globalDebug) { |
|
1968 | + echo "Done\n"; |
|
1969 | + } |
|
1708 | 1970 | |
1709 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1971 | + if ($globalDebug) { |
|
1972 | + echo "Owner Ireland: Download..."; |
|
1973 | + } |
|
1710 | 1974 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1711 | 1975 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1712 | - if ($globalDebug) echo "Add to DB..."; |
|
1976 | + if ($globalDebug) { |
|
1977 | + echo "Add to DB..."; |
|
1978 | + } |
|
1713 | 1979 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1714 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1980 | + } else { |
|
1981 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1982 | + } |
|
1715 | 1983 | if ($error != '') { |
1716 | 1984 | return $error; |
1717 | - } elseif ($globalDebug) echo "Done\n"; |
|
1718 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1985 | + } elseif ($globalDebug) { |
|
1986 | + echo "Done\n"; |
|
1987 | + } |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo "Owner Switzerland: Download..."; |
|
1990 | + } |
|
1719 | 1991 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1720 | 1992 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1721 | - if ($globalDebug) echo "Add to DB..."; |
|
1993 | + if ($globalDebug) { |
|
1994 | + echo "Add to DB..."; |
|
1995 | + } |
|
1722 | 1996 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1723 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1997 | + } else { |
|
1998 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1999 | + } |
|
1724 | 2000 | if ($error != '') { |
1725 | 2001 | return $error; |
1726 | - } elseif ($globalDebug) echo "Done\n"; |
|
1727 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2002 | + } elseif ($globalDebug) { |
|
2003 | + echo "Done\n"; |
|
2004 | + } |
|
2005 | + if ($globalDebug) { |
|
2006 | + echo "Owner Czech Republic: Download..."; |
|
2007 | + } |
|
1728 | 2008 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1729 | 2009 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1730 | - if ($globalDebug) echo "Add to DB..."; |
|
2010 | + if ($globalDebug) { |
|
2011 | + echo "Add to DB..."; |
|
2012 | + } |
|
1731 | 2013 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1732 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2014 | + } else { |
|
2015 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2016 | + } |
|
1733 | 2017 | if ($error != '') { |
1734 | 2018 | return $error; |
1735 | - } elseif ($globalDebug) echo "Done\n"; |
|
1736 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2019 | + } elseif ($globalDebug) { |
|
2020 | + echo "Done\n"; |
|
2021 | + } |
|
2022 | + if ($globalDebug) { |
|
2023 | + echo "Owner Australia: Download..."; |
|
2024 | + } |
|
1737 | 2025 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1738 | 2026 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1739 | - if ($globalDebug) echo "Add to DB..."; |
|
2027 | + if ($globalDebug) { |
|
2028 | + echo "Add to DB..."; |
|
2029 | + } |
|
1740 | 2030 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1741 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2031 | + } else { |
|
2032 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2033 | + } |
|
1742 | 2034 | if ($error != '') { |
1743 | 2035 | return $error; |
1744 | - } elseif ($globalDebug) echo "Done\n"; |
|
1745 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2036 | + } elseif ($globalDebug) { |
|
2037 | + echo "Done\n"; |
|
2038 | + } |
|
2039 | + if ($globalDebug) { |
|
2040 | + echo "Owner Austria: Download..."; |
|
2041 | + } |
|
1746 | 2042 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1747 | 2043 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1748 | - if ($globalDebug) echo "Add to DB..."; |
|
2044 | + if ($globalDebug) { |
|
2045 | + echo "Add to DB..."; |
|
2046 | + } |
|
1749 | 2047 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1750 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2048 | + } else { |
|
2049 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2050 | + } |
|
1751 | 2051 | if ($error != '') { |
1752 | 2052 | return $error; |
1753 | - } elseif ($globalDebug) echo "Done\n"; |
|
1754 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2053 | + } elseif ($globalDebug) { |
|
2054 | + echo "Done\n"; |
|
2055 | + } |
|
2056 | + if ($globalDebug) { |
|
2057 | + echo "Owner Chile: Download..."; |
|
2058 | + } |
|
1755 | 2059 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1756 | 2060 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1757 | - if ($globalDebug) echo "Add to DB..."; |
|
2061 | + if ($globalDebug) { |
|
2062 | + echo "Add to DB..."; |
|
2063 | + } |
|
1758 | 2064 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1759 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2065 | + } else { |
|
2066 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2067 | + } |
|
1760 | 2068 | if ($error != '') { |
1761 | 2069 | return $error; |
1762 | - } elseif ($globalDebug) echo "Done\n"; |
|
1763 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2070 | + } elseif ($globalDebug) { |
|
2071 | + echo "Done\n"; |
|
2072 | + } |
|
2073 | + if ($globalDebug) { |
|
2074 | + echo "Owner Colombia: Download..."; |
|
2075 | + } |
|
1764 | 2076 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1765 | 2077 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1766 | - if ($globalDebug) echo "Add to DB..."; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo "Add to DB..."; |
|
2080 | + } |
|
1767 | 2081 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1768 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2082 | + } else { |
|
2083 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2084 | + } |
|
1769 | 2085 | if ($error != '') { |
1770 | 2086 | return $error; |
1771 | - } elseif ($globalDebug) echo "Done\n"; |
|
1772 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2087 | + } elseif ($globalDebug) { |
|
2088 | + echo "Done\n"; |
|
2089 | + } |
|
2090 | + if ($globalDebug) { |
|
2091 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2092 | + } |
|
1773 | 2093 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1774 | 2094 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1775 | - if ($globalDebug) echo "Add to DB..."; |
|
2095 | + if ($globalDebug) { |
|
2096 | + echo "Add to DB..."; |
|
2097 | + } |
|
1776 | 2098 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1777 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2099 | + } else { |
|
2100 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2101 | + } |
|
1778 | 2102 | if ($error != '') { |
1779 | 2103 | return $error; |
1780 | - } elseif ($globalDebug) echo "Done\n"; |
|
1781 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2104 | + } elseif ($globalDebug) { |
|
2105 | + echo "Done\n"; |
|
2106 | + } |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo "Owner Brazil: Download..."; |
|
2109 | + } |
|
1782 | 2110 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1783 | 2111 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1784 | - if ($globalDebug) echo "Add to DB..."; |
|
2112 | + if ($globalDebug) { |
|
2113 | + echo "Add to DB..."; |
|
2114 | + } |
|
1785 | 2115 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1786 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2116 | + } else { |
|
2117 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2118 | + } |
|
1787 | 2119 | if ($error != '') { |
1788 | 2120 | return $error; |
1789 | - } elseif ($globalDebug) echo "Done\n"; |
|
1790 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2121 | + } elseif ($globalDebug) { |
|
2122 | + echo "Done\n"; |
|
2123 | + } |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo "Owner Cayman Islands: Download..."; |
|
2126 | + } |
|
1791 | 2127 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1792 | 2128 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1793 | - if ($globalDebug) echo "Add to DB..."; |
|
2129 | + if ($globalDebug) { |
|
2130 | + echo "Add to DB..."; |
|
2131 | + } |
|
1794 | 2132 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1795 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2133 | + } else { |
|
2134 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2135 | + } |
|
1796 | 2136 | if ($error != '') { |
1797 | 2137 | return $error; |
1798 | - } elseif ($globalDebug) echo "Done\n"; |
|
1799 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2138 | + } elseif ($globalDebug) { |
|
2139 | + echo "Done\n"; |
|
2140 | + } |
|
2141 | + if ($globalDebug) { |
|
2142 | + echo "Owner Croatia: Download..."; |
|
2143 | + } |
|
1800 | 2144 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1801 | 2145 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1802 | - if ($globalDebug) echo "Add to DB..."; |
|
2146 | + if ($globalDebug) { |
|
2147 | + echo "Add to DB..."; |
|
2148 | + } |
|
1803 | 2149 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1804 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2150 | + } else { |
|
2151 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2152 | + } |
|
1805 | 2153 | if ($error != '') { |
1806 | 2154 | return $error; |
1807 | - } elseif ($globalDebug) echo "Done\n"; |
|
1808 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2155 | + } elseif ($globalDebug) { |
|
2156 | + echo "Done\n"; |
|
2157 | + } |
|
2158 | + if ($globalDebug) { |
|
2159 | + echo "Owner Luxembourg: Download..."; |
|
2160 | + } |
|
1809 | 2161 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1810 | 2162 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1811 | - if ($globalDebug) echo "Add to DB..."; |
|
2163 | + if ($globalDebug) { |
|
2164 | + echo "Add to DB..."; |
|
2165 | + } |
|
1812 | 2166 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1813 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2167 | + } else { |
|
2168 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2169 | + } |
|
1814 | 2170 | if ($error != '') { |
1815 | 2171 | return $error; |
1816 | - } elseif ($globalDebug) echo "Done\n"; |
|
1817 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2172 | + } elseif ($globalDebug) { |
|
2173 | + echo "Done\n"; |
|
2174 | + } |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo "Owner Maldives: Download..."; |
|
2177 | + } |
|
1818 | 2178 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1819 | 2179 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1820 | - if ($globalDebug) echo "Add to DB..."; |
|
2180 | + if ($globalDebug) { |
|
2181 | + echo "Add to DB..."; |
|
2182 | + } |
|
1821 | 2183 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1822 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2184 | + } else { |
|
2185 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2186 | + } |
|
1823 | 2187 | if ($error != '') { |
1824 | 2188 | return $error; |
1825 | - } elseif ($globalDebug) echo "Done\n"; |
|
1826 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2189 | + } elseif ($globalDebug) { |
|
2190 | + echo "Done\n"; |
|
2191 | + } |
|
2192 | + if ($globalDebug) { |
|
2193 | + echo "Owner New Zealand: Download..."; |
|
2194 | + } |
|
1827 | 2195 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1828 | 2196 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1829 | - if ($globalDebug) echo "Add to DB..."; |
|
2197 | + if ($globalDebug) { |
|
2198 | + echo "Add to DB..."; |
|
2199 | + } |
|
1830 | 2200 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1831 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2201 | + } else { |
|
2202 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2203 | + } |
|
1832 | 2204 | if ($error != '') { |
1833 | 2205 | return $error; |
1834 | - } elseif ($globalDebug) echo "Done\n"; |
|
1835 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2206 | + } elseif ($globalDebug) { |
|
2207 | + echo "Done\n"; |
|
2208 | + } |
|
2209 | + if ($globalDebug) { |
|
2210 | + echo "Owner Papua New Guinea: Download..."; |
|
2211 | + } |
|
1836 | 2212 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1837 | 2213 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1838 | - if ($globalDebug) echo "Add to DB..."; |
|
2214 | + if ($globalDebug) { |
|
2215 | + echo "Add to DB..."; |
|
2216 | + } |
|
1839 | 2217 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1840 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2218 | + } else { |
|
2219 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2220 | + } |
|
1841 | 2221 | if ($error != '') { |
1842 | 2222 | return $error; |
1843 | - } elseif ($globalDebug) echo "Done\n"; |
|
1844 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2223 | + } elseif ($globalDebug) { |
|
2224 | + echo "Done\n"; |
|
2225 | + } |
|
2226 | + if ($globalDebug) { |
|
2227 | + echo "Owner Slovakia: Download..."; |
|
2228 | + } |
|
1845 | 2229 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1846 | 2230 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1847 | - if ($globalDebug) echo "Add to DB..."; |
|
2231 | + if ($globalDebug) { |
|
2232 | + echo "Add to DB..."; |
|
2233 | + } |
|
1848 | 2234 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1849 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2235 | + } else { |
|
2236 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2237 | + } |
|
1850 | 2238 | if ($error != '') { |
1851 | 2239 | return $error; |
1852 | - } elseif ($globalDebug) echo "Done\n"; |
|
1853 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2240 | + } elseif ($globalDebug) { |
|
2241 | + echo "Done\n"; |
|
2242 | + } |
|
2243 | + if ($globalDebug) { |
|
2244 | + echo "Owner Ecuador: Download..."; |
|
2245 | + } |
|
1854 | 2246 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1855 | 2247 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1856 | - if ($globalDebug) echo "Add to DB..."; |
|
2248 | + if ($globalDebug) { |
|
2249 | + echo "Add to DB..."; |
|
2250 | + } |
|
1857 | 2251 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1858 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2252 | + } else { |
|
2253 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2254 | + } |
|
1859 | 2255 | if ($error != '') { |
1860 | 2256 | return $error; |
1861 | - } elseif ($globalDebug) echo "Done\n"; |
|
1862 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2257 | + } elseif ($globalDebug) { |
|
2258 | + echo "Done\n"; |
|
2259 | + } |
|
2260 | + if ($globalDebug) { |
|
2261 | + echo "Owner Iceland: Download..."; |
|
2262 | + } |
|
1863 | 2263 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1864 | 2264 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1865 | - if ($globalDebug) echo "Add to DB..."; |
|
2265 | + if ($globalDebug) { |
|
2266 | + echo "Add to DB..."; |
|
2267 | + } |
|
1866 | 2268 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1867 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2269 | + } else { |
|
2270 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2271 | + } |
|
1868 | 2272 | if ($error != '') { |
1869 | 2273 | return $error; |
1870 | - } elseif ($globalDebug) echo "Done\n"; |
|
1871 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2274 | + } elseif ($globalDebug) { |
|
2275 | + echo "Done\n"; |
|
2276 | + } |
|
2277 | + if ($globalDebug) { |
|
2278 | + echo "Owner Isle of Man: Download..."; |
|
2279 | + } |
|
1872 | 2280 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
1873 | 2281 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1874 | - if ($globalDebug) echo "Add to DB..."; |
|
2282 | + if ($globalDebug) { |
|
2283 | + echo "Add to DB..."; |
|
2284 | + } |
|
1875 | 2285 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
1876 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2286 | + } else { |
|
2287 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2288 | + } |
|
1877 | 2289 | if ($error != '') { |
1878 | 2290 | return $error; |
1879 | - } elseif ($globalDebug) echo "Done\n"; |
|
2291 | + } elseif ($globalDebug) { |
|
2292 | + echo "Done\n"; |
|
2293 | + } |
|
1880 | 2294 | if ($globalMasterSource) { |
1881 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2295 | + if ($globalDebug) { |
|
2296 | + echo "ModeS Netherlands: Download..."; |
|
2297 | + } |
|
1882 | 2298 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
1883 | 2299 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1884 | - if ($globalDebug) echo "Add to DB..."; |
|
2300 | + if ($globalDebug) { |
|
2301 | + echo "Add to DB..."; |
|
2302 | + } |
|
1885 | 2303 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
1886 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2304 | + } else { |
|
2305 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2306 | + } |
|
1887 | 2307 | if ($error != '') { |
1888 | 2308 | return $error; |
1889 | - } elseif ($globalDebug) echo "Done\n"; |
|
1890 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2309 | + } elseif ($globalDebug) { |
|
2310 | + echo "Done\n"; |
|
2311 | + } |
|
2312 | + if ($globalDebug) { |
|
2313 | + echo "ModeS Denmark: Download..."; |
|
2314 | + } |
|
1891 | 2315 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
1892 | 2316 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1893 | - if ($globalDebug) echo "Add to DB..."; |
|
2317 | + if ($globalDebug) { |
|
2318 | + echo "Add to DB..."; |
|
2319 | + } |
|
1894 | 2320 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
1895 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2321 | + } else { |
|
2322 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2323 | + } |
|
1896 | 2324 | if ($error != '') { |
1897 | 2325 | return $error; |
1898 | - } elseif ($globalDebug) echo "Done\n"; |
|
1899 | - } elseif ($globalDebug) echo "Done\n"; |
|
2326 | + } elseif ($globalDebug) { |
|
2327 | + echo "Done\n"; |
|
2328 | + } |
|
2329 | + } elseif ($globalDebug) { |
|
2330 | + echo "Done\n"; |
|
2331 | + } |
|
1900 | 2332 | return ''; |
1901 | 2333 | } |
1902 | 2334 | |
1903 | 2335 | public static function update_translation() { |
1904 | 2336 | global $tmp_dir, $globalDebug; |
1905 | 2337 | $error = ''; |
1906 | - if ($globalDebug) echo "Translation : Download..."; |
|
2338 | + if ($globalDebug) { |
|
2339 | + echo "Translation : Download..."; |
|
2340 | + } |
|
1907 | 2341 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1908 | 2342 | if (file_exists($tmp_dir.'translation.zip')) { |
1909 | - if ($globalDebug) echo "Unzip..."; |
|
2343 | + if ($globalDebug) { |
|
2344 | + echo "Unzip..."; |
|
2345 | + } |
|
1910 | 2346 | update_db::unzip($tmp_dir.'translation.zip'); |
1911 | - if ($globalDebug) echo "Add to DB..."; |
|
2347 | + if ($globalDebug) { |
|
2348 | + echo "Add to DB..."; |
|
2349 | + } |
|
1912 | 2350 | $error = update_db::translation(); |
1913 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2351 | + } else { |
|
2352 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2353 | + } |
|
1914 | 2354 | if ($error != '') { |
1915 | 2355 | return $error; |
1916 | - } elseif ($globalDebug) echo "Done\n"; |
|
2356 | + } elseif ($globalDebug) { |
|
2357 | + echo "Done\n"; |
|
2358 | + } |
|
1917 | 2359 | return ''; |
1918 | 2360 | } |
1919 | 2361 | |
1920 | 2362 | public static function update_translation_fam() { |
1921 | 2363 | global $tmp_dir, $globalDebug; |
1922 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2364 | + if ($globalDebug) { |
|
2365 | + echo "Translation from FlightAirMap website : Download..."; |
|
2366 | + } |
|
1923 | 2367 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1924 | 2368 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1925 | - if ($globalDebug) echo "Gunzip..."; |
|
2369 | + if ($globalDebug) { |
|
2370 | + echo "Gunzip..."; |
|
2371 | + } |
|
1926 | 2372 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1927 | - if ($globalDebug) echo "Add to DB..."; |
|
2373 | + if ($globalDebug) { |
|
2374 | + echo "Add to DB..."; |
|
2375 | + } |
|
1928 | 2376 | $error = update_db::translation_fam(); |
1929 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2377 | + } else { |
|
2378 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2379 | + } |
|
1930 | 2380 | if ($error != '') { |
1931 | 2381 | return $error; |
1932 | - } elseif ($globalDebug) echo "Done\n"; |
|
2382 | + } elseif ($globalDebug) { |
|
2383 | + echo "Done\n"; |
|
2384 | + } |
|
1933 | 2385 | return ''; |
1934 | 2386 | } |
1935 | 2387 | public static function update_ModeS_fam() { |
1936 | 2388 | global $tmp_dir, $globalDebug; |
1937 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2389 | + if ($globalDebug) { |
|
2390 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2391 | + } |
|
1938 | 2392 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1939 | 2393 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1940 | - if ($globalDebug) echo "Gunzip..."; |
|
2394 | + if ($globalDebug) { |
|
2395 | + echo "Gunzip..."; |
|
2396 | + } |
|
1941 | 2397 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1942 | - if ($globalDebug) echo "Add to DB..."; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo "Add to DB..."; |
|
2400 | + } |
|
1943 | 2401 | $error = update_db::modes_fam(); |
1944 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2402 | + } else { |
|
2403 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2404 | + } |
|
1945 | 2405 | if ($error != '') { |
1946 | 2406 | return $error; |
1947 | - } elseif ($globalDebug) echo "Done\n"; |
|
2407 | + } elseif ($globalDebug) { |
|
2408 | + echo "Done\n"; |
|
2409 | + } |
|
1948 | 2410 | return ''; |
1949 | 2411 | } |
1950 | 2412 | public static function update_owner_fam() { |
1951 | 2413 | global $tmp_dir, $globalDebug, $globalOwner; |
1952 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2414 | + if ($globalDebug) { |
|
2415 | + echo "owner from FlightAirMap website : Download..."; |
|
2416 | + } |
|
1953 | 2417 | if ($globalOwner === TRUE) { |
1954 | 2418 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1955 | 2419 | } else { |
1956 | 2420 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1957 | 2421 | } |
1958 | 2422 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1959 | - if ($globalDebug) echo "Gunzip..."; |
|
2423 | + if ($globalDebug) { |
|
2424 | + echo "Gunzip..."; |
|
2425 | + } |
|
1960 | 2426 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
1961 | - if ($globalDebug) echo "Add to DB..."; |
|
2427 | + if ($globalDebug) { |
|
2428 | + echo "Add to DB..."; |
|
2429 | + } |
|
1962 | 2430 | $error = update_db::owner_fam(); |
1963 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2431 | + } else { |
|
2432 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2433 | + } |
|
1964 | 2434 | if ($error != '') { |
1965 | 2435 | return $error; |
1966 | - } elseif ($globalDebug) echo "Done\n"; |
|
2436 | + } elseif ($globalDebug) { |
|
2437 | + echo "Done\n"; |
|
2438 | + } |
|
1967 | 2439 | return ''; |
1968 | 2440 | } |
1969 | 2441 | public static function update_routes_fam() { |
1970 | 2442 | global $tmp_dir, $globalDebug; |
1971 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2443 | + if ($globalDebug) { |
|
2444 | + echo "Routes from FlightAirMap website : Download..."; |
|
2445 | + } |
|
1972 | 2446 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
1973 | 2447 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1974 | - if ($globalDebug) echo "Gunzip..."; |
|
2448 | + if ($globalDebug) { |
|
2449 | + echo "Gunzip..."; |
|
2450 | + } |
|
1975 | 2451 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
1976 | - if ($globalDebug) echo "Add to DB..."; |
|
2452 | + if ($globalDebug) { |
|
2453 | + echo "Add to DB..."; |
|
2454 | + } |
|
1977 | 2455 | $error = update_db::routes_fam(); |
1978 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2456 | + } else { |
|
2457 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2458 | + } |
|
1979 | 2459 | if ($error != '') { |
1980 | 2460 | return $error; |
1981 | - } elseif ($globalDebug) echo "Done\n"; |
|
2461 | + } elseif ($globalDebug) { |
|
2462 | + echo "Done\n"; |
|
2463 | + } |
|
1982 | 2464 | return ''; |
1983 | 2465 | } |
1984 | 2466 | public static function update_banned_fam() { |
1985 | 2467 | global $tmp_dir, $globalDebug; |
1986 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2468 | + if ($globalDebug) { |
|
2469 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2470 | + } |
|
1987 | 2471 | update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); |
1988 | 2472 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
1989 | 2473 | //if ($globalDebug) echo "Gunzip..."; |
1990 | 2474 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
1991 | - if ($globalDebug) echo "Add to DB..."; |
|
2475 | + if ($globalDebug) { |
|
2476 | + echo "Add to DB..."; |
|
2477 | + } |
|
1992 | 2478 | $error = update_db::banned_fam(); |
1993 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2479 | + } else { |
|
2480 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2481 | + } |
|
1994 | 2482 | if ($error != '') { |
1995 | 2483 | return $error; |
1996 | - } elseif ($globalDebug) echo "Done\n"; |
|
2484 | + } elseif ($globalDebug) { |
|
2485 | + echo "Done\n"; |
|
2486 | + } |
|
1997 | 2487 | return ''; |
1998 | 2488 | } |
1999 | 2489 | |
@@ -2001,7 +2491,9 @@ discard block |
||
2001 | 2491 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2002 | 2492 | include_once('class.create_db.php'); |
2003 | 2493 | $error = ''; |
2004 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2494 | + if ($globalDebug) { |
|
2495 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2496 | + } |
|
2005 | 2497 | if ($globalDBdriver == 'mysql') { |
2006 | 2498 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2007 | 2499 | } else { |
@@ -2017,9 +2509,13 @@ discard block |
||
2017 | 2509 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
2018 | 2510 | } |
2019 | 2511 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2020 | - if ($globalDebug) echo "Gunzip..."; |
|
2512 | + if ($globalDebug) { |
|
2513 | + echo "Gunzip..."; |
|
2514 | + } |
|
2021 | 2515 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2022 | - if ($globalDebug) echo "Add to DB..."; |
|
2516 | + if ($globalDebug) { |
|
2517 | + echo "Add to DB..."; |
|
2518 | + } |
|
2023 | 2519 | $Connection = new Connection(); |
2024 | 2520 | if ($Connection->tableExists('airspace')) { |
2025 | 2521 | $query = 'DROP TABLE airspace'; |
@@ -2032,31 +2528,47 @@ discard block |
||
2032 | 2528 | } |
2033 | 2529 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2034 | 2530 | update_db::insert_airspace_version($airspace_md5); |
2035 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2531 | + } else { |
|
2532 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2533 | + } |
|
2036 | 2534 | } |
2037 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2535 | + } else { |
|
2536 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2537 | + } |
|
2038 | 2538 | if ($error != '') { |
2039 | 2539 | return $error; |
2040 | - } elseif ($globalDebug) echo "Done\n"; |
|
2540 | + } elseif ($globalDebug) { |
|
2541 | + echo "Done\n"; |
|
2542 | + } |
|
2041 | 2543 | return ''; |
2042 | 2544 | } |
2043 | 2545 | |
2044 | 2546 | public static function update_tle() { |
2045 | 2547 | global $tmp_dir, $globalDebug; |
2046 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2548 | + if ($globalDebug) { |
|
2549 | + echo "Download TLE : Download..."; |
|
2550 | + } |
|
2047 | 2551 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
2048 | 2552 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
2049 | 2553 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
2050 | 2554 | foreach ($alltle as $filename) { |
2051 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo "downloading ".$filename.'...'; |
|
2557 | + } |
|
2052 | 2558 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2053 | 2559 | if (file_exists($tmp_dir.$filename)) { |
2054 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2560 | + if ($globalDebug) { |
|
2561 | + echo "Add to DB ".$filename."..."; |
|
2562 | + } |
|
2055 | 2563 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2056 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2564 | + } else { |
|
2565 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2566 | + } |
|
2057 | 2567 | if ($error != '') { |
2058 | 2568 | echo $error."\n"; |
2059 | - } elseif ($globalDebug) echo "Done\n"; |
|
2569 | + } elseif ($globalDebug) { |
|
2570 | + echo "Done\n"; |
|
2571 | + } |
|
2060 | 2572 | } |
2061 | 2573 | return ''; |
2062 | 2574 | } |
@@ -2064,10 +2576,14 @@ discard block |
||
2064 | 2576 | public static function update_models() { |
2065 | 2577 | global $tmp_dir, $globalDebug; |
2066 | 2578 | $error = ''; |
2067 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2579 | + if ($globalDebug) { |
|
2580 | + echo "Models from FlightAirMap website : Download..."; |
|
2581 | + } |
|
2068 | 2582 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2069 | 2583 | if (file_exists($tmp_dir.'models.md5sum')) { |
2070 | - if ($globalDebug) echo "Check files...\n"; |
|
2584 | + if ($globalDebug) { |
|
2585 | + echo "Check files...\n"; |
|
2586 | + } |
|
2071 | 2587 | $newmodelsdb = array(); |
2072 | 2588 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2073 | 2589 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2086,25 +2602,35 @@ discard block |
||
2086 | 2602 | } |
2087 | 2603 | $diff = array_diff($newmodelsdb,$modelsdb); |
2088 | 2604 | foreach ($diff as $key => $value) { |
2089 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2605 | + if ($globalDebug) { |
|
2606 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2607 | + } |
|
2090 | 2608 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2091 | 2609 | |
2092 | 2610 | } |
2093 | 2611 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2094 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2612 | + } else { |
|
2613 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2614 | + } |
|
2095 | 2615 | if ($error != '') { |
2096 | 2616 | return $error; |
2097 | - } elseif ($globalDebug) echo "Done\n"; |
|
2617 | + } elseif ($globalDebug) { |
|
2618 | + echo "Done\n"; |
|
2619 | + } |
|
2098 | 2620 | return ''; |
2099 | 2621 | } |
2100 | 2622 | |
2101 | 2623 | public static function update_space_models() { |
2102 | 2624 | global $tmp_dir, $globalDebug; |
2103 | 2625 | $error = ''; |
2104 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2626 | + if ($globalDebug) { |
|
2627 | + echo "Space models from FlightAirMap website : Download..."; |
|
2628 | + } |
|
2105 | 2629 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2106 | 2630 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2107 | - if ($globalDebug) echo "Check files...\n"; |
|
2631 | + if ($globalDebug) { |
|
2632 | + echo "Check files...\n"; |
|
2633 | + } |
|
2108 | 2634 | $newmodelsdb = array(); |
2109 | 2635 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2110 | 2636 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2123,25 +2649,35 @@ discard block |
||
2123 | 2649 | } |
2124 | 2650 | $diff = array_diff($newmodelsdb,$modelsdb); |
2125 | 2651 | foreach ($diff as $key => $value) { |
2126 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2652 | + if ($globalDebug) { |
|
2653 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2654 | + } |
|
2127 | 2655 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2128 | 2656 | |
2129 | 2657 | } |
2130 | 2658 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2131 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2659 | + } else { |
|
2660 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2661 | + } |
|
2132 | 2662 | if ($error != '') { |
2133 | 2663 | return $error; |
2134 | - } elseif ($globalDebug) echo "Done\n"; |
|
2664 | + } elseif ($globalDebug) { |
|
2665 | + echo "Done\n"; |
|
2666 | + } |
|
2135 | 2667 | return ''; |
2136 | 2668 | } |
2137 | 2669 | |
2138 | 2670 | public static function update_vehicules_models() { |
2139 | 2671 | global $tmp_dir, $globalDebug; |
2140 | 2672 | $error = ''; |
2141 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
2673 | + if ($globalDebug) { |
|
2674 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
2675 | + } |
|
2142 | 2676 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2143 | 2677 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2144 | - if ($globalDebug) echo "Check files...\n"; |
|
2678 | + if ($globalDebug) { |
|
2679 | + echo "Check files...\n"; |
|
2680 | + } |
|
2145 | 2681 | $newmodelsdb = array(); |
2146 | 2682 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2147 | 2683 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2160,15 +2696,21 @@ discard block |
||
2160 | 2696 | } |
2161 | 2697 | $diff = array_diff($newmodelsdb,$modelsdb); |
2162 | 2698 | foreach ($diff as $key => $value) { |
2163 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2699 | + if ($globalDebug) { |
|
2700 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2701 | + } |
|
2164 | 2702 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2165 | 2703 | |
2166 | 2704 | } |
2167 | 2705 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2168 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2706 | + } else { |
|
2707 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2708 | + } |
|
2169 | 2709 | if ($error != '') { |
2170 | 2710 | return $error; |
2171 | - } elseif ($globalDebug) echo "Done\n"; |
|
2711 | + } elseif ($globalDebug) { |
|
2712 | + echo "Done\n"; |
|
2713 | + } |
|
2172 | 2714 | return ''; |
2173 | 2715 | } |
2174 | 2716 | |
@@ -2211,7 +2753,9 @@ discard block |
||
2211 | 2753 | } |
2212 | 2754 | |
2213 | 2755 | $error = ''; |
2214 | - if ($globalDebug) echo "Notam : Download..."; |
|
2756 | + if ($globalDebug) { |
|
2757 | + echo "Notam : Download..."; |
|
2758 | + } |
|
2215 | 2759 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2216 | 2760 | if (file_exists($tmp_dir.'notam.rss')) { |
2217 | 2761 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2226,14 +2770,30 @@ discard block |
||
2226 | 2770 | $data['fir'] = $q[0]; |
2227 | 2771 | $data['code'] = $q[1]; |
2228 | 2772 | $ifrvfr = $q[2]; |
2229 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2230 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2231 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2232 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2233 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2234 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2235 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2236 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2773 | + if ($ifrvfr == 'IV') { |
|
2774 | + $data['rules'] = 'IFR/VFR'; |
|
2775 | + } |
|
2776 | + if ($ifrvfr == 'I') { |
|
2777 | + $data['rules'] = 'IFR'; |
|
2778 | + } |
|
2779 | + if ($ifrvfr == 'V') { |
|
2780 | + $data['rules'] = 'VFR'; |
|
2781 | + } |
|
2782 | + if ($q[4] == 'A') { |
|
2783 | + $data['scope'] = 'Airport warning'; |
|
2784 | + } |
|
2785 | + if ($q[4] == 'E') { |
|
2786 | + $data['scope'] = 'Enroute warning'; |
|
2787 | + } |
|
2788 | + if ($q[4] == 'W') { |
|
2789 | + $data['scope'] = 'Navigation warning'; |
|
2790 | + } |
|
2791 | + if ($q[4] == 'AE') { |
|
2792 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2793 | + } |
|
2794 | + if ($q[4] == 'AW') { |
|
2795 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2796 | + } |
|
2237 | 2797 | //$data['scope'] = $q[4]; |
2238 | 2798 | $data['lower_limit'] = $q[5]; |
2239 | 2799 | $data['upper_limit'] = $q[6]; |
@@ -2241,8 +2801,12 @@ discard block |
||
2241 | 2801 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2242 | 2802 | $latitude = $Common->convertDec($las,'latitude'); |
2243 | 2803 | $longitude = $Common->convertDec($lns,'longitude'); |
2244 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2245 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2804 | + if ($lac == 'S') { |
|
2805 | + $latitude = '-'.$latitude; |
|
2806 | + } |
|
2807 | + if ($lnc == 'W') { |
|
2808 | + $longitude = '-'.$longitude; |
|
2809 | + } |
|
2246 | 2810 | $data['center_latitude'] = $latitude; |
2247 | 2811 | $data['center_longitude'] = $longitude; |
2248 | 2812 | $data['radius'] = intval($radius); |
@@ -2272,10 +2836,14 @@ discard block |
||
2272 | 2836 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
2273 | 2837 | unset($data); |
2274 | 2838 | } |
2275 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2839 | + } else { |
|
2840 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2841 | + } |
|
2276 | 2842 | if ($error != '') { |
2277 | 2843 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2844 | + } elseif ($globalDebug) { |
|
2845 | + echo "Done\n"; |
|
2846 | + } |
|
2279 | 2847 | return ''; |
2280 | 2848 | } |
2281 | 2849 | |
@@ -2300,7 +2868,9 @@ discard block |
||
2300 | 2868 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2301 | 2869 | $airspace_json = json_decode($airspace_lst,true); |
2302 | 2870 | foreach ($airspace_json['records'] as $airspace) { |
2303 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2871 | + if ($globalDebug) { |
|
2872 | + echo $airspace['name']."...\n"; |
|
2873 | + } |
|
2304 | 2874 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2305 | 2875 | if (file_exists($tmp_dir.$airspace['name'])) { |
2306 | 2876 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2344,8 +2914,11 @@ discard block |
||
2344 | 2914 | return "error : ".$e->getMessage(); |
2345 | 2915 | } |
2346 | 2916 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2347 | - if ($row['nb'] > 0) return false; |
|
2348 | - else return true; |
|
2917 | + if ($row['nb'] > 0) { |
|
2918 | + return false; |
|
2919 | + } else { |
|
2920 | + return true; |
|
2921 | + } |
|
2349 | 2922 | } |
2350 | 2923 | |
2351 | 2924 | public static function insert_last_update() { |
@@ -2370,8 +2943,11 @@ discard block |
||
2370 | 2943 | return "error : ".$e->getMessage(); |
2371 | 2944 | } |
2372 | 2945 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2373 | - if ($row['nb'] > 0) return true; |
|
2374 | - else return false; |
|
2946 | + if ($row['nb'] > 0) { |
|
2947 | + return true; |
|
2948 | + } else { |
|
2949 | + return false; |
|
2950 | + } |
|
2375 | 2951 | } |
2376 | 2952 | |
2377 | 2953 | |
@@ -2402,8 +2978,11 @@ discard block |
||
2402 | 2978 | return "error : ".$e->getMessage(); |
2403 | 2979 | } |
2404 | 2980 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2405 | - if ($row['nb'] > 0) return false; |
|
2406 | - else return true; |
|
2981 | + if ($row['nb'] > 0) { |
|
2982 | + return false; |
|
2983 | + } else { |
|
2984 | + return true; |
|
2985 | + } |
|
2407 | 2986 | } |
2408 | 2987 | |
2409 | 2988 | public static function insert_last_notam_update() { |
@@ -2432,8 +3011,11 @@ discard block |
||
2432 | 3011 | return "error : ".$e->getMessage(); |
2433 | 3012 | } |
2434 | 3013 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2435 | - if ($row['nb'] > 0) return false; |
|
2436 | - else return true; |
|
3014 | + if ($row['nb'] > 0) { |
|
3015 | + return false; |
|
3016 | + } else { |
|
3017 | + return true; |
|
3018 | + } |
|
2437 | 3019 | } |
2438 | 3020 | |
2439 | 3021 | public static function insert_last_airspace_update() { |
@@ -2463,8 +3045,11 @@ discard block |
||
2463 | 3045 | return "error : ".$e->getMessage(); |
2464 | 3046 | } |
2465 | 3047 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2466 | - if ($row['nb'] > 0) return false; |
|
2467 | - else return true; |
|
3048 | + if ($row['nb'] > 0) { |
|
3049 | + return false; |
|
3050 | + } else { |
|
3051 | + return true; |
|
3052 | + } |
|
2468 | 3053 | } |
2469 | 3054 | |
2470 | 3055 | public static function insert_last_owner_update() { |
@@ -2493,8 +3078,11 @@ discard block |
||
2493 | 3078 | return "error : ".$e->getMessage(); |
2494 | 3079 | } |
2495 | 3080 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2496 | - if ($row['nb'] > 0) return false; |
|
2497 | - else return true; |
|
3081 | + if ($row['nb'] > 0) { |
|
3082 | + return false; |
|
3083 | + } else { |
|
3084 | + return true; |
|
3085 | + } |
|
2498 | 3086 | } |
2499 | 3087 | |
2500 | 3088 | public static function insert_last_schedules_update() { |
@@ -2523,8 +3111,11 @@ discard block |
||
2523 | 3111 | return "error : ".$e->getMessage(); |
2524 | 3112 | } |
2525 | 3113 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2526 | - if ($row['nb'] > 0) return false; |
|
2527 | - else return true; |
|
3114 | + if ($row['nb'] > 0) { |
|
3115 | + return false; |
|
3116 | + } else { |
|
3117 | + return true; |
|
3118 | + } |
|
2528 | 3119 | } |
2529 | 3120 | |
2530 | 3121 | public static function insert_last_tle_update() { |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
78 | 80 | } |
79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
81 | + if ($filter_query_where == '' && $where) { |
|
82 | + $filter_query_where = ' WHERE'; |
|
83 | + } elseif ($filter_query_where != '' && $and) { |
|
84 | + $filter_query_where .= ' AND'; |
|
85 | + } |
|
81 | 86 | if ($filter_query_where != '') { |
82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
83 | 88 | } |
@@ -119,7 +124,9 @@ discard block |
||
119 | 124 | } |
120 | 125 | } |
121 | 126 | |
122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
127 | + if (!isset($globalLiveInterval)) { |
|
128 | + $globalLiveInterval = '200'; |
|
129 | + } |
|
123 | 130 | if ($globalDBdriver == 'mysql') { |
124 | 131 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
125 | 132 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
144 | 151 | |
145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
146 | 153 | |
147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
154 | + if (!isset($globalLiveInterval)) { |
|
155 | + $globalLiveInterval = '200'; |
|
156 | + } |
|
148 | 157 | if ($globalDBdriver == 'mysql') { |
149 | 158 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
150 | 159 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -178,7 +187,9 @@ discard block |
||
178 | 187 | |
179 | 188 | $filter_query = $this->getFilter($filter,true,true); |
180 | 189 | |
181 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
190 | + if (!isset($globalLiveInterval)) { |
|
191 | + $globalLiveInterval = '200'; |
|
192 | + } |
|
182 | 193 | if ($globalDBdriver == 'mysql') { |
183 | 194 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
184 | 195 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -211,7 +222,9 @@ discard block |
||
211 | 222 | global $globalDBdriver, $globalLiveInterval; |
212 | 223 | $filter_query = $this->getFilter($filter,true,true); |
213 | 224 | |
214 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
225 | + if (!isset($globalLiveInterval)) { |
|
226 | + $globalLiveInterval = '200'; |
|
227 | + } |
|
215 | 228 | if ($globalDBdriver == 'mysql') { |
216 | 229 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
217 | 230 | } else { |
@@ -239,7 +252,9 @@ discard block |
||
239 | 252 | { |
240 | 253 | global $globalDBdriver, $globalLiveInterval; |
241 | 254 | $Spotter = new Spotter($this->db); |
242 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
255 | + if (!isset($globalLiveInterval)) { |
|
256 | + $globalLiveInterval = '200'; |
|
257 | + } |
|
243 | 258 | $filter_query = $this->getFilter($filter); |
244 | 259 | |
245 | 260 | if (is_array($coord)) { |
@@ -247,7 +262,9 @@ discard block |
||
247 | 262 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
248 | 263 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
249 | 264 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
250 | - } else return array(); |
|
265 | + } else { |
|
266 | + return array(); |
|
267 | + } |
|
251 | 268 | if ($globalDBdriver == 'mysql') { |
252 | 269 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
253 | 270 | } else { |
@@ -411,11 +428,15 @@ discard block |
||
411 | 428 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
412 | 429 | if ($globalDBdriver == 'mysql') { |
413 | 430 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
414 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
431 | + if ($liveinterval) { |
|
432 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
433 | + } |
|
415 | 434 | $query .= ' ORDER BY date'; |
416 | 435 | } else { |
417 | 436 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
418 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
437 | + if ($liveinterval) { |
|
438 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
439 | + } |
|
419 | 440 | $query .= ' ORDER BY date'; |
420 | 441 | } |
421 | 442 | |
@@ -510,7 +531,9 @@ discard block |
||
510 | 531 | $i++; |
511 | 532 | $j++; |
512 | 533 | if ($j == 30) { |
513 | - if ($globalDebug) echo "."; |
|
534 | + if ($globalDebug) { |
|
535 | + echo "."; |
|
536 | + } |
|
514 | 537 | try { |
515 | 538 | |
516 | 539 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -790,7 +813,9 @@ discard block |
||
790 | 813 | { |
791 | 814 | return false; |
792 | 815 | } |
793 | - } else return ''; |
|
816 | + } else { |
|
817 | + return ''; |
|
818 | + } |
|
794 | 819 | |
795 | 820 | if ($longitude != '') |
796 | 821 | { |
@@ -798,7 +823,9 @@ discard block |
||
798 | 823 | { |
799 | 824 | return false; |
800 | 825 | } |
801 | - } else return ''; |
|
826 | + } else { |
|
827 | + return ''; |
|
828 | + } |
|
802 | 829 | |
803 | 830 | |
804 | 831 | if ($heading != '') |
@@ -807,7 +834,9 @@ discard block |
||
807 | 834 | { |
808 | 835 | return false; |
809 | 836 | } |
810 | - } else $heading = 0; |
|
837 | + } else { |
|
838 | + $heading = 0; |
|
839 | + } |
|
811 | 840 | |
812 | 841 | if ($groundspeed != '') |
813 | 842 | { |
@@ -815,9 +844,13 @@ discard block |
||
815 | 844 | { |
816 | 845 | return false; |
817 | 846 | } |
818 | - } else $groundspeed = 0; |
|
847 | + } else { |
|
848 | + $groundspeed = 0; |
|
849 | + } |
|
819 | 850 | date_default_timezone_set('UTC'); |
820 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
851 | + if ($date == '') { |
|
852 | + $date = date("Y-m-d H:i:s", time()); |
|
853 | + } |
|
821 | 854 | |
822 | 855 | |
823 | 856 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -838,9 +871,15 @@ discard block |
||
838 | 871 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
839 | 872 | |
840 | 873 | |
841 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
842 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
843 | - if ($arrival_date == '') $arrival_date = NULL; |
|
874 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
875 | + $groundspeed = 0; |
|
876 | + } |
|
877 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
878 | + $heading = 0; |
|
879 | + } |
|
880 | + if ($arrival_date == '') { |
|
881 | + $arrival_date = NULL; |
|
882 | + } |
|
844 | 883 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
845 | 884 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
846 | 885 |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | if (isset($filter[0]['source'])) { |
32 | 32 | $filters = array_merge($filters,$filter); |
33 | 33 | } |
34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
34 | + if (is_array($globalFilter)) { |
|
35 | + $filter = array_merge($filter,$globalFilter); |
|
36 | + } |
|
35 | 37 | $filter_query_join = ''; |
36 | 38 | $filter_query_where = ''; |
37 | 39 | foreach($filters as $flt) { |
@@ -70,8 +72,11 @@ discard block |
||
70 | 72 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
71 | 73 | } |
72 | 74 | } |
73 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
74 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
75 | + if ($filter_query_where == '' && $where) { |
|
76 | + $filter_query_where = ' WHERE'; |
|
77 | + } elseif ($filter_query_where != '' && $and) { |
|
78 | + $filter_query_where .= ' AND'; |
|
79 | + } |
|
75 | 80 | if ($filter_query_where != '') { |
76 | 81 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
77 | 82 | } |
@@ -125,25 +130,40 @@ discard block |
||
125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
126 | 131 | } elseif (isset($row['spotter_archive_output_id'])) { |
127 | 132 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
128 | - */} |
|
129 | - elseif (isset($row['marineid'])) { |
|
133 | + */} elseif (isset($row['marineid'])) { |
|
130 | 134 | $temp_array['marineid'] = $row['marineid']; |
131 | 135 | } else { |
132 | 136 | $temp_array['marineid'] = ''; |
133 | 137 | } |
134 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
135 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
138 | + if (isset($row['fammarine_id'])) { |
|
139 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
140 | + } |
|
141 | + if (isset($row['mmsi'])) { |
|
142 | + $temp_array['mmsi'] = $row['mmsi']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
137 | 147 | $temp_array['ident'] = $row['ident']; |
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
148 | + if (isset($row['latitude'])) { |
|
149 | + $temp_array['latitude'] = $row['latitude']; |
|
150 | + } |
|
151 | + if (isset($row['longitude'])) { |
|
152 | + $temp_array['longitude'] = $row['longitude']; |
|
153 | + } |
|
154 | + if (isset($row['format_source'])) { |
|
155 | + $temp_array['format_source'] = $row['format_source']; |
|
156 | + } |
|
141 | 157 | if (isset($row['heading'])) { |
142 | 158 | $temp_array['heading'] = $row['heading']; |
143 | 159 | $heading_direction = $this->parseDirection($row['heading']); |
144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
160 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
161 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
162 | + } |
|
163 | + } |
|
164 | + if (isset($row['ground_speed'])) { |
|
165 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
145 | 166 | } |
146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 167 | |
148 | 168 | if (isset($row['date'])) { |
149 | 169 | $dateArray = $this->parseDateString($row['date']); |
@@ -186,13 +206,21 @@ discard block |
||
186 | 206 | } |
187 | 207 | |
188 | 208 | $fromsource = NULL; |
189 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
190 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
191 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
209 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
210 | + $temp_array['source_name'] = $row['source_name']; |
|
211 | + } |
|
212 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
213 | + $temp_array['over_country'] = $row['over_country']; |
|
214 | + } |
|
215 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
216 | + $temp_array['distance'] = $row['distance']; |
|
217 | + } |
|
192 | 218 | $temp_array['query_number_rows'] = $num_rows; |
193 | 219 | $spotter_array[] = $temp_array; |
194 | 220 | } |
195 | - if ($num_rows == 0) return array(); |
|
221 | + if ($num_rows == 0) { |
|
222 | + return array(); |
|
223 | + } |
|
196 | 224 | $spotter_array[0]['query_number_rows'] = $num_rows; |
197 | 225 | return $spotter_array; |
198 | 226 | } |
@@ -223,8 +251,12 @@ discard block |
||
223 | 251 | { |
224 | 252 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
225 | 253 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
226 | - } else $limit_query = ""; |
|
227 | - } else $limit_query = ""; |
|
254 | + } else { |
|
255 | + $limit_query = ""; |
|
256 | + } |
|
257 | + } else { |
|
258 | + $limit_query = ""; |
|
259 | + } |
|
228 | 260 | |
229 | 261 | if ($sort != "") |
230 | 262 | { |
@@ -252,7 +284,9 @@ discard block |
||
252 | 284 | global $global_query; |
253 | 285 | |
254 | 286 | date_default_timezone_set('UTC'); |
255 | - if ($id == '') return array(); |
|
287 | + if ($id == '') { |
|
288 | + return array(); |
|
289 | + } |
|
256 | 290 | $additional_query = "marine_output.fammarine_id = :id"; |
257 | 291 | $query_values = array(':id' => $id); |
258 | 292 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -395,8 +429,11 @@ discard block |
||
395 | 429 | $query .= " ORDER BY marine_output.source_name ASC"; |
396 | 430 | |
397 | 431 | $sth = $this->db->prepare($query); |
398 | - if (!empty($query_values)) $sth->execute($query_values); |
|
399 | - else $sth->execute(); |
|
432 | + if (!empty($query_values)) { |
|
433 | + $sth->execute($query_values); |
|
434 | + } else { |
|
435 | + $sth->execute(); |
|
436 | + } |
|
400 | 437 | |
401 | 438 | $source_array = array(); |
402 | 439 | $temp_array = array(); |
@@ -451,8 +488,11 @@ discard block |
||
451 | 488 | $sth = $this->db->prepare($query); |
452 | 489 | $sth->execute(array(':mmsi' => $mmsi)); |
453 | 490 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
454 | - if (isset($result[0])) return $result[0]; |
|
455 | - else return array(); |
|
491 | + if (isset($result[0])) { |
|
492 | + return $result[0]; |
|
493 | + } else { |
|
494 | + return array(); |
|
495 | + } |
|
456 | 496 | } |
457 | 497 | |
458 | 498 | /* |
@@ -468,7 +508,9 @@ discard block |
||
468 | 508 | date_default_timezone_set($globalTimezone); |
469 | 509 | $datetime = new DateTime(); |
470 | 510 | $offset = $datetime->format('P'); |
471 | - } else $offset = '+00:00'; |
|
511 | + } else { |
|
512 | + $offset = '+00:00'; |
|
513 | + } |
|
472 | 514 | |
473 | 515 | if ($globalDBdriver == 'mysql') { |
474 | 516 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -663,9 +705,15 @@ discard block |
||
663 | 705 | $latitude = 0; |
664 | 706 | $longitude = 0; |
665 | 707 | } |
666 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
667 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
668 | - if ($arrival_date == '') $arrival_date = NULL; |
|
708 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
709 | + $heading = 0; |
|
710 | + } |
|
711 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
712 | + $groundspeed = 0; |
|
713 | + } |
|
714 | + if ($arrival_date == '') { |
|
715 | + $arrival_date = NULL; |
|
716 | + } |
|
669 | 717 | $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) |
670 | 718 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
671 | 719 | |
@@ -829,12 +877,18 @@ discard block |
||
829 | 877 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
830 | 878 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
831 | 879 | if ($olderthanmonths > 0) { |
832 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
833 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
880 | + if ($globalDBdriver == 'mysql') { |
|
881 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
882 | + } else { |
|
883 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
884 | + } |
|
834 | 885 | } |
835 | 886 | if ($sincedate != '') { |
836 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
837 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
887 | + if ($globalDBdriver == 'mysql') { |
|
888 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
889 | + } else { |
|
890 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
891 | + } |
|
838 | 892 | } |
839 | 893 | $query_values = array(); |
840 | 894 | if ($year != '') { |
@@ -865,7 +919,9 @@ discard block |
||
865 | 919 | } |
866 | 920 | } |
867 | 921 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
868 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
922 | + if ($limit) { |
|
923 | + $query .= " LIMIT 10 OFFSET 0"; |
|
924 | + } |
|
869 | 925 | |
870 | 926 | $sth = $this->db->prepare($query); |
871 | 927 | $sth->execute($query_values); |
@@ -900,7 +956,9 @@ discard block |
||
900 | 956 | date_default_timezone_set($globalTimezone); |
901 | 957 | $datetime = new DateTime(); |
902 | 958 | $offset = $datetime->format('P'); |
903 | - } else $offset = '+00:00'; |
|
959 | + } else { |
|
960 | + $offset = '+00:00'; |
|
961 | + } |
|
904 | 962 | |
905 | 963 | if ($globalDBdriver == 'mysql') { |
906 | 964 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -950,7 +1008,9 @@ discard block |
||
950 | 1008 | date_default_timezone_set($globalTimezone); |
951 | 1009 | $datetime = new DateTime(); |
952 | 1010 | $offset = $datetime->format('P'); |
953 | - } else $offset = '+00:00'; |
|
1011 | + } else { |
|
1012 | + $offset = '+00:00'; |
|
1013 | + } |
|
954 | 1014 | $filter_query = $this->getFilter($filters,true,true); |
955 | 1015 | if ($globalDBdriver == 'mysql') { |
956 | 1016 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -996,7 +1056,9 @@ discard block |
||
996 | 1056 | date_default_timezone_set($globalTimezone); |
997 | 1057 | $datetime = new DateTime(); |
998 | 1058 | $offset = $datetime->format('P'); |
999 | - } else $offset = '+00:00'; |
|
1059 | + } else { |
|
1060 | + $offset = '+00:00'; |
|
1061 | + } |
|
1000 | 1062 | $filter_query = $this->getFilter($filters,true,true); |
1001 | 1063 | if ($globalDBdriver == 'mysql') { |
1002 | 1064 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1044,7 +1106,9 @@ discard block |
||
1044 | 1106 | date_default_timezone_set($globalTimezone); |
1045 | 1107 | $datetime = new DateTime(); |
1046 | 1108 | $offset = $datetime->format('P'); |
1047 | - } else $offset = '+00:00'; |
|
1109 | + } else { |
|
1110 | + $offset = '+00:00'; |
|
1111 | + } |
|
1048 | 1112 | |
1049 | 1113 | if ($globalDBdriver == 'mysql') { |
1050 | 1114 | $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 |
@@ -1093,7 +1157,9 @@ discard block |
||
1093 | 1157 | date_default_timezone_set($globalTimezone); |
1094 | 1158 | $datetime = new DateTime(); |
1095 | 1159 | $offset = $datetime->format('P'); |
1096 | - } else $offset = '+00:00'; |
|
1160 | + } else { |
|
1161 | + $offset = '+00:00'; |
|
1162 | + } |
|
1097 | 1163 | $filter_query = $this->getFilter($filters,true,true); |
1098 | 1164 | if ($globalDBdriver == 'mysql') { |
1099 | 1165 | $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 |
@@ -1142,7 +1208,9 @@ discard block |
||
1142 | 1208 | date_default_timezone_set($globalTimezone); |
1143 | 1209 | $datetime = new DateTime(); |
1144 | 1210 | $offset = $datetime->format('P'); |
1145 | - } else $offset = '+00:00'; |
|
1211 | + } else { |
|
1212 | + $offset = '+00:00'; |
|
1213 | + } |
|
1146 | 1214 | |
1147 | 1215 | $orderby_sql = ''; |
1148 | 1216 | if ($orderby == "hour") |
@@ -1211,7 +1279,9 @@ discard block |
||
1211 | 1279 | date_default_timezone_set($globalTimezone); |
1212 | 1280 | $datetime = new DateTime($date); |
1213 | 1281 | $offset = $datetime->format('P'); |
1214 | - } else $offset = '+00:00'; |
|
1282 | + } else { |
|
1283 | + $offset = '+00:00'; |
|
1284 | + } |
|
1215 | 1285 | |
1216 | 1286 | if ($globalDBdriver == 'mysql') { |
1217 | 1287 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1259,7 +1329,9 @@ discard block |
||
1259 | 1329 | date_default_timezone_set($globalTimezone); |
1260 | 1330 | $datetime = new DateTime(); |
1261 | 1331 | $offset = $datetime->format('P'); |
1262 | - } else $offset = '+00:00'; |
|
1332 | + } else { |
|
1333 | + $offset = '+00:00'; |
|
1334 | + } |
|
1263 | 1335 | |
1264 | 1336 | if ($globalDBdriver == 'mysql') { |
1265 | 1337 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1323,8 +1395,11 @@ discard block |
||
1323 | 1395 | $query_values = array_merge($query_values,array(':month' => $month)); |
1324 | 1396 | } |
1325 | 1397 | } |
1326 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1327 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1398 | + if (empty($query_values)) { |
|
1399 | + $queryi .= $this->getFilter($filters); |
|
1400 | + } else { |
|
1401 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1402 | + } |
|
1328 | 1403 | |
1329 | 1404 | $sth = $this->db->prepare($queryi); |
1330 | 1405 | $sth->execute($query_values); |
@@ -1346,7 +1421,9 @@ discard block |
||
1346 | 1421 | date_default_timezone_set($globalTimezone); |
1347 | 1422 | $datetime = new DateTime(); |
1348 | 1423 | $offset = $datetime->format('P'); |
1349 | - } else $offset = '+00:00'; |
|
1424 | + } else { |
|
1425 | + $offset = '+00:00'; |
|
1426 | + } |
|
1350 | 1427 | |
1351 | 1428 | if ($globalDBdriver == 'mysql') { |
1352 | 1429 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1450,7 +1527,9 @@ discard block |
||
1450 | 1527 | */ |
1451 | 1528 | public function parseDirection($direction = 0) |
1452 | 1529 | { |
1453 | - if ($direction == '') $direction = 0; |
|
1530 | + if ($direction == '') { |
|
1531 | + $direction = 0; |
|
1532 | + } |
|
1454 | 1533 | $direction_array = array(); |
1455 | 1534 | $temp_array = array(); |
1456 | 1535 | |
@@ -1539,7 +1618,9 @@ discard block |
||
1539 | 1618 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1540 | 1619 | |
1541 | 1620 | $Connection = new Connection($this->db); |
1542 | - if (!$Connection->tableExists('countries')) return ''; |
|
1621 | + if (!$Connection->tableExists('countries')) { |
|
1622 | + return ''; |
|
1623 | + } |
|
1543 | 1624 | |
1544 | 1625 | try { |
1545 | 1626 | /* |
@@ -1559,9 +1640,13 @@ discard block |
||
1559 | 1640 | $sth->closeCursor(); |
1560 | 1641 | if (count($row) > 0) { |
1561 | 1642 | return $row; |
1562 | - } else return ''; |
|
1643 | + } else { |
|
1644 | + return ''; |
|
1645 | + } |
|
1563 | 1646 | } catch (PDOException $e) { |
1564 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1647 | + if (isset($globalDebug) && $globalDebug) { |
|
1648 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1649 | + } |
|
1565 | 1650 | return ''; |
1566 | 1651 | } |
1567 | 1652 | |
@@ -1579,7 +1664,9 @@ discard block |
||
1579 | 1664 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1580 | 1665 | |
1581 | 1666 | $Connection = new Connection($this->db); |
1582 | - if (!$Connection->tableExists('countries')) return ''; |
|
1667 | + if (!$Connection->tableExists('countries')) { |
|
1668 | + return ''; |
|
1669 | + } |
|
1583 | 1670 | |
1584 | 1671 | try { |
1585 | 1672 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1591,9 +1678,13 @@ discard block |
||
1591 | 1678 | $sth->closeCursor(); |
1592 | 1679 | if (count($row) > 0) { |
1593 | 1680 | return $row; |
1594 | - } else return ''; |
|
1681 | + } else { |
|
1682 | + return ''; |
|
1683 | + } |
|
1595 | 1684 | } catch (PDOException $e) { |
1596 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1685 | + if (isset($globalDebug) && $globalDebug) { |
|
1686 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1687 | + } |
|
1597 | 1688 | return ''; |
1598 | 1689 | } |
1599 | 1690 | |
@@ -1611,7 +1702,9 @@ discard block |
||
1611 | 1702 | { |
1612 | 1703 | global $globalBitlyAccessToken; |
1613 | 1704 | |
1614 | - if ($globalBitlyAccessToken == '') return $url; |
|
1705 | + if ($globalBitlyAccessToken == '') { |
|
1706 | + return $url; |
|
1707 | + } |
|
1615 | 1708 | |
1616 | 1709 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1617 | 1710 |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | public function checkAll() { |
47 | 47 | global $globalDebug; |
48 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
48 | + if ($globalDebug) { |
|
49 | + echo "Update last seen tracked data...\n"; |
|
50 | + } |
|
49 | 51 | foreach ($this->all_tracked as $key => $flight) { |
50 | 52 | if (isset($this->all_tracked[$key]['id'])) { |
51 | 53 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -58,12 +60,16 @@ discard block |
||
58 | 60 | public function del() { |
59 | 61 | global $globalDebug; |
60 | 62 | // Delete old infos |
61 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
63 | + if ($globalDebug) { |
|
64 | + echo 'Delete old values and update latest data...'."\n"; |
|
65 | + } |
|
62 | 66 | foreach ($this->all_tracked as $key => $flight) { |
63 | 67 | if (isset($flight['lastupdate'])) { |
64 | 68 | if ($flight['lastupdate'] < (time()-3000)) { |
65 | 69 | if (isset($this->all_tracked[$key]['id'])) { |
66 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
70 | + if ($globalDebug) { |
|
71 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
72 | + } |
|
67 | 73 | /* |
68 | 74 | $MarineLive = new MarineLive(); |
69 | 75 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -73,7 +79,9 @@ discard block |
||
73 | 79 | $Marine = new Marine($this->db); |
74 | 80 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
75 | 81 | $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']); |
76 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
82 | + if ($globalDebug && $result != 'success') { |
|
83 | + echo '!!! ERROR : '.$result."\n"; |
|
84 | + } |
|
77 | 85 | } |
78 | 86 | // Put in archive |
79 | 87 | // $Marine->db = null; |
@@ -86,7 +94,9 @@ discard block |
||
86 | 94 | |
87 | 95 | public function add($line) { |
88 | 96 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
89 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
97 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
98 | + $globalCoordMinChange = '0.02'; |
|
99 | + } |
|
90 | 100 | date_default_timezone_set('UTC'); |
91 | 101 | $dataFound = false; |
92 | 102 | $send = false; |
@@ -111,8 +121,11 @@ discard block |
||
111 | 121 | |
112 | 122 | $Common = new Common(); |
113 | 123 | $AIS = new AIS(); |
114 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
115 | - else $id = trim($line['id']); |
|
124 | + if (!isset($line['id'])) { |
|
125 | + $id = trim($line['mmsi']); |
|
126 | + } else { |
|
127 | + $id = trim($line['id']); |
|
128 | + } |
|
116 | 129 | |
117 | 130 | if (!isset($this->all_tracked[$id])) { |
118 | 131 | $this->all_tracked[$id] = array(); |
@@ -120,10 +133,16 @@ discard block |
||
120 | 133 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '')); |
121 | 134 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
122 | 135 | if (!isset($line['id'])) { |
123 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
136 | + if (!isset($globalDaemon)) { |
|
137 | + $globalDaemon = TRUE; |
|
138 | + } |
|
124 | 139 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
125 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
126 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | + } else { |
|
141 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
142 | + } |
|
143 | + if ($globalAllTracked !== FALSE) { |
|
144 | + $dataFound = true; |
|
145 | + } |
|
127 | 146 | } |
128 | 147 | |
129 | 148 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -166,11 +185,17 @@ discard block |
||
166 | 185 | $Marine = new Marine($this->db); |
167 | 186 | $fromsource = NULL; |
168 | 187 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
169 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
188 | + if ($globalDebug && $result != 'success') { |
|
189 | + echo '!!! ERROR : '.$result."\n"; |
|
190 | + } |
|
170 | 191 | $Marine->db = null; |
171 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) { |
|
193 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
194 | + } |
|
195 | + } |
|
196 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
172 | 198 | } |
173 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
174 | 199 | } |
175 | 200 | |
176 | 201 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -181,14 +206,21 @@ discard block |
||
181 | 206 | if ($distance > 1000 && $distance < 10000) { |
182 | 207 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
183 | 208 | $speed = $speed*3.6; |
184 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
185 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
209 | + if ($speed < 1000) { |
|
210 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
211 | + } |
|
212 | + if ($globalDebug) { |
|
213 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
214 | + } |
|
186 | 215 | } |
187 | 216 | } |
188 | 217 | |
189 | 218 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
190 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
191 | - else unset($timediff); |
|
219 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
220 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
221 | + } else { |
|
222 | + unset($timediff); |
|
223 | + } |
|
192 | 224 | 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')))) { |
193 | 225 | 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'])) { |
194 | 226 | 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'])) { |
@@ -196,20 +228,30 @@ discard block |
||
196 | 228 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
197 | 229 | $this->all_tracked[$id]['putinarchive'] = true; |
198 | 230 | |
199 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
233 | + } |
|
200 | 234 | $timeelapsed = microtime(true); |
201 | 235 | $Marine = new Marine($this->db); |
202 | 236 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
203 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
237 | + if (!empty($all_country)) { |
|
238 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
239 | + } |
|
204 | 240 | $Marine->db = null; |
205 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
241 | + if ($globalDebugTimeElapsed) { |
|
242 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
243 | + } |
|
206 | 244 | $this->tmd = 0; |
207 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
247 | + } |
|
208 | 248 | } |
209 | 249 | } |
210 | 250 | |
211 | 251 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
212 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
252 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
253 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
254 | + } |
|
213 | 255 | 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') { |
214 | 256 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
215 | 257 | $dataFound = true; |
@@ -218,8 +260,12 @@ discard block |
||
218 | 260 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
219 | 261 | } |
220 | 262 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
221 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
222 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
263 | + if ($line['longitude'] > 180) { |
|
264 | + $line['longitude'] = $line['longitude'] - 360; |
|
265 | + } |
|
266 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
267 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
268 | + } |
|
223 | 269 | 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') { |
224 | 270 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
225 | 271 | $dataFound = true; |
@@ -237,7 +283,9 @@ discard block |
||
237 | 283 | } |
238 | 284 | } |
239 | 285 | if (isset($line['last_update']) && $line['last_update'] != '') { |
240 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
286 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
287 | + $dataFound = true; |
|
288 | + } |
|
241 | 289 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
242 | 290 | } |
243 | 291 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -255,15 +303,21 @@ discard block |
||
255 | 303 | } |
256 | 304 | |
257 | 305 | if (isset($line['heading']) && $line['heading'] != '') { |
258 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
306 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
307 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
308 | + } |
|
259 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
260 | 310 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
261 | 311 | //$dataFound = true; |
262 | 312 | } 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']) { |
263 | 313 | $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']); |
264 | 314 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
265 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
315 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
316 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
317 | + } |
|
318 | + if ($globalDebug) { |
|
319 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
320 | + } |
|
267 | 321 | } |
268 | 322 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
269 | 323 | |
@@ -271,8 +325,11 @@ discard block |
||
271 | 325 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
272 | 326 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
273 | 327 | } else { |
274 | - 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"; |
|
275 | - 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"; |
|
328 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
329 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
330 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
331 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
332 | + } |
|
276 | 333 | return ''; |
277 | 334 | } |
278 | 335 | } else { |
@@ -286,22 +343,35 @@ discard block |
||
286 | 343 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
287 | 344 | 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'])) { |
288 | 345 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
289 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
346 | + if ($globalDebug) { |
|
347 | + echo "Check if aircraft is already in DB..."; |
|
348 | + } |
|
290 | 349 | $timeelapsed = microtime(true); |
291 | 350 | $MarineLive = new MarineLive($this->db); |
292 | 351 | if (isset($line['id'])) { |
293 | 352 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
294 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
353 | + if ($globalDebugTimeElapsed) { |
|
354 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
355 | + } |
|
295 | 356 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
296 | 357 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
297 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
358 | + if ($globalDebugTimeElapsed) { |
|
359 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
360 | + } |
|
298 | 361 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
299 | 362 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
300 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | - } else $recent_ident = ''; |
|
363 | + if ($globalDebugTimeElapsed) { |
|
364 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
365 | + } |
|
366 | + } else { |
|
367 | + $recent_ident = ''; |
|
368 | + } |
|
302 | 369 | $MarineLive->db=null; |
303 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
304 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
370 | + if ($globalDebug && $recent_ident == '') { |
|
371 | + echo " Not in DB.\n"; |
|
372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
373 | + echo " Already in DB.\n"; |
|
374 | + } |
|
305 | 375 | } else { |
306 | 376 | $recent_ident = ''; |
307 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -309,16 +379,24 @@ discard block |
||
309 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
310 | 380 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
311 | 381 | { |
312 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
382 | + if ($globalDebug) { |
|
383 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
384 | + } |
|
313 | 385 | //adds the spotter data for the archive |
314 | 386 | $highlight = ''; |
315 | - 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'))); |
|
387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
389 | + } |
|
316 | 390 | $timeelapsed = microtime(true); |
317 | 391 | $Marine = new Marine($this->db); |
318 | 392 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
319 | 393 | $Marine->db = null; |
320 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
321 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
394 | + if ($globalDebug && isset($result)) { |
|
395 | + echo $result."\n"; |
|
396 | + } |
|
397 | + if ($globalDebugTimeElapsed) { |
|
398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + } |
|
322 | 400 | |
323 | 401 | /* |
324 | 402 | // Add source stat in DB |
@@ -352,12 +430,16 @@ discard block |
||
352 | 430 | $this->all_tracked[$id]['addedMarine'] = 1; |
353 | 431 | //print_r($this->all_tracked[$id]); |
354 | 432 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
355 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
433 | + if ($globalDebug) { |
|
434 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
435 | + } |
|
356 | 436 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
357 | 437 | $MarineLive = new MarineLive($this->db); |
358 | 438 | $MarineLive->deleteLiveMarineData(); |
359 | 439 | $MarineLive->db=null; |
360 | - if ($globalDebug) echo " Done\n"; |
|
440 | + if ($globalDebug) { |
|
441 | + echo " Done\n"; |
|
442 | + } |
|
361 | 443 | $this->last_delete = time(); |
362 | 444 | } |
363 | 445 | } elseif ($recent_ident != '') { |
@@ -380,13 +462,17 @@ discard block |
||
380 | 462 | |
381 | 463 | if (!$ignoreImport) { |
382 | 464 | 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'])) { |
383 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
465 | + if ($globalDebug) { |
|
466 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
467 | + } |
|
384 | 468 | $timeelapsed = microtime(true); |
385 | 469 | $MarineLive = new MarineLive($this->db); |
386 | 470 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
387 | 471 | $MarineLive->db = null; |
388 | 472 | $this->all_tracked[$id]['putinarchive'] = false; |
389 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
473 | + if ($globalDebugTimeElapsed) { |
|
474 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + } |
|
390 | 476 | |
391 | 477 | // Put statistics in $this->stats variable |
392 | 478 | /* |
@@ -443,19 +529,29 @@ discard block |
||
443 | 529 | */ |
444 | 530 | |
445 | 531 | $this->all_tracked[$id]['lastupdate'] = time(); |
446 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
447 | - if ($globalDebug) echo $result."\n"; |
|
448 | - } 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"; |
|
532 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
533 | + $send = true; |
|
534 | + } |
|
535 | + if ($globalDebug) { |
|
536 | + echo $result."\n"; |
|
537 | + } |
|
538 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
539 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
540 | + } |
|
449 | 541 | //$this->del(); |
450 | 542 | |
451 | 543 | |
452 | 544 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
453 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
545 | + if ($globalDebug) { |
|
546 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
547 | + } |
|
454 | 548 | $MarineLive = new MarineLive($this->db); |
455 | 549 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
456 | 550 | $MarineLive->db = null; |
457 | 551 | //MarineLive->deleteLiveMarineData(); |
458 | - if ($globalDebug) echo " Done\n"; |
|
552 | + if ($globalDebug) { |
|
553 | + echo " Done\n"; |
|
554 | + } |
|
459 | 555 | $this->last_delete_hourly = time(); |
460 | 556 | } |
461 | 557 | |
@@ -463,7 +559,9 @@ discard block |
||
463 | 559 | //$ignoreImport = false; |
464 | 560 | } |
465 | 561 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
466 | - if ($send) return $this->all_tracked[$id]; |
|
562 | + if ($send) { |
|
563 | + return $this->all_tracked[$id]; |
|
564 | + } |
|
467 | 565 | } |
468 | 566 | } |
469 | 567 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | $temp += 1; |
36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else { |
|
39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
40 | + } |
|
39 | 41 | return $flat; // float |
40 | 42 | } |
41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | $temp += 1; |
48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
49 | 51 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
52 | + } else { |
|
53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
54 | + } |
|
51 | 55 | return $flon; |
52 | 56 | } |
53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
70 | 74 | */ |
71 | 75 | private function asciidec_2_8bit($ascii) { |
72 | 76 | //only process in the following range: 48-87, 96-119 |
73 | - if ($ascii < 48) { } |
|
74 | - else { |
|
75 | - if($ascii>119) { } |
|
76 | - else { |
|
77 | + if ($ascii < 48) { } else { |
|
78 | + if($ascii>119) { } else { |
|
77 | 79 | if ($ascii>87 && $ascii<96) ; |
78 | 80 | else { |
79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
180 | + if ($ro->heading == 511) { |
|
181 | + $ro->heading = ''; |
|
182 | + } |
|
179 | 183 | $ro->cls = 2; // class B |
180 | 184 | } else if ($ro->id == 19) { |
181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
186 | 190 | $ro->cls = 2; // class B |
187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
192 | + if ($ro->heading == 511) { |
|
193 | + $ro->heading = ''; |
|
194 | + } |
|
189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
216 | 222 | $ro->cls = 2; // class B |
217 | 223 | } else if ($ro->id == 27) { |
218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
225 | + if ($ro->cog == 511) { |
|
226 | + $ro->cog = 0.0; |
|
227 | + } |
|
220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
229 | + if ($ro->sog == 63) { |
|
230 | + $ro->sog = 0.0; |
|
231 | + } |
|
222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
267 | 277 | } |
268 | 278 | |
269 | 279 | public function getShipType($code) { |
270 | - if ($code == 0) return 'Not available (default)'; |
|
271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
282 | - elseif ($code == 30) return 'Fishing'; |
|
283 | - elseif ($code == 31) return 'Towing'; |
|
284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
286 | - elseif ($code == 34) return 'Diving ops'; |
|
287 | - elseif ($code == 35) return 'Military ops'; |
|
288 | - elseif ($code == 36) return 'Sailing'; |
|
289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
290 | - elseif ($code == 38) return 'Reserved'; |
|
291 | - elseif ($code == 39) return 'Reserved'; |
|
292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
304 | - elseif ($code == 52) return 'Tug'; |
|
305 | - elseif ($code == 53) return 'Port Tender'; |
|
306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
310 | - elseif ($code == 58) return 'Medical Transport'; |
|
311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
280 | + if ($code == 0) { |
|
281 | + return 'Not available (default)'; |
|
282 | + } elseif ($code >= 1 && $code <= 19) { |
|
283 | + return 'Reserved for future use'; |
|
284 | + } elseif ($code == 20) { |
|
285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
286 | + } elseif ($code == 21) { |
|
287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
288 | + } elseif ($code == 22) { |
|
289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
290 | + } elseif ($code == 23) { |
|
291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
292 | + } elseif ($code == 24) { |
|
293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
294 | + } elseif ($code == 25) { |
|
295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
296 | + } elseif ($code == 26) { |
|
297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
298 | + } elseif ($code == 27) { |
|
299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
300 | + } elseif ($code == 28) { |
|
301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
302 | + } elseif ($code == 29) { |
|
303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
304 | + } elseif ($code == 30) { |
|
305 | + return 'Fishing'; |
|
306 | + } elseif ($code == 31) { |
|
307 | + return 'Towing'; |
|
308 | + } elseif ($code == 32) { |
|
309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
310 | + } elseif ($code == 33) { |
|
311 | + return 'Dredging or underwater ops'; |
|
312 | + } elseif ($code == 34) { |
|
313 | + return 'Diving ops'; |
|
314 | + } elseif ($code == 35) { |
|
315 | + return 'Military ops'; |
|
316 | + } elseif ($code == 36) { |
|
317 | + return 'Sailing'; |
|
318 | + } elseif ($code == 37) { |
|
319 | + return 'Pleasure Craft'; |
|
320 | + } elseif ($code == 38) { |
|
321 | + return 'Reserved'; |
|
322 | + } elseif ($code == 39) { |
|
323 | + return 'Reserved'; |
|
324 | + } elseif ($code == 40) { |
|
325 | + return 'High speed craft (HSC), all ships of this type'; |
|
326 | + } elseif ($code == 41) { |
|
327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
328 | + } elseif ($code == 42) { |
|
329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
330 | + } elseif ($code == 43) { |
|
331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
332 | + } elseif ($code == 44) { |
|
333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
334 | + } elseif ($code == 45) { |
|
335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
336 | + } elseif ($code == 46) { |
|
337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
338 | + } elseif ($code == 47) { |
|
339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
340 | + } elseif ($code == 48) { |
|
341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
342 | + } elseif ($code == 49) { |
|
343 | + return 'High speed craft (HSC), No additional information'; |
|
344 | + } elseif ($code == 50) { |
|
345 | + return 'Pilot Vessel'; |
|
346 | + } elseif ($code == 51) { |
|
347 | + return 'Search and Rescue vessel'; |
|
348 | + } elseif ($code == 52) { |
|
349 | + return 'Tug'; |
|
350 | + } elseif ($code == 53) { |
|
351 | + return 'Port Tender'; |
|
352 | + } elseif ($code == 54) { |
|
353 | + return 'Anti-pollution equipment'; |
|
354 | + } elseif ($code == 55) { |
|
355 | + return 'Law Enforcement'; |
|
356 | + } elseif ($code == 56) { |
|
357 | + return 'Spare - Local Vessel'; |
|
358 | + } elseif ($code == 57) { |
|
359 | + return 'Spare - Local Vessel'; |
|
360 | + } elseif ($code == 58) { |
|
361 | + return 'Medical Transport'; |
|
362 | + } elseif ($code == 59) { |
|
363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
364 | + } elseif ($code == 60) { |
|
365 | + return 'Passenger, all ships of this type'; |
|
366 | + } elseif ($code == 61) { |
|
367 | + return 'Passenger, Hazardous category A'; |
|
368 | + } elseif ($code == 62) { |
|
369 | + return 'Passenger, Hazardous category B'; |
|
370 | + } elseif ($code == 63) { |
|
371 | + return 'Passenger, Hazardous category C'; |
|
372 | + } elseif ($code == 64) { |
|
373 | + return 'Passenger, Hazardous category D'; |
|
374 | + } elseif ($code == 65) { |
|
375 | + return 'Passenger, Reserved for future use'; |
|
376 | + } elseif ($code == 66) { |
|
377 | + return 'Passenger, Reserved for future use'; |
|
378 | + } elseif ($code == 67) { |
|
379 | + return 'Passenger, Reserved for future use'; |
|
380 | + } elseif ($code == 68) { |
|
381 | + return 'Passenger, Reserved for future use'; |
|
382 | + } elseif ($code == 69) { |
|
383 | + return 'Passenger, No additional information'; |
|
384 | + } elseif ($code == 70) { |
|
385 | + return 'Cargo, all ships of this type'; |
|
386 | + } elseif ($code == 71) { |
|
387 | + return 'Cargo, Hazardous category A'; |
|
388 | + } elseif ($code == 72) { |
|
389 | + return 'Cargo, Hazardous category B'; |
|
390 | + } elseif ($code == 73) { |
|
391 | + return 'Cargo, Hazardous category C'; |
|
392 | + } elseif ($code == 74) { |
|
393 | + return 'Cargo, Hazardous category D'; |
|
394 | + } elseif ($code == 75) { |
|
395 | + return 'Cargo, Reserved for future use'; |
|
396 | + } elseif ($code == 76) { |
|
397 | + return 'Cargo, Reserved for future use'; |
|
398 | + } elseif ($code == 77) { |
|
399 | + return 'Cargo, Reserved for future use'; |
|
400 | + } elseif ($code == 78) { |
|
401 | + return 'Cargo, Reserved for future use'; |
|
402 | + } elseif ($code == 79) { |
|
403 | + return 'Cargo, No additional information'; |
|
404 | + } elseif ($code == 80) { |
|
405 | + return 'Tanker, all ships of this type'; |
|
406 | + } elseif ($code == 81) { |
|
407 | + return 'Tanker, Hazardous category A'; |
|
408 | + } elseif ($code == 82) { |
|
409 | + return 'Tanker, Hazardous category B'; |
|
410 | + } elseif ($code == 83) { |
|
411 | + return 'Tanker, Hazardous category C'; |
|
412 | + } elseif ($code == 84) { |
|
413 | + return 'Tanker, Hazardous category D'; |
|
414 | + } elseif ($code == 85) { |
|
415 | + return 'Tanker, Reserved for future use'; |
|
416 | + } elseif ($code == 86) { |
|
417 | + return 'Tanker, Reserved for future use'; |
|
418 | + } elseif ($code == 87) { |
|
419 | + return 'Tanker, Reserved for future use'; |
|
420 | + } elseif ($code == 88) { |
|
421 | + return 'Tanker, Reserved for future use'; |
|
422 | + } elseif ($code == 89) { |
|
423 | + return 'Tanker, No additional information'; |
|
424 | + } elseif ($code == 90) { |
|
425 | + return 'Other Type, all ships of this type'; |
|
426 | + } elseif ($code == 91) { |
|
427 | + return 'Other Type, Hazardous category A'; |
|
428 | + } elseif ($code == 92) { |
|
429 | + return 'Other Type, Hazardous category B'; |
|
430 | + } elseif ($code == 93) { |
|
431 | + return 'Other Type, Hazardous category C'; |
|
432 | + } elseif ($code == 94) { |
|
433 | + return 'Other Type, Hazardous category D'; |
|
434 | + } elseif ($code == 95) { |
|
435 | + return 'Other Type, Reserved for future use'; |
|
436 | + } elseif ($code == 96) { |
|
437 | + return 'Other Type, Reserved for future use'; |
|
438 | + } elseif ($code == 97) { |
|
439 | + return 'Other Type, Reserved for future use'; |
|
440 | + } elseif ($code == 98) { |
|
441 | + return 'Other Type, Reserved for future use'; |
|
442 | + } elseif ($code == 99) { |
|
443 | + return 'Other Type, no additional information'; |
|
444 | + } |
|
352 | 445 | } |
353 | 446 | |
354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,19 +479,34 @@ discard block |
||
386 | 479 | // assume 1st ! is valid |
387 | 480 | // find * ensure that it is at correct position |
388 | 481 | $end = strrpos ( $rawdata , '*' ); |
389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
482 | + if ($end === FALSE) { |
|
483 | + return -1; |
|
484 | + } |
|
485 | + // check for NULLS!!! |
|
390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
487 | + if ( strlen($cs) != 2 ) { |
|
488 | + return -1; |
|
489 | + } |
|
490 | + // correct cs length |
|
392 | 491 | $dcs = (int)hexdec( $cs ); |
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
494 | + } |
|
495 | + // perform XOR for NMEA checksum |
|
394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
395 | 497 | $pcs = explode(',', $rawdata); |
396 | 498 | // !AI??? identifier |
397 | 499 | $num_seq = (int)$pcs[1]; // number of sequences |
398 | 500 | $seq = (int)$pcs[2]; // get sequence |
399 | 501 | // get msg sequence id |
400 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
502 | + if ($pcs[3] == '') { |
|
503 | + $msg_sid = -1; |
|
504 | + } |
|
505 | + // non-multipart message, set to -1 |
|
506 | + else { |
|
507 | + $msg_sid = (int)$pcs[3]; |
|
508 | + } |
|
509 | + // multipart message |
|
402 | 510 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 511 | // message sequence checking |
404 | 512 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -459,10 +567,18 @@ discard block |
||
459 | 567 | //DEBUG echo "[$start $end $tst]\n"; |
460 | 568 | $result = $this->process_ais_raw( $tst, "" ); |
461 | 569 | $last_pos = $end + 1; |
462 | - } else break; |
|
570 | + } else { |
|
571 | + break; |
|
572 | + } |
|
573 | + } |
|
574 | + if ($last_pos > 0) { |
|
575 | + $cbuf = substr($cbuf, $last_pos); |
|
463 | 576 | } |
464 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
465 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
577 | + // move... |
|
578 | + if (strlen($cbuf) > 1024) { |
|
579 | + $cbuf = ""; |
|
580 | + } |
|
581 | + // prevent overflow simple mode... |
|
466 | 582 | return $result; |
467 | 583 | } |
468 | 584 | |
@@ -482,7 +598,9 @@ discard block |
||
482 | 598 | if ($lat<0.0) { |
483 | 599 | $lat = -$lat; |
484 | 600 | $neg=true; |
485 | - } else $neg=false; |
|
601 | + } else { |
|
602 | + $neg=false; |
|
603 | + } |
|
486 | 604 | $latd = 0x00000000; |
487 | 605 | $latd = intval ($lat * 600000.0); |
488 | 606 | if ($neg==true) { |
@@ -498,7 +616,9 @@ discard block |
||
498 | 616 | if ($lon<0.0) { |
499 | 617 | $lon = -$lon; |
500 | 618 | $neg=true; |
501 | - } else $neg=false; |
|
619 | + } else { |
|
620 | + $neg=false; |
|
621 | + } |
|
502 | 622 | $lond = 0x00000000; |
503 | 623 | $lond = intval ($lon * 600000.0); |
504 | 624 | if ($neg==true) { |
@@ -511,9 +631,14 @@ discard block |
||
511 | 631 | |
512 | 632 | private function char2bin($name, $max_len) { |
513 | 633 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
516 | - else $pad = ''; |
|
634 | + if ($len > $max_len) { |
|
635 | + $name = substr($name,0,$max_len); |
|
636 | + } |
|
637 | + if ($len < $max_len) { |
|
638 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
639 | + } else { |
|
640 | + $pad = ''; |
|
641 | + } |
|
517 | 642 | $rv = ''; |
518 | 643 | $ais_chars = array( |
519 | 644 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -526,9 +651,12 @@ discard block |
||
526 | 651 | ); |
527 | 652 | // " |
528 | 653 | $_a = str_split($name); |
529 | - if ($_a) foreach ($_a as $_1) { |
|
654 | + if ($_a) { |
|
655 | + foreach ($_a as $_1) { |
|
530 | 656 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | - else $dec = 0; |
|
657 | + } else { |
|
658 | + $dec = 0; |
|
659 | + } |
|
532 | 660 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
533 | 661 | $rv .= $bin; |
534 | 662 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -540,7 +668,9 @@ discard block |
||
540 | 668 | $len_bit = strlen($_enc); |
541 | 669 | $rem6 = $len_bit % 6; |
542 | 670 | $pad6_len = 0; |
543 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
671 | + if ($rem6) { |
|
672 | + $pad6_len = 6 - $rem6; |
|
673 | + } |
|
544 | 674 | //echo $pad6_len.'<br>'; |
545 | 675 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | 676 | $len_enc = strlen($_enc) / 6; |
@@ -549,8 +679,11 @@ discard block |
||
549 | 679 | for ($i=0; $i<$len_enc; $i++) { |
550 | 680 | $offset = $i * 6; |
551 | 681 | $dec = bindec(substr($_enc,$offset,6)); |
552 | - if ($dec < 40) $dec += 48; |
|
553 | - else $dec += 56; |
|
682 | + if ($dec < 40) { |
|
683 | + $dec += 48; |
|
684 | + } else { |
|
685 | + $dec += 56; |
|
686 | + } |
|
554 | 687 | //echo chr($dec)." $dec<br/>"; |
555 | 688 | $itu .= chr($dec); |
556 | 689 | } |
@@ -563,25 +696,41 @@ discard block |
||
563 | 696 | } |
564 | 697 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
565 | 698 | $lsb = $chksum & 0x0F; |
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
567 | - else $lsbc = '0'; |
|
699 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
700 | + $lsbc = $hex_arr[$lsb]; |
|
701 | + } else { |
|
702 | + $lsbc = '0'; |
|
703 | + } |
|
568 | 704 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
570 | - else $msbc = '0'; |
|
705 | + if ($msb >=0 && $msb <= 15 ) { |
|
706 | + $msbc = $hex_arr[$msb]; |
|
707 | + } else { |
|
708 | + $msbc = '0'; |
|
709 | + } |
|
571 | 710 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 711 | return $itu; |
573 | 712 | } |
574 | 713 | |
575 | 714 | public function parse($buffer) { |
576 | 715 | $data = $this->process_ais_buf($buffer); |
577 | - if (!is_object($data)) return array(); |
|
578 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
579 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
716 | + if (!is_object($data)) { |
|
717 | + return array(); |
|
718 | + } |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
580 | 725 | $result['ident'] = trim($data->name); |
581 | 726 | $result['timestamp'] = $data->ts; |
582 | 727 | $result['mmsi'] = $data->mmsi; |
583 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
584 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
728 | + if ($data->sog != -1.0) { |
|
729 | + $result['speed'] = $data->sog; |
|
730 | + } |
|
731 | + if ($data->cog != 0) { |
|
732 | + $result['heading'] = $data->cog; |
|
733 | + } |
|
585 | 734 | /* |
586 | 735 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
587 | 736 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -591,15 +740,25 @@ discard block |
||
591 | 740 | |
592 | 741 | public function mmsitype($mmsi) { |
593 | 742 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
602 | - else return 'Ship'; |
|
743 | + if (substr($mmsi,0,3) == '974') { |
|
744 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
745 | + } elseif (substr($mmsi,0,3) == '972') { |
|
746 | + return 'MOB (Man Overboard) device'; |
|
747 | + } elseif (substr($mmsi,0,3) == '970') { |
|
748 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
749 | + } elseif (substr($mmsi,0,3) == '111') { |
|
750 | + return 'SAR (Search and Rescue) aircraft'; |
|
751 | + } elseif (substr($mmsi,0,2) == '98') { |
|
752 | + return 'Auxiliary craft associated with a parent ship'; |
|
753 | + } elseif (substr($mmsi,0,2) == '99') { |
|
754 | + return 'Aids to Navigation'; |
|
755 | + } elseif (substr($mmsi,0,2) == '00') { |
|
756 | + return 'Coastal stations'; |
|
757 | + } elseif (substr($mmsi,0,1) == '0') { |
|
758 | + return 'Group of ships'; |
|
759 | + } else { |
|
760 | + return 'Ship'; |
|
761 | + } |
|
603 | 762 | } |
604 | 763 | |
605 | 764 | |
@@ -616,25 +775,48 @@ discard block |
||
616 | 775 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 776 | return array(); |
618 | 777 | } |
619 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
620 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
778 | + if ($data->lon != 0) { |
|
779 | + $result['longitude'] = $data->lon; |
|
780 | + } |
|
781 | + if ($data->lat != 0) { |
|
782 | + $result['latitude'] = $data->lat; |
|
783 | + } |
|
621 | 784 | $result['ident'] = trim(str_replace('@','',$data->name)); |
622 | 785 | $result['timestamp'] = $data->ts; |
623 | 786 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
787 | + if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') { |
|
788 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
789 | + } |
|
625 | 790 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
627 | - if ($data->heading != '') $result['heading'] = $data->heading; |
|
628 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
629 | - if ($data->status != '') $result['status'] = $data->status; |
|
630 | - if ($data->type != '') $result['type'] = $data->type; |
|
631 | - if ($data->typeid != '') $result['typeid'] = $data->typeid; |
|
632 | - if ($data->imo != '') $result['imo'] = $data->imo; |
|
633 | - if ($data->callsign != '') $result['callsign'] = $data->callsign; |
|
791 | + if ($data->sog != -1.0) { |
|
792 | + $result['speed'] = $data->sog; |
|
793 | + } |
|
794 | + if ($data->heading != '') { |
|
795 | + $result['heading'] = $data->heading; |
|
796 | + } elseif ($data->cog != 0) { |
|
797 | + $result['heading'] = $data->cog; |
|
798 | + } |
|
799 | + if ($data->status != '') { |
|
800 | + $result['status'] = $data->status; |
|
801 | + } |
|
802 | + if ($data->type != '') { |
|
803 | + $result['type'] = $data->type; |
|
804 | + } |
|
805 | + if ($data->typeid != '') { |
|
806 | + $result['typeid'] = $data->typeid; |
|
807 | + } |
|
808 | + if ($data->imo != '') { |
|
809 | + $result['imo'] = $data->imo; |
|
810 | + } |
|
811 | + if ($data->callsign != '') { |
|
812 | + $result['callsign'] = $data->callsign; |
|
813 | + } |
|
634 | 814 | if ($data->eta_month != '' && $data->eta_day != '' && $data->eta_hour != '' && $data->eta_minute != '') { |
635 | 815 | $result['eta_ts'] = strtotime(date('Y').'-'.$data->eta_month.'-'.$data->eta_day.' '.$data->eta_hour.':'.$data->eta_minute.':00'); |
636 | 816 | } |
637 | - if ($data->destination != '') $result['destination'] = $data->destination; |
|
817 | + if ($data->destination != '') { |
|
818 | + $result['destination'] = $data->destination; |
|
819 | + } |
|
638 | 820 | $result['all'] = (array) $data; |
639 | 821 | /* |
640 | 822 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |