@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection. (Tracker)'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 76 | } |
73 | 77 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
78 | + if ($filter_query_where == '' && $where) { |
|
79 | + $filter_query_where = ' WHERE'; |
|
80 | + } elseif ($filter_query_where != '' && $and) { |
|
81 | + $filter_query_where .= ' AND'; |
|
82 | + } |
|
76 | 83 | if ($filter_query_where != '') { |
77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
127 | 134 | } elseif (isset($row['spotter_archive_output_id'])) { |
128 | 135 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
129 | - */} |
|
130 | - elseif (isset($row['trackerid'])) { |
|
136 | + */} elseif (isset($row['trackerid'])) { |
|
131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
132 | 138 | } else { |
133 | 139 | $temp_array['trackerid'] = ''; |
134 | 140 | } |
135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
141 | + if (isset($row['famtrackid'])) { |
|
142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
147 | + if (isset($row['comment'])) { |
|
148 | + $temp_array['comment'] = $row['comment']; |
|
149 | + } |
|
138 | 150 | $temp_array['ident'] = $row['ident']; |
139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
160 | + if (isset($row['altitude'])) { |
|
161 | + $temp_array['altitude'] = $row['altitude']; |
|
162 | + } |
|
143 | 163 | if (isset($row['heading'])) { |
144 | 164 | $temp_array['heading'] = $row['heading']; |
145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 172 | } |
148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
149 | 173 | |
150 | 174 | if (isset($row['date'])) { |
151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
188 | 212 | } |
189 | 213 | |
190 | 214 | $fromsource = NULL; |
191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
216 | + $temp_array['source_name'] = $row['source_name']; |
|
217 | + } |
|
218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
219 | + $temp_array['over_country'] = $row['over_country']; |
|
220 | + } |
|
221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
222 | + $temp_array['distance'] = $row['distance']; |
|
223 | + } |
|
194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
195 | 225 | $spotter_array[] = $temp_array; |
196 | 226 | } |
197 | - if ($num_rows == 0) return array(); |
|
227 | + if ($num_rows == 0) { |
|
228 | + return array(); |
|
229 | + } |
|
198 | 230 | $spotter_array[0]['query_number_rows'] = $num_rows; |
199 | 231 | return $spotter_array; |
200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
225 | 257 | { |
226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
228 | - } else $limit_query = ""; |
|
229 | - } else $limit_query = ""; |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
230 | 266 | |
231 | 267 | if ($sort != "") |
232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
254 | 290 | global $global_query; |
255 | 291 | |
256 | 292 | date_default_timezone_set('UTC'); |
257 | - if ($id == '') return array(); |
|
293 | + if ($id == '') { |
|
294 | + return array(); |
|
295 | + } |
|
258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 297 | $query_values = array(':id' => $id); |
260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
398 | 436 | |
399 | 437 | $sth = $this->db->prepare($query); |
400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
401 | - else $sth->execute(); |
|
438 | + if (!empty($query_values)) { |
|
439 | + $sth->execute($query_values); |
|
440 | + } else { |
|
441 | + $sth->execute(); |
|
442 | + } |
|
402 | 443 | |
403 | 444 | $source_array = array(); |
404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
453 | 494 | date_default_timezone_set($globalTimezone); |
454 | 495 | $datetime = new DateTime(); |
455 | 496 | $offset = $datetime->format('P'); |
456 | - } else $offset = '+00:00'; |
|
497 | + } else { |
|
498 | + $offset = '+00:00'; |
|
499 | + } |
|
457 | 500 | |
458 | 501 | if ($globalDBdriver == 'mysql') { |
459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
609 | 652 | { |
610 | 653 | return false; |
611 | 654 | } |
612 | - } else $altitude = 0; |
|
655 | + } else { |
|
656 | + $altitude = 0; |
|
657 | + } |
|
613 | 658 | |
614 | 659 | if ($heading != "") |
615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
648 | 693 | $latitude = 0; |
649 | 694 | $longitude = 0; |
650 | 695 | } |
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
697 | + $heading = 0; |
|
698 | + } |
|
699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
700 | + $groundspeed = 0; |
|
701 | + } |
|
653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 704 | |
@@ -758,7 +807,9 @@ discard block |
||
758 | 807 | global $globalDBdriver, $globalArchive; |
759 | 808 | //$filter_query = $this->getFilter($filters,true,true); |
760 | 809 | $Connection= new Connection($this->db); |
761 | - if (!$Connection->tableExists('countries')) return array(); |
|
810 | + if (!$Connection->tableExists('countries')) { |
|
811 | + return array(); |
|
812 | + } |
|
762 | 813 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 814 | require_once('class.TrackerLive.php'); |
764 | 815 | $TrackerLive = new TrackerLive($this->db); |
@@ -801,7 +852,9 @@ discard block |
||
801 | 852 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
802 | 853 | } |
803 | 854 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
804 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
855 | + if ($limit) { |
|
856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
857 | + } |
|
805 | 858 | |
806 | 859 | |
807 | 860 | $sth = $this->db->prepare($query); |
@@ -834,12 +887,18 @@ discard block |
||
834 | 887 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
835 | 888 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 889 | if ($olderthanmonths > 0) { |
837 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
838 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
890 | + if ($globalDBdriver == 'mysql') { |
|
891 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
892 | + } else { |
|
893 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
894 | + } |
|
839 | 895 | } |
840 | 896 | if ($sincedate != '') { |
841 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
842 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
897 | + if ($globalDBdriver == 'mysql') { |
|
898 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
899 | + } else { |
|
900 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
901 | + } |
|
843 | 902 | } |
844 | 903 | $query_values = array(); |
845 | 904 | if ($year != '') { |
@@ -870,7 +929,9 @@ discard block |
||
870 | 929 | } |
871 | 930 | } |
872 | 931 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
873 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
932 | + if ($limit) { |
|
933 | + $query .= " LIMIT 10 OFFSET 0"; |
|
934 | + } |
|
874 | 935 | |
875 | 936 | $sth = $this->db->prepare($query); |
876 | 937 | $sth->execute($query_values); |
@@ -905,7 +966,9 @@ discard block |
||
905 | 966 | date_default_timezone_set($globalTimezone); |
906 | 967 | $datetime = new DateTime(); |
907 | 968 | $offset = $datetime->format('P'); |
908 | - } else $offset = '+00:00'; |
|
969 | + } else { |
|
970 | + $offset = '+00:00'; |
|
971 | + } |
|
909 | 972 | |
910 | 973 | if ($globalDBdriver == 'mysql') { |
911 | 974 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -955,7 +1018,9 @@ discard block |
||
955 | 1018 | date_default_timezone_set($globalTimezone); |
956 | 1019 | $datetime = new DateTime(); |
957 | 1020 | $offset = $datetime->format('P'); |
958 | - } else $offset = '+00:00'; |
|
1021 | + } else { |
|
1022 | + $offset = '+00:00'; |
|
1023 | + } |
|
959 | 1024 | $filter_query = $this->getFilter($filters,true,true); |
960 | 1025 | if ($globalDBdriver == 'mysql') { |
961 | 1026 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1001,7 +1066,9 @@ discard block |
||
1001 | 1066 | date_default_timezone_set($globalTimezone); |
1002 | 1067 | $datetime = new DateTime(); |
1003 | 1068 | $offset = $datetime->format('P'); |
1004 | - } else $offset = '+00:00'; |
|
1069 | + } else { |
|
1070 | + $offset = '+00:00'; |
|
1071 | + } |
|
1005 | 1072 | $filter_query = $this->getFilter($filters,true,true); |
1006 | 1073 | if ($globalDBdriver == 'mysql') { |
1007 | 1074 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1049,7 +1116,9 @@ discard block |
||
1049 | 1116 | date_default_timezone_set($globalTimezone); |
1050 | 1117 | $datetime = new DateTime(); |
1051 | 1118 | $offset = $datetime->format('P'); |
1052 | - } else $offset = '+00:00'; |
|
1119 | + } else { |
|
1120 | + $offset = '+00:00'; |
|
1121 | + } |
|
1053 | 1122 | |
1054 | 1123 | if ($globalDBdriver == 'mysql') { |
1055 | 1124 | $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 |
@@ -1098,7 +1167,9 @@ discard block |
||
1098 | 1167 | date_default_timezone_set($globalTimezone); |
1099 | 1168 | $datetime = new DateTime(); |
1100 | 1169 | $offset = $datetime->format('P'); |
1101 | - } else $offset = '+00:00'; |
|
1170 | + } else { |
|
1171 | + $offset = '+00:00'; |
|
1172 | + } |
|
1102 | 1173 | $filter_query = $this->getFilter($filters,true,true); |
1103 | 1174 | if ($globalDBdriver == 'mysql') { |
1104 | 1175 | $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 |
@@ -1147,7 +1218,9 @@ discard block |
||
1147 | 1218 | date_default_timezone_set($globalTimezone); |
1148 | 1219 | $datetime = new DateTime(); |
1149 | 1220 | $offset = $datetime->format('P'); |
1150 | - } else $offset = '+00:00'; |
|
1221 | + } else { |
|
1222 | + $offset = '+00:00'; |
|
1223 | + } |
|
1151 | 1224 | |
1152 | 1225 | $orderby_sql = ''; |
1153 | 1226 | if ($orderby == "hour") |
@@ -1216,7 +1289,9 @@ discard block |
||
1216 | 1289 | date_default_timezone_set($globalTimezone); |
1217 | 1290 | $datetime = new DateTime($date); |
1218 | 1291 | $offset = $datetime->format('P'); |
1219 | - } else $offset = '+00:00'; |
|
1292 | + } else { |
|
1293 | + $offset = '+00:00'; |
|
1294 | + } |
|
1220 | 1295 | |
1221 | 1296 | if ($globalDBdriver == 'mysql') { |
1222 | 1297 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1264,7 +1339,9 @@ discard block |
||
1264 | 1339 | date_default_timezone_set($globalTimezone); |
1265 | 1340 | $datetime = new DateTime(); |
1266 | 1341 | $offset = $datetime->format('P'); |
1267 | - } else $offset = '+00:00'; |
|
1342 | + } else { |
|
1343 | + $offset = '+00:00'; |
|
1344 | + } |
|
1268 | 1345 | |
1269 | 1346 | if ($globalDBdriver == 'mysql') { |
1270 | 1347 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1329,8 +1406,11 @@ discard block |
||
1329 | 1406 | $query_values = array_merge($query_values,array(':month' => $month)); |
1330 | 1407 | } |
1331 | 1408 | } |
1332 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1409 | + if (empty($query_values)) { |
|
1410 | + $queryi .= $this->getFilter($filters); |
|
1411 | + } else { |
|
1412 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1413 | + } |
|
1334 | 1414 | |
1335 | 1415 | $sth = $this->db->prepare($queryi); |
1336 | 1416 | $sth->execute($query_values); |
@@ -1367,8 +1447,11 @@ discard block |
||
1367 | 1447 | $query_values = array_merge($query_values,array(':month' => $month)); |
1368 | 1448 | } |
1369 | 1449 | } |
1370 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1450 | + if (empty($query_values)) { |
|
1451 | + $queryi .= $this->getFilter($filters); |
|
1452 | + } else { |
|
1453 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1454 | + } |
|
1372 | 1455 | |
1373 | 1456 | $sth = $this->db->prepare($queryi); |
1374 | 1457 | $sth->execute($query_values); |
@@ -1390,7 +1473,9 @@ discard block |
||
1390 | 1473 | date_default_timezone_set($globalTimezone); |
1391 | 1474 | $datetime = new DateTime(); |
1392 | 1475 | $offset = $datetime->format('P'); |
1393 | - } else $offset = '+00:00'; |
|
1476 | + } else { |
|
1477 | + $offset = '+00:00'; |
|
1478 | + } |
|
1394 | 1479 | |
1395 | 1480 | if ($globalDBdriver == 'mysql') { |
1396 | 1481 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1494,7 +1579,9 @@ discard block |
||
1494 | 1579 | */ |
1495 | 1580 | public function parseDirection($direction = 0) |
1496 | 1581 | { |
1497 | - if ($direction == '') $direction = 0; |
|
1582 | + if ($direction == '') { |
|
1583 | + $direction = 0; |
|
1584 | + } |
|
1498 | 1585 | $direction_array = array(); |
1499 | 1586 | $temp_array = array(); |
1500 | 1587 | |
@@ -1583,7 +1670,9 @@ discard block |
||
1583 | 1670 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1584 | 1671 | |
1585 | 1672 | $Connection = new Connection($this->db); |
1586 | - if (!$Connection->tableExists('countries')) return ''; |
|
1673 | + if (!$Connection->tableExists('countries')) { |
|
1674 | + return ''; |
|
1675 | + } |
|
1587 | 1676 | |
1588 | 1677 | try { |
1589 | 1678 | /* |
@@ -1603,9 +1692,13 @@ discard block |
||
1603 | 1692 | $sth->closeCursor(); |
1604 | 1693 | if (count($row) > 0) { |
1605 | 1694 | return $row; |
1606 | - } else return ''; |
|
1695 | + } else { |
|
1696 | + return ''; |
|
1697 | + } |
|
1607 | 1698 | } catch (PDOException $e) { |
1608 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1699 | + if (isset($globalDebug) && $globalDebug) { |
|
1700 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1701 | + } |
|
1609 | 1702 | return ''; |
1610 | 1703 | } |
1611 | 1704 | |
@@ -1623,7 +1716,9 @@ discard block |
||
1623 | 1716 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1624 | 1717 | |
1625 | 1718 | $Connection = new Connection($this->db); |
1626 | - if (!$Connection->tableExists('countries')) return ''; |
|
1719 | + if (!$Connection->tableExists('countries')) { |
|
1720 | + return ''; |
|
1721 | + } |
|
1627 | 1722 | |
1628 | 1723 | try { |
1629 | 1724 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1635,9 +1730,13 @@ discard block |
||
1635 | 1730 | $sth->closeCursor(); |
1636 | 1731 | if (count($row) > 0) { |
1637 | 1732 | return $row; |
1638 | - } else return ''; |
|
1733 | + } else { |
|
1734 | + return ''; |
|
1735 | + } |
|
1639 | 1736 | } catch (PDOException $e) { |
1640 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1737 | + if (isset($globalDebug) && $globalDebug) { |
|
1738 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1739 | + } |
|
1641 | 1740 | return ''; |
1642 | 1741 | } |
1643 | 1742 | |
@@ -1698,7 +1797,9 @@ discard block |
||
1698 | 1797 | } |
1699 | 1798 | } |
1700 | 1799 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1701 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1800 | + if ($limit) { |
|
1801 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1802 | + } |
|
1702 | 1803 | $sth = $this->db->prepare($query); |
1703 | 1804 | $sth->execute($query_values); |
1704 | 1805 | $tracker_array = array(); |
@@ -1725,7 +1826,9 @@ discard block |
||
1725 | 1826 | { |
1726 | 1827 | global $globalBitlyAccessToken; |
1727 | 1828 | |
1728 | - if ($globalBitlyAccessToken == '') return $url; |
|
1829 | + if ($globalBitlyAccessToken == '') { |
|
1830 | + return $url; |
|
1831 | + } |
|
1729 | 1832 | |
1730 | 1833 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1731 | 1834 |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | public function __construct($dbc = null) { |
10 | 10 | $Connection = new Connection($dbc); |
11 | 11 | $this->db = $Connection->db(); |
12 | - if ($this->db === null) die('Error: No DB connection. (Image)'); |
|
12 | + if ($this->db === null) { |
|
13 | + die('Error: No DB connection. (Image)'); |
|
14 | + } |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
26 | 28 | $reg = $registration; |
27 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
29 | + if ($reg == '' && $aircraft_icao != '') { |
|
30 | + $reg = $aircraft_icao.$airline_icao; |
|
31 | + } |
|
28 | 32 | $reg = trim($reg); |
29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | $sth = $this->db->prepare($query); |
33 | 37 | $sth->execute(array(':registration' => $reg)); |
34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | - if (!empty($result)) return $result; |
|
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
37 | - else return array(); |
|
39 | + if (!empty($result)) { |
|
40 | + return $result; |
|
41 | + } elseif ($registration != '') { |
|
42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
38 | 46 | } |
39 | 47 | |
40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
77 | 85 | public function getExifCopyright($url) { |
78 | 86 | $exif = exif_read_data($url); |
79 | 87 | $copyright = ''; |
80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
90 | + } elseif (isset($exif['copyright'])) { |
|
91 | + $copyright = $exif['copyright']; |
|
92 | + } |
|
82 | 93 | if ($copyright != '') { |
83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
97 | 108 | { |
98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
111 | + return ''; |
|
112 | + } |
|
100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
101 | 114 | $registration = trim($registration); |
102 | 115 | //getting the aircraft image |
103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
116 | + if ($globalDebug && $registration != '') { |
|
117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
122 | + } |
|
106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
124 | + if ($registration == '' && $aircraft_icao != '') { |
|
125 | + $registration = $aircraft_icao.$airline_icao; |
|
126 | + } |
|
108 | 127 | if ($image_url['original'] != '') { |
109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
128 | + if ($globalDebug) { |
|
129 | + echo 'Found !'."\n"; |
|
130 | + } |
|
110 | 131 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
111 | 132 | try { |
112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
115 | 136 | echo $e->getMessage()."\n"; |
116 | 137 | return "error"; |
117 | 138 | } |
118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
139 | + } elseif ($globalDebug) { |
|
140 | + echo "Not found :'(\n"; |
|
141 | + } |
|
119 | 142 | return "success"; |
120 | 143 | } |
121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
129 | 152 | { |
130 | 153 | global $globalDebug,$globalMarineImageFetch; |
131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
155 | + return ''; |
|
156 | + } |
|
132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
138 | 163 | $identity = $Marine->getIdentity($mmsi); |
139 | 164 | if (isset($identity[0]['mmsi'])) { |
140 | 165 | $imo = $identity[0]['imo']; |
141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
166 | + if ($identity[0]['ship_name'] != '') { |
|
167 | + $name = $identity[0]['ship_name']; |
|
168 | + } |
|
142 | 169 | } |
143 | 170 | } |
144 | 171 | unset($Marine); |
145 | 172 | |
146 | 173 | //getting the aircraft image |
147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
174 | + if ($globalDebug && $name != '') { |
|
175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
176 | + } |
|
148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
149 | 178 | if ($image_url['original'] != '') { |
150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo 'Found !'."\n"; |
|
181 | + } |
|
151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
152 | 183 | try { |
153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
156 | 187 | echo $e->getMessage()."\n"; |
157 | 188 | return "error"; |
158 | 189 | } |
159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
190 | + } elseif ($globalDebug) { |
|
191 | + echo "Not found :'(\n"; |
|
192 | + } |
|
160 | 193 | return "success"; |
161 | 194 | } |
162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
171 | 204 | { |
172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 206 | $Spotter = new Spotter($this->db); |
174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
207 | + if (!isset($globalIVAO)) { |
|
208 | + $globalIVAO = FALSE; |
|
209 | + } |
|
175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
176 | 211 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
214 | + } |
|
178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
181 | - else $aircraft_name = ''; |
|
182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
183 | - else $aircraft_icao = ''; |
|
184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
185 | - else $airline_icao = ''; |
|
217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
219 | + } else { |
|
220 | + $aircraft_name = ''; |
|
221 | + } |
|
222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
224 | + } else { |
|
225 | + $aircraft_icao = ''; |
|
226 | + } |
|
227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
229 | + } else { |
|
230 | + $airline_icao = ''; |
|
231 | + } |
|
186 | 232 | } elseif ($aircraft_icao != '') { |
187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
189 | - else $aircraft_name = ''; |
|
234 | + if (isset($aircraft_info[0]['type'])) { |
|
235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
236 | + } else { |
|
237 | + $aircraft_name = ''; |
|
238 | + } |
|
190 | 239 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
240 | + } else { |
|
241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
242 | + } |
|
192 | 243 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
244 | + if (!isset($globalAircraftImageSources)) { |
|
245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
246 | + } |
|
194 | 247 | foreach ($globalAircraftImageSources as $source) { |
195 | 248 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
207 | - } |
|
208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
251 | + } |
|
252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'bing') { |
|
259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'wikimedia') { |
|
265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if ($source == 'customsources') { |
|
277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
278 | + } |
|
279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
280 | + return $images_array; |
|
281 | + } |
|
282 | + } |
|
283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
284 | + return $this->findAircraftImage($aircraft_icao); |
|
285 | + } |
|
209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
210 | 287 | } |
211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
227 | 304 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
305 | + if (strlen($name) < 4) { |
|
306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
307 | + } |
|
229 | 308 | /* |
230 | 309 | $Marine = new Marine($this->db); |
231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
237 | 316 | } |
238 | 317 | unset($Marine); |
239 | 318 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
319 | + if (!isset($globalMarineImageSources)) { |
|
320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
321 | + } |
|
241 | 322 | foreach ($globalMarineImageSources as $source) { |
242 | 323 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
324 | + if ($source == 'flickr') { |
|
325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'bing') { |
|
328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'deviantart') { |
|
331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'wikimedia') { |
|
334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if ($source == 'customsources') { |
|
337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
338 | + } |
|
339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
340 | + return $images_array; |
|
341 | + } |
|
249 | 342 | } |
250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
251 | 344 | } |
@@ -268,7 +361,9 @@ discard block |
||
268 | 361 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
269 | 362 | } |
270 | 363 | $data = $Common->getData($url); |
271 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
364 | + if (substr($data, 0, 5) != "<?xml") { |
|
365 | + return false; |
|
366 | + } |
|
272 | 367 | if ($xml = simplexml_load_string($data)) { |
273 | 368 | if (isset($xml->channel->item)) { |
274 | 369 | $image_url = array(); |
@@ -307,7 +402,9 @@ discard block |
||
307 | 402 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
308 | 403 | } |
309 | 404 | $data = $Common->getData($url); |
310 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
405 | + if (substr($data, 0, 5) != "<?xml") { |
|
406 | + return false; |
|
407 | + } |
|
311 | 408 | if ($xml = simplexml_load_string($data)) { |
312 | 409 | if (isset($xml->channel->item->link)) { |
313 | 410 | $image_url = array(); |
@@ -411,14 +508,22 @@ discard block |
||
411 | 508 | public function fromFlickr($type,$registration,$name='') { |
412 | 509 | $Common = new Common(); |
413 | 510 | if ($type == 'aircraft') { |
414 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
415 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
511 | + if ($name != '') { |
|
512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
513 | + } else { |
|
514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
515 | + } |
|
416 | 516 | } elseif ($type == 'marine') { |
417 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
418 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
517 | + if ($name != '') { |
|
518 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
519 | + } else { |
|
520 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
521 | + } |
|
419 | 522 | } |
420 | 523 | $data = $Common->getData($url); |
421 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
524 | + if (substr($data, 0, 5) != "<?xml") { |
|
525 | + return false; |
|
526 | + } |
|
422 | 527 | if ($xml = simplexml_load_string($data)) { |
423 | 528 | if (isset($xml->channel->item)) { |
424 | 529 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -461,13 +566,21 @@ discard block |
||
461 | 566 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
462 | 567 | global $globalImageBingKey; |
463 | 568 | $Common = new Common(); |
464 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
569 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
570 | + return false; |
|
571 | + } |
|
465 | 572 | if ($type == 'aircraft') { |
466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
573 | + if ($aircraft_name != '') { |
|
574 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
575 | + } else { |
|
576 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
577 | + } |
|
468 | 578 | } elseif ($type == 'marine') { |
469 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
470 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
579 | + if ($aircraft_name != '') { |
|
580 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
581 | + } else { |
|
582 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
583 | + } |
|
471 | 584 | } |
472 | 585 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
473 | 586 | $data = $Common->getData($url,'get','',$headers); |
@@ -523,17 +636,25 @@ discard block |
||
523 | 636 | public function fromWikimedia($type,$registration,$name='') { |
524 | 637 | $Common = new Common(); |
525 | 638 | if ($type == 'aircraft') { |
526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
527 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
639 | + if ($name != '') { |
|
640 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
641 | + } else { |
|
642 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
643 | + } |
|
528 | 644 | } elseif ($type == 'marine') { |
529 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
530 | - else return false; |
|
645 | + if ($name != '') { |
|
646 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
647 | + } else { |
|
648 | + return false; |
|
649 | + } |
|
531 | 650 | } |
532 | 651 | $data = $Common->getData($url); |
533 | 652 | $result = json_decode($data); |
534 | 653 | if (isset($result->query->search[0]->title)) { |
535 | 654 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
655 | + if (substr($fileo,-3) == 'pdf') { |
|
656 | + return false; |
|
657 | + } |
|
537 | 658 | $file = urlencode($fileo); |
538 | 659 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 660 | $data2 = $Common->getData($url2); |
@@ -604,18 +725,27 @@ discard block |
||
604 | 725 | $image_url = array(); |
605 | 726 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 727 | $image_url['original'] = $url; |
607 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
608 | - else $exifCopyright = ''; |
|
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
611 | - else $image_url['copyright'] = $source['source_website']; |
|
728 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
729 | + $exifCopyright = $this->getExifCopyright($url); |
|
730 | + } else { |
|
731 | + $exifCopyright = ''; |
|
732 | + } |
|
733 | + if ($exifCopyright != '') { |
|
734 | + $image_url['copyright'] = $exifCopyright; |
|
735 | + } elseif (isset($source['copyright'])) { |
|
736 | + $image_url['copyright'] = $source['copyright']; |
|
737 | + } else { |
|
738 | + $image_url['copyright'] = $source['source_website']; |
|
739 | + } |
|
612 | 740 | $image_url['source_website'] = $source['source_website']; |
613 | 741 | $image_url['source'] = $source['source']; |
614 | 742 | return $image_url; |
615 | 743 | } |
616 | 744 | } |
617 | 745 | return false; |
618 | - } else return false; |
|
746 | + } else { |
|
747 | + return false; |
|
748 | + } |
|
619 | 749 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
620 | 750 | $customsources = array(); |
621 | 751 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -640,18 +770,27 @@ discard block |
||
640 | 770 | $image_url = array(); |
641 | 771 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 772 | $image_url['original'] = $url; |
643 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
644 | - else $exifCopyright = ''; |
|
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
647 | - else $image_url['copyright'] = $source['source_website']; |
|
773 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
774 | + $exifCopyright = $this->getExifCopyright($url); |
|
775 | + } else { |
|
776 | + $exifCopyright = ''; |
|
777 | + } |
|
778 | + if ($exifCopyright != '') { |
|
779 | + $image_url['copyright'] = $exifCopyright; |
|
780 | + } elseif (isset($source['copyright'])) { |
|
781 | + $image_url['copyright'] = $source['copyright']; |
|
782 | + } else { |
|
783 | + $image_url['copyright'] = $source['source_website']; |
|
784 | + } |
|
648 | 785 | $image_url['source_website'] = $source['source_website']; |
649 | 786 | $image_url['source'] = $source['source']; |
650 | 787 | return $image_url; |
651 | 788 | } |
652 | 789 | } |
653 | 790 | return false; |
654 | - } else return false; |
|
791 | + } else { |
|
792 | + return false; |
|
793 | + } |
|
655 | 794 | } |
656 | 795 | } |
657 | 796 |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,17 +108,25 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
108 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
132 | 148 | |
133 | 149 | public function checkAll() { |
134 | 150 | global $globalDebug, $globalNoImport; |
135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Update last seen flights data...\n"; |
|
153 | + } |
|
136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | 155 | foreach ($this->all_flights as $key => $flight) { |
138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 158 | $Spotter = new Spotter($this->db); |
141 | 159 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
161 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
162 | + } |
|
143 | 163 | } |
144 | 164 | } |
145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
147 | 167 | |
148 | 168 | public function arrival($key) { |
149 | 169 | global $globalClosestMinDist, $globalDebug; |
150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo 'Update arrival...'."\n"; |
|
172 | + } |
|
151 | 173 | $Spotter = new Spotter($this->db); |
152 | 174 | $airport_icao = ''; |
153 | 175 | $airport_time = ''; |
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
177 | + $globalClosestMinDist = 50; |
|
178 | + } |
|
155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
157 | 181 | if (isset($closestAirports[0])) { |
158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
187 | + } |
|
162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
163 | 189 | foreach ($closestAirports as $airport) { |
164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
165 | 191 | $airport_icao = $airport['icao']; |
166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
195 | + } |
|
168 | 196 | break; |
169 | 197 | } |
170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 202 | } else { |
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
205 | + } |
|
176 | 206 | } |
177 | 207 | } else { |
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
210 | + } |
|
179 | 211 | } |
180 | 212 | |
181 | 213 | } else { |
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
216 | + } |
|
183 | 217 | } |
184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
189 | 223 | public function del() { |
190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 225 | // Delete old infos |
192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
226 | + if ($globalDebug) { |
|
227 | + echo 'Delete old values and update latest data...'."\n"; |
|
228 | + } |
|
193 | 229 | foreach ($this->all_flights as $key => $flight) { |
194 | 230 | if (isset($flight['lastupdate'])) { |
195 | 231 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -203,13 +239,17 @@ discard block |
||
203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 240 | // Delete old infos |
205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
244 | + } |
|
207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
208 | 246 | $real_arrival = $this->arrival($key); |
209 | 247 | $Spotter = new Spotter($this->db); |
210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | 249 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
250 | + if ($globalDebug && $result != 'success') { |
|
251 | + echo '!!! ERROR : '.$result."\n"; |
|
252 | + } |
|
213 | 253 | } |
214 | 254 | } |
215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
219 | 259 | public function add($line) { |
220 | 260 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224 | -/* |
|
262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
263 | + $globalCoordMinChange = '0.01'; |
|
264 | + } |
|
265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
266 | + $globalAircraftMaxUpdate = 3000; |
|
267 | + } |
|
268 | + /* |
|
225 | 269 | $Spotter = new Spotter(); |
226 | 270 | $dbc = $Spotter->db; |
227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
243 | 287 | // SBS format is CSV format |
244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | 289 | //print_r($line); |
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
290 | + if (isset($line['hex'])) { |
|
291 | + $line['hex'] = strtoupper($line['hex']); |
|
292 | + } |
|
247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
248 | 294 | |
249 | 295 | // Increment message number |
250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | 297 | $current_date = date('Y-m-d'); |
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
298 | + if (isset($line['source_name'])) { |
|
299 | + $source = $line['source_name']; |
|
300 | + } else { |
|
301 | + $source = ''; |
|
302 | + } |
|
303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
304 | + $source = $line['format_source']; |
|
305 | + } |
|
255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
309 | + } else { |
|
310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
311 | + } |
|
259 | 312 | } |
260 | 313 | |
261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
271 | 324 | //$this->db = $dbc; |
272 | 325 | |
273 | 326 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
327 | + if (!isset($line['id'])) { |
|
328 | + $id = trim($line['hex']); |
|
329 | + } else { |
|
330 | + $id = trim($line['id']); |
|
331 | + } |
|
276 | 332 | |
277 | 333 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'New flight...'."\n"; |
|
336 | + } |
|
279 | 337 | $this->all_flights[$id] = array(); |
280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
281 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
342 | + } |
|
283 | 343 | if (!isset($line['id'])) { |
284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
344 | + if (!isset($globalDaemon)) { |
|
345 | + $globalDaemon = TRUE; |
|
346 | + } |
|
347 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
286 | 348 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
349 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
351 | + } |
|
288 | 352 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
353 | + } else { |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
355 | + } |
|
356 | + if ($globalAllFlights !== FALSE) { |
|
357 | + $dataFound = true; |
|
358 | + } |
|
291 | 359 | } |
292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 378 | } |
311 | 379 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
383 | + if ($aircraft_icao != '') { |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
385 | + } |
|
314 | 386 | } |
315 | 387 | } |
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
388 | + if ($globalAllFlights !== FALSE) { |
|
389 | + $dataFound = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
393 | + } |
|
318 | 394 | } |
319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -323,7 +399,9 @@ discard block |
||
323 | 399 | $icao = $line['aircraft_icao']; |
324 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
325 | 401 | $Spotter = new Spotter($this->db); |
326 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
402 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
403 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
404 | + } |
|
327 | 405 | $Spotter->db = null; |
328 | 406 | } |
329 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -334,15 +412,24 @@ discard block |
||
334 | 412 | $Spotter = new Spotter($this->db); |
335 | 413 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
336 | 414 | $Spotter->db = null; |
337 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
415 | + if ($aircraft_icao != '') { |
|
416 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
417 | + } |
|
338 | 418 | } |
339 | 419 | } |
340 | 420 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
341 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
342 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
343 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
344 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
345 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
421 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
422 | + $aircraft_icao = 'GLID'; |
|
423 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
424 | + $aircraft_icao = 'UHEL'; |
|
425 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
426 | + $aircraft_icao = 'TOWPLANE'; |
|
427 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
428 | + $aircraft_icao = 'POWAIRC'; |
|
429 | + } |
|
430 | + if (isset($aircraft_icao)) { |
|
431 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
432 | + } |
|
346 | 433 | } |
347 | 434 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
348 | 435 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -352,8 +439,11 @@ discard block |
||
352 | 439 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
353 | 440 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
354 | 441 | } else { |
355 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
356 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
442 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
443 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
444 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
445 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
446 | + } |
|
357 | 447 | /* |
358 | 448 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
359 | 449 | print_r($this->all_flights[$id]); |
@@ -362,16 +452,22 @@ discard block |
||
362 | 452 | return ''; |
363 | 453 | } |
364 | 454 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
365 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
455 | + if ($globalDebug) { |
|
456 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
457 | + } |
|
366 | 458 | return ''; |
367 | 459 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
368 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
460 | + if ($globalDebug) { |
|
461 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
462 | + } |
|
369 | 463 | return ''; |
370 | 464 | } elseif (!isset($line['datetime'])) { |
371 | 465 | date_default_timezone_set('UTC'); |
372 | 466 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
373 | 467 | } else { |
374 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
468 | + if ($globalDebug) { |
|
469 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
470 | + } |
|
375 | 471 | return ''; |
376 | 472 | } |
377 | 473 | |
@@ -392,30 +488,48 @@ discard block |
||
392 | 488 | |
393 | 489 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
394 | 490 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
491 | + if ($globalDebug) { |
|
492 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
493 | + } |
|
396 | 494 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
397 | 495 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
398 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
399 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
400 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
496 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
498 | + } elseif (isset($line['id'])) { |
|
499 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
500 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
501 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
502 | + } |
|
401 | 503 | } else { |
402 | 504 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
403 | 505 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
404 | 506 | $timeelapsed = microtime(true); |
405 | 507 | $Spotter = new Spotter($this->db); |
406 | 508 | $fromsource = NULL; |
407 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
409 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
410 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
411 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
509 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
510 | + $fromsource = $globalAirlinesSource; |
|
511 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
512 | + $fromsource = 'vatsim'; |
|
513 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
514 | + $fromsource = 'ivao'; |
|
515 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
516 | + $fromsource = 'vatsim'; |
|
517 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
518 | + $fromsource = 'ivao'; |
|
519 | + } |
|
412 | 520 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
413 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
521 | + if ($globalDebug && $result != 'success') { |
|
522 | + echo '!!! ERROR : '.$result."\n"; |
|
523 | + } |
|
414 | 524 | $Spotter->db = null; |
415 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
525 | + if ($globalDebugTimeElapsed) { |
|
526 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
527 | + } |
|
416 | 528 | } |
417 | 529 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
530 | + } else { |
|
531 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
532 | + } |
|
419 | 533 | |
420 | 534 | /* |
421 | 535 | if (!isset($line['id'])) { |
@@ -425,7 +539,9 @@ discard block |
||
425 | 539 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 540 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 541 | */ |
428 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
542 | + if (!isset($this->all_flights[$id]['id'])) { |
|
543 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
544 | + } |
|
429 | 545 | |
430 | 546 | //$putinarchive = true; |
431 | 547 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -443,7 +559,9 @@ discard block |
||
443 | 559 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 560 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | 561 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
562 | + if ($globalDebugTimeElapsed) { |
|
563 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
564 | + } |
|
447 | 565 | } |
448 | 566 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
449 | 567 | $timeelapsed = microtime(true); |
@@ -457,7 +575,9 @@ discard block |
||
457 | 575 | $Translation->db = null; |
458 | 576 | } |
459 | 577 | $Spotter->db = null; |
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
578 | + if ($globalDebugTimeElapsed) { |
|
579 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
580 | + } |
|
461 | 581 | } |
462 | 582 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | 583 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -466,9 +586,13 @@ discard block |
||
466 | 586 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
467 | 587 | } |
468 | 588 | } |
469 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
589 | + if (!isset($globalFork)) { |
|
590 | + $globalFork = TRUE; |
|
591 | + } |
|
470 | 592 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
593 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
594 | + $this->get_Schedule($id,trim($line['ident'])); |
|
595 | + } |
|
472 | 596 | } |
473 | 597 | } |
474 | 598 | } |
@@ -486,9 +610,13 @@ discard block |
||
486 | 610 | $speed = $speed*3.6; |
487 | 611 | if ($speed < 1000) { |
488 | 612 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
489 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
613 | + if ($globalDebug) { |
|
614 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
615 | + } |
|
490 | 616 | } else { |
491 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
617 | + if ($globalDebug) { |
|
618 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
619 | + } |
|
492 | 620 | } |
493 | 621 | } |
494 | 622 | } |
@@ -497,13 +625,21 @@ discard block |
||
497 | 625 | |
498 | 626 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
499 | 627 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
500 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
628 | + if ($globalDebug) { |
|
629 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
630 | + } |
|
501 | 631 | return false; |
502 | 632 | } |
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | - else unset($timediff); |
|
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | - else unset($timediff_archive); |
|
633 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
634 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
635 | + } else { |
|
636 | + unset($timediff); |
|
637 | + } |
|
638 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
639 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
640 | + } else { |
|
641 | + unset($timediff_archive); |
|
642 | + } |
|
507 | 643 | if ($this->tmd > 5 |
508 | 644 | || (isset($line['format_source']) |
509 | 645 | && $line['format_source'] == 'airwhere' |
@@ -539,16 +675,25 @@ discard block |
||
539 | 675 | $this->all_flights[$id]['putinarchive'] = true; |
540 | 676 | $this->tmd = 0; |
541 | 677 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
542 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
678 | + if ($globalDebug) { |
|
679 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
680 | + } |
|
543 | 681 | $timeelapsed = microtime(true); |
544 | 682 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 683 | $Spotter = new Spotter($this->db); |
546 | 684 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
547 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
548 | - else $this->all_flights[$id]['over_country'] = ''; |
|
685 | + if (!empty($all_country)) { |
|
686 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
687 | + } else { |
|
688 | + $this->all_flights[$id]['over_country'] = ''; |
|
689 | + } |
|
549 | 690 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
691 | + if ($globalDebugTimeElapsed) { |
|
692 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
696 | + } |
|
552 | 697 | } |
553 | 698 | } |
554 | 699 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -594,7 +739,9 @@ discard block |
||
594 | 739 | */ |
595 | 740 | } |
596 | 741 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
597 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
742 | + if ($line['longitude'] > 180) { |
|
743 | + $line['longitude'] = $line['longitude'] - 360; |
|
744 | + } |
|
598 | 745 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
599 | 746 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
600 | 747 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -631,7 +778,9 @@ discard block |
||
631 | 778 | } |
632 | 779 | } |
633 | 780 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
781 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
782 | + $dataFound = true; |
|
783 | + } |
|
635 | 784 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
636 | 785 | } |
637 | 786 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -653,35 +802,53 @@ discard block |
||
653 | 802 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | 803 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
655 | 804 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
656 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
805 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
807 | + } elseif (isset($line['id'])) { |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
809 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
810 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
811 | + } |
|
812 | + } |
|
813 | + if ($line['ground'] != 1) { |
|
814 | + $line['ground'] = 0; |
|
659 | 815 | } |
660 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | 816 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
662 | 817 | //$dataFound = true; |
663 | 818 | } |
664 | 819 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 820 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
666 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
821 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
822 | + $this->all_flights[$id]['putinarchive'] = true; |
|
823 | + } |
|
667 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
668 | 825 | $highlight = ''; |
669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
826 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
827 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
828 | + } |
|
829 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
830 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
831 | + } |
|
832 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
833 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
834 | + } |
|
672 | 835 | if ($highlight != '') { |
673 | 836 | $timeelapsed = microtime(true); |
674 | 837 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 838 | $Spotter = new Spotter($this->db); |
676 | 839 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
677 | 840 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
841 | + if ($globalDebugTimeElapsed) { |
|
842 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
843 | + } |
|
679 | 844 | } |
680 | 845 | //$putinarchive = true; |
681 | 846 | //$highlight = ''; |
682 | 847 | } |
683 | 848 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
849 | + } else { |
|
850 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
851 | + } |
|
685 | 852 | //$dataFound = true; |
686 | 853 | } |
687 | 854 | |
@@ -694,19 +861,27 @@ discard block |
||
694 | 861 | } |
695 | 862 | } |
696 | 863 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
864 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
865 | + $this->all_flights[$id]['putinarchive'] = true; |
|
866 | + } |
|
698 | 867 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
699 | 868 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
700 | 869 | //$dataFound = true; |
701 | 870 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 871 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 872 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
873 | + if ($globalDebug) { |
|
874 | + echo '--- Reset because of altitude'."\n"; |
|
875 | + } |
|
705 | 876 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
706 | 877 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
707 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
878 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
880 | + } elseif (isset($line['id'])) { |
|
881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
882 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
883 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
884 | + } |
|
710 | 885 | } |
711 | 886 | } |
712 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -717,22 +892,32 @@ discard block |
||
717 | 892 | } |
718 | 893 | |
719 | 894 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
895 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
896 | + $this->all_flights[$id]['putinarchive'] = true; |
|
897 | + } |
|
721 | 898 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
722 | 899 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
723 | 900 | //$dataFound = true; |
724 | 901 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | 902 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
726 | 903 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
904 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
905 | + $this->all_flights[$id]['putinarchive'] = true; |
|
906 | + } |
|
907 | + if ($globalDebug) { |
|
908 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
909 | + } |
|
729 | 910 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 911 | // If not enough messages and ACARS set heading to 0 |
731 | 912 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
732 | 913 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
914 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
915 | + $dataFound = false; |
|
916 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
917 | + $dataFound = false; |
|
918 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
919 | + $dataFound = false; |
|
920 | + } |
|
736 | 921 | |
737 | 922 | // print_r($this->all_flights[$id]); |
738 | 923 | //gets the callsign from the last hour |
@@ -749,23 +934,38 @@ discard block |
||
749 | 934 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
750 | 935 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
751 | 936 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
752 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
937 | + if ($globalDebug) { |
|
938 | + echo "Check if aircraft is already in DB..."; |
|
939 | + } |
|
753 | 940 | $timeelapsed = microtime(true); |
754 | 941 | $SpotterLive = new SpotterLive($this->db); |
755 | 942 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
756 | 943 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
944 | + if ($globalDebugTimeElapsed) { |
|
945 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
946 | + } |
|
758 | 947 | } elseif (isset($line['id'])) { |
759 | 948 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
949 | + if ($globalDebugTimeElapsed) { |
|
950 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
951 | + } |
|
761 | 952 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 953 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
764 | - } else $recent_ident = ''; |
|
954 | + if ($globalDebugTimeElapsed) { |
|
955 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
956 | + } |
|
957 | + } else { |
|
958 | + $recent_ident = ''; |
|
959 | + } |
|
765 | 960 | $SpotterLive->db=null; |
766 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768 | - } else $recent_ident = ''; |
|
961 | + if ($globalDebug && $recent_ident == '') { |
|
962 | + echo " Not in DB.\n"; |
|
963 | + } elseif ($globalDebug && $recent_ident != '') { |
|
964 | + echo " Already in DB.\n"; |
|
965 | + } |
|
966 | + } else { |
|
967 | + $recent_ident = ''; |
|
968 | + } |
|
769 | 969 | } else { |
770 | 970 | $recent_ident = ''; |
771 | 971 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -773,7 +973,9 @@ discard block |
||
773 | 973 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | 974 | if($recent_ident == "") |
775 | 975 | { |
776 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
976 | + if ($globalDebug) { |
|
977 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
978 | + } |
|
777 | 979 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 980 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 981 | //adds the spotter data for the archive |
@@ -817,31 +1019,49 @@ discard block |
||
817 | 1019 | |
818 | 1020 | if (!$ignoreImport) { |
819 | 1021 | $highlight = ''; |
820 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1022 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1023 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1024 | + } |
|
1025 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1026 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1027 | + } |
|
1028 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1029 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1030 | + } |
|
1031 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1032 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1033 | + } |
|
824 | 1034 | $timeelapsed = microtime(true); |
825 | 1035 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 1036 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 1037 | $Spotter = new Spotter($this->db); |
828 | 1038 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
829 | 1039 | $Spotter->db = null; |
830 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
1040 | + if ($globalDebug && isset($result)) { |
|
1041 | + echo $result."\n"; |
|
1042 | + } |
|
831 | 1043 | } |
832 | 1044 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1045 | + if ($globalDebugTimeElapsed) { |
|
1046 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1047 | + } |
|
834 | 1048 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 1049 | |
836 | 1050 | // Add source stat in DB |
837 | 1051 | $Stats = new Stats($this->db); |
838 | 1052 | if (!empty($this->stats)) { |
839 | - if ($globalDebug) echo 'Add source stats : '; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo 'Add source stats : '; |
|
1055 | + } |
|
840 | 1056 | foreach($this->stats as $date => $data) { |
841 | 1057 | foreach($data as $source => $sourced) { |
842 | 1058 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1059 | + if (isset($sourced['polar'])) { |
|
1060 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1061 | + } |
|
1062 | + if (isset($sourced['hist'])) { |
|
1063 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1064 | + } |
|
845 | 1065 | if (isset($sourced['msg'])) { |
846 | 1066 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 1067 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -854,13 +1074,17 @@ discard block |
||
854 | 1074 | unset($this->stats[$date]); |
855 | 1075 | } |
856 | 1076 | } |
857 | - if ($globalDebug) echo 'Done'."\n"; |
|
1077 | + if ($globalDebug) { |
|
1078 | + echo 'Done'."\n"; |
|
1079 | + } |
|
858 | 1080 | |
859 | 1081 | } |
860 | 1082 | $Stats->db = null; |
861 | 1083 | } |
862 | 1084 | $this->del(); |
863 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1085 | + } elseif ($globalDebug) { |
|
1086 | + echo 'Ignore data'."\n"; |
|
1087 | + } |
|
864 | 1088 | //$ignoreImport = false; |
865 | 1089 | $this->all_flights[$id]['addedSpotter'] = 1; |
866 | 1090 | //print_r($this->all_flights[$id]); |
@@ -877,7 +1101,9 @@ discard block |
||
877 | 1101 | */ |
878 | 1102 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
879 | 1103 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
880 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1104 | + if ($globalDebug) { |
|
1105 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1106 | + } |
|
881 | 1107 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
882 | 1108 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
883 | 1109 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -886,7 +1112,9 @@ discard block |
||
886 | 1112 | $SpotterLive->db=null; |
887 | 1113 | } |
888 | 1114 | } |
889 | - if ($globalDebug) echo " Done\n"; |
|
1115 | + if ($globalDebug) { |
|
1116 | + echo " Done\n"; |
|
1117 | + } |
|
890 | 1118 | $this->last_delete = time(); |
891 | 1119 | } |
892 | 1120 | } else { |
@@ -913,11 +1141,17 @@ discard block |
||
913 | 1141 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
914 | 1142 | if ($globalDebug) { |
915 | 1143 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
916 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
917 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1144 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1145 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1146 | + } else { |
|
1147 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1148 | + } |
|
918 | 1149 | } else { |
919 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
920 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1150 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1151 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1152 | + } else { |
|
1153 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1154 | + } |
|
921 | 1155 | } |
922 | 1156 | } |
923 | 1157 | $ignoreImport = false; |
@@ -963,22 +1197,30 @@ discard block |
||
963 | 1197 | |
964 | 1198 | if (!$ignoreImport) { |
965 | 1199 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
966 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1200 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1201 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1202 | + } |
|
967 | 1203 | $timeelapsed = microtime(true); |
968 | 1204 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 1205 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1206 | + if ($globalDebug) { |
|
1207 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1208 | + } |
|
971 | 1209 | $SpotterLive = new SpotterLive($this->db); |
972 | 1210 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
973 | 1211 | $SpotterLive->db = null; |
974 | - if ($globalDebug) echo $result."\n"; |
|
1212 | + if ($globalDebug) { |
|
1213 | + echo $result."\n"; |
|
1214 | + } |
|
975 | 1215 | } |
976 | 1216 | } |
977 | 1217 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | 1218 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
979 | 1219 | } |
980 | 1220 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1221 | + if ($globalDebugTimeElapsed) { |
|
1222 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1223 | + } |
|
982 | 1224 | |
983 | 1225 | // Put statistics in $this->stats variable |
984 | 1226 | //if ($line['format_source'] != 'aprs') { |
@@ -986,7 +1228,9 @@ discard block |
||
986 | 1228 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | 1229 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
988 | 1230 | $source = $this->all_flights[$id]['source_name']; |
989 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1231 | + if ($source == '') { |
|
1232 | + $source = $this->all_flights[$id]['format_source']; |
|
1233 | + } |
|
990 | 1234 | if (!isset($this->source_location[$source])) { |
991 | 1235 | $Location = new Source($this->db); |
992 | 1236 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1007,7 +1251,9 @@ discard block |
||
1007 | 1251 | $stats_heading = round($stats_heading/22.5); |
1008 | 1252 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1009 | 1253 | $current_date = date('Y-m-d'); |
1010 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1254 | + if ($stats_heading == 16) { |
|
1255 | + $stats_heading = 0; |
|
1256 | + } |
|
1011 | 1257 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | 1258 | for ($i=0;$i<=15;$i++) { |
1013 | 1259 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1025,7 +1271,9 @@ discard block |
||
1025 | 1271 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1272 | end($this->stats[$current_date][$source]['hist']); |
1027 | 1273 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1028 | - } else $mini = 0; |
|
1274 | + } else { |
|
1275 | + $mini = 0; |
|
1276 | + } |
|
1029 | 1277 | for ($i=$mini;$i<=$distance;$i+=10) { |
1030 | 1278 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1279 | } |
@@ -1037,19 +1285,27 @@ discard block |
||
1037 | 1285 | } |
1038 | 1286 | |
1039 | 1287 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1288 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1289 | + $send = true; |
|
1290 | + } |
|
1041 | 1291 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1292 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1293 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1294 | + } |
|
1043 | 1295 | //$this->del(); |
1044 | 1296 | |
1045 | 1297 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1046 | 1298 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1047 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1299 | + if ($globalDebug) { |
|
1300 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1301 | + } |
|
1048 | 1302 | $SpotterLive = new SpotterLive($this->db); |
1049 | 1303 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1050 | 1304 | $SpotterLive->db = null; |
1051 | 1305 | //SpotterLive->deleteLiveSpotterData(); |
1052 | - if ($globalDebug) echo " Done\n"; |
|
1306 | + if ($globalDebug) { |
|
1307 | + echo " Done\n"; |
|
1308 | + } |
|
1053 | 1309 | $this->last_delete_hourly = time(); |
1054 | 1310 | } else { |
1055 | 1311 | $this->del(); |
@@ -1061,7 +1317,9 @@ discard block |
||
1061 | 1317 | //$ignoreImport = false; |
1062 | 1318 | } |
1063 | 1319 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1064 | - if ($send) return $this->all_flights[$id]; |
|
1320 | + if ($send) { |
|
1321 | + return $this->all_flights[$id]; |
|
1322 | + } |
|
1065 | 1323 | } |
1066 | 1324 | } |
1067 | 1325 | } |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -186,34 +212,49 @@ discard block |
||
186 | 212 | $Marine = new Marine($this->db); |
187 | 213 | $fromsource = NULL; |
188 | 214 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
189 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
215 | + if ($globalDebug && $result != 'success') { |
|
216 | + echo '!!! ERROR : '.$result."\n"; |
|
217 | + } |
|
190 | 218 | $Marine->db = null; |
191 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
219 | + if ($globalDebugTimeElapsed) { |
|
220 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
221 | + } |
|
192 | 222 | } |
193 | 223 | } |
194 | 224 | } |
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
225 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
226 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
227 | + } |
|
196 | 228 | } |
197 | 229 | |
198 | 230 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
199 | 231 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
200 | 232 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
201 | 233 | } else { |
202 | - 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"; |
|
203 | - 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"; |
|
234 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
235 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
236 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
237 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
238 | + } |
|
204 | 239 | return ''; |
205 | 240 | } |
206 | 241 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
207 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
244 | + } |
|
208 | 245 | return ''; |
209 | 246 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
210 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
247 | + if ($globalDebug) { |
|
248 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
249 | + } |
|
211 | 250 | return ''; |
212 | 251 | } elseif (!isset($line['datetime'])) { |
213 | 252 | date_default_timezone_set('UTC'); |
214 | 253 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
215 | 254 | } else { |
216 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
255 | + if ($globalDebug) { |
|
256 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
257 | + } |
|
217 | 258 | return ''; |
218 | 259 | } |
219 | 260 | |
@@ -226,14 +267,21 @@ discard block |
||
226 | 267 | if ($distance > 1000 && $distance < 10000) { |
227 | 268 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 269 | $speed = $speed*3.6; |
229 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
230 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
270 | + if ($speed < 1000) { |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
272 | + } |
|
273 | + if ($globalDebug) { |
|
274 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
275 | + } |
|
231 | 276 | } |
232 | 277 | } |
233 | 278 | |
234 | 279 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | - else unset($timediff); |
|
280 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
281 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
282 | + } else { |
|
283 | + unset($timediff); |
|
284 | + } |
|
237 | 285 | 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')))) { |
238 | 286 | 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'])) { |
239 | 287 | 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'])) { |
@@ -241,22 +289,32 @@ discard block |
||
241 | 289 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 290 | $this->all_tracked[$id]['putinarchive'] = true; |
243 | 291 | |
244 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
294 | + } |
|
245 | 295 | $timeelapsed = microtime(true); |
246 | 296 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | 297 | $Marine = new Marine($this->db); |
248 | 298 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
249 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
299 | + if (!empty($all_country)) { |
|
300 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
301 | + } |
|
250 | 302 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
303 | + if ($globalDebugTimeElapsed) { |
|
304 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
305 | + } |
|
252 | 306 | } |
253 | 307 | $this->tmd = 0; |
254 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
310 | + } |
|
255 | 311 | } |
256 | 312 | } |
257 | 313 | |
258 | 314 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
315 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
316 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
317 | + } |
|
260 | 318 | 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') { |
261 | 319 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
262 | 320 | $dataFound = true; |
@@ -265,8 +323,12 @@ discard block |
||
265 | 323 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
266 | 324 | } |
267 | 325 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
326 | + if ($line['longitude'] > 180) { |
|
327 | + $line['longitude'] = $line['longitude'] - 360; |
|
328 | + } |
|
329 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
330 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
331 | + } |
|
270 | 332 | 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') { |
271 | 333 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
272 | 334 | $dataFound = true; |
@@ -284,7 +346,9 @@ discard block |
||
284 | 346 | } |
285 | 347 | } |
286 | 348 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
349 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
350 | + $dataFound = true; |
|
351 | + } |
|
288 | 352 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
289 | 353 | } |
290 | 354 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -314,15 +378,21 @@ discard block |
||
314 | 378 | } |
315 | 379 | |
316 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
382 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
383 | + } |
|
318 | 384 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
319 | 385 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
320 | 386 | //$dataFound = true; |
321 | 387 | } 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']) { |
322 | 388 | $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']); |
323 | 389 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
390 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
391 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
392 | + } |
|
393 | + if ($globalDebug) { |
|
394 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
395 | + } |
|
326 | 396 | } |
327 | 397 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
328 | 398 | |
@@ -334,23 +404,38 @@ discard block |
||
334 | 404 | 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'])) { |
335 | 405 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
336 | 406 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
407 | + if ($globalDebug) { |
|
408 | + echo "Check if aircraft is already in DB..."; |
|
409 | + } |
|
338 | 410 | $timeelapsed = microtime(true); |
339 | 411 | $MarineLive = new MarineLive($this->db); |
340 | 412 | if (isset($line['id'])) { |
341 | 413 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + if ($globalDebugTimeElapsed) { |
|
415 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
416 | + } |
|
343 | 417 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
344 | 418 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) { |
|
420 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + } |
|
346 | 422 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
347 | 423 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
349 | - } else $recent_ident = ''; |
|
424 | + if ($globalDebugTimeElapsed) { |
|
425 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
426 | + } |
|
427 | + } else { |
|
428 | + $recent_ident = ''; |
|
429 | + } |
|
350 | 430 | $MarineLive->db=null; |
351 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
353 | - } else $recent_ident = ''; |
|
431 | + if ($globalDebug && $recent_ident == '') { |
|
432 | + echo " Not in DB.\n"; |
|
433 | + } elseif ($globalDebug && $recent_ident != '') { |
|
434 | + echo " Already in DB.\n"; |
|
435 | + } |
|
436 | + } else { |
|
437 | + $recent_ident = ''; |
|
438 | + } |
|
354 | 439 | } else { |
355 | 440 | $recent_ident = ''; |
356 | 441 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -358,30 +443,44 @@ discard block |
||
358 | 443 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
359 | 444 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
360 | 445 | { |
361 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
446 | + if ($globalDebug) { |
|
447 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
448 | + } |
|
362 | 449 | //adds the spotter data for the archive |
363 | 450 | $highlight = ''; |
364 | - 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'))); |
|
451 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
452 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
453 | + } |
|
365 | 454 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
366 | 455 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | 456 | $timeelapsed = microtime(true); |
368 | 457 | $Marine = new Marine($this->db); |
369 | 458 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
370 | 459 | $Marine->db = null; |
371 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + if ($globalDebug && isset($result)) { |
|
461 | + echo $result."\n"; |
|
462 | + } |
|
463 | + if ($globalDebugTimeElapsed) { |
|
464 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
465 | + } |
|
373 | 466 | } |
374 | 467 | } |
375 | 468 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
376 | 469 | // Add source stat in DB |
377 | 470 | $Stats = new Stats($this->db); |
378 | 471 | if (!empty($this->stats)) { |
379 | - if ($globalDebug) echo 'Add source stats : '; |
|
472 | + if ($globalDebug) { |
|
473 | + echo 'Add source stats : '; |
|
474 | + } |
|
380 | 475 | foreach($this->stats as $date => $data) { |
381 | 476 | foreach($data as $source => $sourced) { |
382 | 477 | //print_r($sourced); |
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
478 | + if (isset($sourced['polar'])) { |
|
479 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
480 | + } |
|
481 | + if (isset($sourced['hist'])) { |
|
482 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
483 | + } |
|
385 | 484 | if (isset($sourced['msg'])) { |
386 | 485 | if (time() - $sourced['msg']['date'] > 10) { |
387 | 486 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -394,7 +493,9 @@ discard block |
||
394 | 493 | unset($this->stats[$date]); |
395 | 494 | } |
396 | 495 | } |
397 | - if ($globalDebug) echo 'Done'."\n"; |
|
496 | + if ($globalDebug) { |
|
497 | + echo 'Done'."\n"; |
|
498 | + } |
|
398 | 499 | } |
399 | 500 | $Stats->db = null; |
400 | 501 | } |
@@ -404,13 +505,17 @@ discard block |
||
404 | 505 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 506 | //print_r($this->all_tracked[$id]); |
406 | 507 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
407 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
508 | + if ($globalDebug) { |
|
509 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
510 | + } |
|
408 | 511 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
409 | 512 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 513 | $MarineLive = new MarineLive($this->db); |
411 | 514 | $MarineLive->deleteLiveMarineData(); |
412 | 515 | $MarineLive->db=null; |
413 | - if ($globalDebug) echo " Done\n"; |
|
516 | + if ($globalDebug) { |
|
517 | + echo " Done\n"; |
|
518 | + } |
|
414 | 519 | } |
415 | 520 | $this->last_delete = time(); |
416 | 521 | } |
@@ -436,15 +541,21 @@ discard block |
||
436 | 541 | |
437 | 542 | if (!$ignoreImport) { |
438 | 543 | 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'])) { |
439 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
544 | + if ($globalDebug) { |
|
545 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
546 | + } |
|
440 | 547 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | 548 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 549 | $timeelapsed = microtime(true); |
443 | 550 | $MarineLive = new MarineLive($this->db); |
444 | 551 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
445 | 552 | $MarineLive->db = null; |
446 | - if ($globalDebug) echo $result."\n"; |
|
447 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
553 | + if ($globalDebug) { |
|
554 | + echo $result."\n"; |
|
555 | + } |
|
556 | + if ($globalDebugTimeElapsed) { |
|
557 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
558 | + } |
|
448 | 559 | } |
449 | 560 | } |
450 | 561 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -456,7 +567,9 @@ discard block |
||
456 | 567 | |
457 | 568 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
458 | 569 | $source = $this->all_tracked[$id]['source_name']; |
459 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
570 | + if ($source == '') { |
|
571 | + $source = $this->all_tracked[$id]['format_source']; |
|
572 | + } |
|
460 | 573 | if (!isset($this->source_location[$source])) { |
461 | 574 | $Location = new Source($this->db); |
462 | 575 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -477,7 +590,9 @@ discard block |
||
477 | 590 | $stats_heading = round($stats_heading/22.5); |
478 | 591 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
479 | 592 | $current_date = date('Y-m-d'); |
480 | - if ($stats_heading == 16) $stats_heading = 0; |
|
593 | + if ($stats_heading == 16) { |
|
594 | + $stats_heading = 0; |
|
595 | + } |
|
481 | 596 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | 597 | for ($i=0;$i<=15;$i++) { |
483 | 598 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -495,7 +610,9 @@ discard block |
||
495 | 610 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | 611 | end($this->stats[$current_date][$source]['hist']); |
497 | 612 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
498 | - } else $mini = 0; |
|
613 | + } else { |
|
614 | + $mini = 0; |
|
615 | + } |
|
499 | 616 | for ($i=$mini;$i<=$distance;$i+=10) { |
500 | 617 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
501 | 618 | } |
@@ -507,19 +624,27 @@ discard block |
||
507 | 624 | |
508 | 625 | |
509 | 626 | $this->all_tracked[$id]['lastupdate'] = time(); |
510 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
511 | - } 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"; |
|
627 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
628 | + $send = true; |
|
629 | + } |
|
630 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
631 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
632 | + } |
|
512 | 633 | //$this->del(); |
513 | 634 | |
514 | 635 | |
515 | 636 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
516 | 637 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
517 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
638 | + if ($globalDebug) { |
|
639 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
640 | + } |
|
518 | 641 | $MarineLive = new MarineLive($this->db); |
519 | 642 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
520 | 643 | $MarineLive->db = null; |
521 | 644 | //MarineLive->deleteLiveMarineData(); |
522 | - if ($globalDebug) echo " Done\n"; |
|
645 | + if ($globalDebug) { |
|
646 | + echo " Done\n"; |
|
647 | + } |
|
523 | 648 | } |
524 | 649 | $this->last_delete_hourly = time(); |
525 | 650 | } |
@@ -528,7 +653,9 @@ discard block |
||
528 | 653 | //$ignoreImport = false; |
529 | 654 | } |
530 | 655 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
531 | - if ($send) return $this->all_tracked[$id]; |
|
656 | + if ($send) { |
|
657 | + return $this->all_tracked[$id]; |
|
658 | + } |
|
532 | 659 | } |
533 | 660 | } |
534 | 661 | } |