@@ -118,8 +118,12 @@ discard block |
||
118 | 118 | { |
119 | 119 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
120 | 120 | $ident = $spotter_array[0]['ident']; |
121 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
122 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
121 | + if (isset($spotter_array[0]['latitude'])) { |
|
122 | + $latitude = $spotter_array[0]['latitude']; |
|
123 | + } |
|
124 | + if (isset($spotter_array[0]['longitude'])) { |
|
125 | + $longitude = $spotter_array[0]['longitude']; |
|
126 | + } |
|
123 | 127 | require_once('header.php'); |
124 | 128 | if (isset($globalArchive) && $globalArchive && $type == 'aircraft') { |
125 | 129 | // Requirement for altitude graph |
@@ -127,7 +131,9 @@ discard block |
||
127 | 131 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
128 | 132 | if (isset($globalTimezone)) { |
129 | 133 | date_default_timezone_set($globalTimezone); |
130 | - } else date_default_timezone_set('UTC'); |
|
134 | + } else { |
|
135 | + date_default_timezone_set('UTC'); |
|
136 | + } |
|
131 | 137 | if (is_array($all_data) && count($all_data) > 1) { |
132 | 138 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
133 | 139 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -204,14 +210,22 @@ discard block |
||
204 | 210 | if (isset($spotter_array[0]['airline_icao'])) { |
205 | 211 | print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; |
206 | 212 | } |
207 | - if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
213 | + if ($type == 'aircraft') { |
|
214 | + print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
|
215 | + } |
|
208 | 216 | print '</div>'; |
209 | 217 | |
210 | - if ($type == 'aircraft') include('ident-sub-menu.php'); |
|
218 | + if ($type == 'aircraft') { |
|
219 | + include('ident-sub-menu.php'); |
|
220 | + } |
|
211 | 221 | print '<div class="table column">'; |
212 | - if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
213 | - elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
214 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
222 | + if ($type == 'aircraft') { |
|
223 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
224 | + } elseif ($type == 'marine') { |
|
225 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
226 | + } elseif ($type == 'tracker') { |
|
227 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
228 | + } |
|
215 | 229 | |
216 | 230 | include('table-output.php'); |
217 | 231 | print '<div class="pagination">'; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | require_once('require/class.Language.php'); |
4 | 4 | require_once('require/class.Translation.php'); |
5 | 5 | $type = ''; |
6 | -$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
6 | +$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
7 | 7 | if (isset($_GET['marine'])) { |
8 | 8 | require_once('require/class.Marine.php'); |
9 | 9 | require_once('require/class.MarineLive.php'); |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | $page_url = $globalURL.'/ident/'.$_GET['ident']; |
31 | 31 | } |
32 | 32 | |
33 | -if (!isset($_GET['ident'])){ |
|
33 | +if (!isset($_GET['ident'])) { |
|
34 | 34 | header('Location: '.$globalURL.''); |
35 | 35 | } else { |
36 | 36 | $Translation = new Translation(); |
37 | 37 | //calculuation for the pagination |
38 | - if(!isset($_GET['limit'])) |
|
38 | + if (!isset($_GET['limit'])) |
|
39 | 39 | { |
40 | 40 | $limit_start = 0; |
41 | 41 | $limit_end = 25; |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | $limit_previous_1 = $limit_start - $absolute_difference; |
55 | 55 | $limit_previous_2 = $limit_end - $absolute_difference; |
56 | 56 | |
57 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
57 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
58 | 58 | if ($type == 'aircraft') { |
59 | 59 | if ($sort != '') |
60 | 60 | { |
61 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
61 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
62 | 62 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
63 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
63 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
66 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
67 | 67 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
68 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
68 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | if (empty($spotter_array)) { |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | $ident = $new_ident; |
75 | 75 | if ($sort != '') |
76 | 76 | { |
77 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
77 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
78 | 78 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
79 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
79 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
80 | 80 | } |
81 | 81 | } else { |
82 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
82 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
83 | 83 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
84 | - $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
84 | + $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -89,34 +89,34 @@ discard block |
||
89 | 89 | } elseif ($type == 'marine') { |
90 | 90 | if ($sort != '') |
91 | 91 | { |
92 | - $spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
92 | + $spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
93 | 93 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
94 | - $spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
94 | + $spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | - $spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
97 | + $spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
98 | 98 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
99 | - $spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
99 | + $spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } elseif ($type == 'tracker') { |
103 | 103 | if ($sort != '') |
104 | 104 | { |
105 | - $spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
105 | + $spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
106 | 106 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
107 | - $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
|
107 | + $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort); |
|
108 | 108 | } |
109 | 109 | } else { |
110 | - $spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
110 | + $spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
111 | 111 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
112 | - $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference); |
|
112 | + $spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | if (!empty($spotter_array)) |
118 | 118 | { |
119 | - $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
|
119 | + $title = sprintf(_("Detailed View for %s"), $spotter_array[0]['ident']); |
|
120 | 120 | $ident = $spotter_array[0]['ident']; |
121 | 121 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
122 | 122 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $altitude_data = ''; |
136 | 136 | $hour_data = ''; |
137 | 137 | $speed_data = ''; |
138 | - foreach($all_data as $data) |
|
138 | + foreach ($all_data as $data) |
|
139 | 139 | { |
140 | 140 | $hour_data .= '"'.$data['date'].'",'; |
141 | 141 | if (isset($data['real_altitude']) && $data['real_altitude'] != '') { |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | $speed_data .= $speed.','; |
164 | 164 | } |
165 | 165 | $hour_data = "['x',".substr($hour_data, 0, -1)."]"; |
166 | - $altitude_data = "['altitude',".substr($altitude_data,0,-1)."]"; |
|
167 | - $speed_data = "['speed',".substr($speed_data,0,-1)."]"; |
|
166 | + $altitude_data = "['altitude',".substr($altitude_data, 0, -1)."]"; |
|
167 | + $speed_data = "['speed',".substr($speed_data, 0, -1)."]"; |
|
168 | 168 | print 'c3.generate({ |
169 | 169 | bindto: "#chart", |
170 | 170 | data: { |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | if ($type == 'aircraft') include('ident-sub-menu.php'); |
210 | 210 | print '<div class="table column">'; |
211 | - if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
212 | - elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
213 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
211 | + if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
212 | + elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
213 | + elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
214 | 214 | |
215 | 215 | include('table-output.php'); |
216 | 216 | print '<div class="pagination">'; |
@@ -48,7 +48,7 @@ |
||
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | 50 | if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
51 | - //print_r($metar_parse); |
|
51 | + //print_r($metar_parse); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | $METAR = new METAR(); |
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
50 | + if (isset($metar_info[0]['metar'])) { |
|
51 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
52 | + } |
|
51 | 53 | //print_r($metar_parse); |
52 | 54 | } |
53 | 55 | |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | print '<option></option>'; |
62 | 64 | $Stats = new Stats(); |
63 | 65 | $airport_names = $Stats->getAllAirportNames(); |
64 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
66 | + if (empty($airport_names)) { |
|
67 | + $airport_names = $Spotter->getAllAirportNames(); |
|
68 | + } |
|
65 | 69 | ksort($airport_names); |
66 | 70 | foreach($airport_names as $airport_name) |
67 | 71 | { |
@@ -102,7 +106,9 @@ discard block |
||
102 | 106 | // Use spotter also |
103 | 107 | if (isset($globalTimezone)) { |
104 | 108 | date_default_timezone_set($globalTimezone); |
105 | - } else date_default_timezone_set('UTC'); |
|
109 | + } else { |
|
110 | + date_default_timezone_set('UTC'); |
|
111 | + } |
|
106 | 112 | if (count($all_data) > 0) { |
107 | 113 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
108 | 114 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -5,17 +5,17 @@ discard block |
||
5 | 5 | require_once('require/class.Stats.php'); |
6 | 6 | require_once('require/class.METAR.php'); |
7 | 7 | |
8 | -if (!isset($_GET['airport'])){ |
|
8 | +if (!isset($_GET['airport'])) { |
|
9 | 9 | header('Location: '.$globalURL.'/airport'); |
10 | 10 | } else { |
11 | 11 | $Spotter = new Spotter(); |
12 | 12 | //calculation for the pagination |
13 | - if(!isset($_GET['limit'])) |
|
13 | + if (!isset($_GET['limit'])) |
|
14 | 14 | { |
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | $limit_next = $limit_end + $absolute_difference; |
29 | 29 | $limit_previous_1 = $limit_start - $absolute_difference; |
30 | 30 | $limit_previous_2 = $limit_end - $absolute_difference; |
31 | - $airport_icao = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
|
31 | + $airport_icao = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
32 | 32 | $airport = $airport_icao; |
33 | 33 | $page_url = $globalURL.'/airport/'.$airport_icao; |
34 | 34 | |
35 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
35 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
36 | 36 | if ($sort != '') { |
37 | - $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, $sort); |
|
37 | + $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao, $limit_start.",".$absolute_difference, $sort); |
|
38 | 38 | } else { |
39 | - $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, ''); |
|
39 | + $spotter_array = $Spotter->getSpotterDataByAirport($airport_icao, $limit_start.",".$absolute_difference, ''); |
|
40 | 40 | } |
41 | 41 | $airport_array = $Spotter->getAllAirportInfo($airport_icao); |
42 | 42 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | //print_r($metar_parse); |
52 | 52 | } |
53 | 53 | |
54 | - $title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
|
54 | + $title = sprintf(_("Detailed View for %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']); |
|
55 | 55 | |
56 | 56 | require_once('header.php'); |
57 | 57 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $airport_names = $Stats->getAllAirportNames(); |
64 | 64 | if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
65 | 65 | ksort($airport_names); |
66 | - foreach($airport_names as $airport_name) |
|
66 | + foreach ($airport_names as $airport_name) |
|
67 | 67 | { |
68 | - if($airport_icao == $airport_name['airport_icao']) |
|
68 | + if ($airport_icao == $airport_name['airport_icao']) |
|
69 | 69 | { |
70 | 70 | print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>'; |
71 | 71 | } else { |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $date_data = ''; |
112 | 112 | $departure_data = ''; |
113 | 113 | $arrival_data = ''; |
114 | - foreach($all_data as $data) |
|
114 | + foreach ($all_data as $data) |
|
115 | 115 | { |
116 | 116 | $date_data .= '"'.$data['date'].'",'; |
117 | 117 | $departure_data .= $data['departure'].','; |
118 | 118 | $arrival_data .= $data['arrival'].','; |
119 | 119 | } |
120 | - $date_data = "['x',".substr($date_data,0,-1)."]"; |
|
121 | - $departure_data = "['departure',".substr($departure_data,0,-1)."]"; |
|
122 | - $arrival_data = "['arrival',".substr($arrival_data,0,-1)."]"; |
|
120 | + $date_data = "['x',".substr($date_data, 0, -1)."]"; |
|
121 | + $departure_data = "['departure',".substr($departure_data, 0, -1)."]"; |
|
122 | + $arrival_data = "['arrival',".substr($arrival_data, 0, -1)."]"; |
|
123 | 123 | print 'c3.generate({ |
124 | 124 | bindto: "#chart", |
125 | 125 | data: { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | print _("Dew point:").' '.$metar_parse['dew'].' °C'." - "; |
177 | 177 | } |
178 | 178 | if (isset($metar_parse['temperature']) && isset($metar_parse['dew'])) { |
179 | - $humidity = round(100 * pow((112 - (0.1 * $metar_parse['temperature']) + $metar_parse['dew']) / (112 + (0.9 * $metar_parse['temperature'])), 8),1); |
|
179 | + $humidity = round(100*pow((112 - (0.1*$metar_parse['temperature']) + $metar_parse['dew'])/(112 + (0.9*$metar_parse['temperature'])), 8), 1); |
|
180 | 180 | print _("Humidity:").' '.$humidity.'%'." - "; |
181 | 181 | } |
182 | 182 | if (isset($metar_parse['QNH'])) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | print '<div class="table column">'; |
193 | 193 | if ($airport_array[0]['iata'] != "NA") |
194 | 194 | { |
195 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>'; |
|
195 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>'; |
|
196 | 196 | } |
197 | 197 | include('table-output.php'); |
198 | 198 | print '<div class="pagination">'; |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
8 | 8 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
9 | 9 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
10 | 10 | |
11 | 11 | if (!empty($spotter_array)) |
12 | 12 | { |
13 | - $title = sprintf(_("Most Common Time of Day of aircraft with registration %s"),$registration); |
|
13 | + $title = sprintf(_("Most Common Time of Day of aircraft with registration %s"), $registration); |
|
14 | 14 | require_once('header.php'); |
15 | 15 | |
16 | 16 | print '<div class="info column">'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | include('registration-sub-menu.php'); |
24 | 24 | print '<div class="column">'; |
25 | 25 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
26 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day from aircraft with registration <strong>%s</strong>."),$registration).'</p>'; |
|
26 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day from aircraft with registration <strong>%s</strong>."), $registration).'</p>'; |
|
27 | 27 | |
28 | 28 | $hour_array = $Spotter->countAllHoursByRegistration($registration); |
29 | 29 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | $hour_data = ''; |
34 | 34 | $hour_cnt = ''; |
35 | 35 | $last = 0; |
36 | - foreach($hour_array as $hour_item) |
|
36 | + foreach ($hour_array as $hour_item) |
|
37 | 37 | { |
38 | - while($last != $hour_item['hour_name']) { |
|
38 | + while ($last != $hour_item['hour_name']) { |
|
39 | 39 | $hour_data .= '"'.$last.':00",'; |
40 | 40 | $hour_cnt .= '0,'; |
41 | 41 | $last++; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $hour_cnt .= $hour_item['hour_count'].','; |
46 | 46 | } |
47 | 47 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
48 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
48 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
49 | 49 | print 'c3.generate({ |
50 | 50 | bindto: "#chartHour", |
51 | 51 | data: { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | print '</thead>'; |
69 | 69 | print '<tbody>'; |
70 | 70 | $i = 1; |
71 | - foreach($hour_array as $hour_item) |
|
71 | + foreach ($hour_array as $hour_item) |
|
72 | 72 | { |
73 | 73 | print '<tr>'; |
74 | 74 | print '<td>'.$hour_item['hour_name'].':00</td>'; |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | 6 | $Spotter = new Spotter(); |
7 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
8 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
9 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
7 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
8 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
9 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
10 | 10 | |
11 | 11 | if (!empty($spotter_array)) |
12 | 12 | { |
13 | - $title = sprintf(_("Most Common Departure Airports on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | + $title = sprintf(_("Most Common Departure Airports on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
14 | 14 | |
15 | 15 | require_once('header.php'); |
16 | 16 | print '<div class="select-item">'; |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
29 | 29 | print '<br />'; |
30 | 30 | print '<div class="info column">'; |
31 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
32 | 32 | print '</div>'; |
33 | 33 | |
34 | 34 | include('date-sub-menu.php'); |
35 | 35 | print '<div class="column">'; |
36 | 36 | print '<h2>'._("Most Common Departure Airports").'</h2>'; |
37 | - print '<p>'.sprintf(_("The statistic below shows all departure airports of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | + print '<p>'.sprintf(_("The statistic below shows all departure airports of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
38 | 38 | $airport_airport_array = $Spotter->countAllDepartureAirportsByDate($date); |
39 | 39 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
40 | 40 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | print '<script>'; |
44 | 44 | print 'var series = ['; |
45 | 45 | $airport_data = ''; |
46 | - foreach($airport_airport_array as $airport_item) |
|
46 | + foreach ($airport_airport_array as $airport_item) |
|
47 | 47 | { |
48 | 48 | $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],'; |
49 | 49 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | print '</thead>'; |
99 | 99 | print '<tbody>'; |
100 | 100 | $i = 1; |
101 | - foreach($airport_airport_array as $airport_item) |
|
101 | + foreach ($airport_airport_array as $airport_item) |
|
102 | 102 | { |
103 | 103 | print '<tr>'; |
104 | 104 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | require_once('require/class.Spotter.php'); |
9 | 9 | require_once('require/class.Language.php'); |
10 | 10 | $Spotter = new Spotter(); |
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
12 | -$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING); |
|
13 | -$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | +$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING); |
|
13 | +$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING); |
|
14 | 14 | $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort); |
15 | 15 | |
16 | 16 | if (!empty($spotter_array)) |
17 | 17 | { |
18 | - $title = sprintf(_("Most Common Airlines by Country between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']); |
|
18 | + $title = sprintf(_("Most Common Airlines by Country between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']); |
|
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="info column">'; |
21 | 21 | print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>'; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | include('route-sub-menu.php'); |
27 | 27 | print '<div class="column">'; |
28 | 28 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
29 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>'; |
|
29 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>'; |
|
30 | 30 | |
31 | 31 | $airline_array = $Spotter->countAllAirlineCountriesByRoute($departure_airport, $arrival_airport); |
32 | 32 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
36 | 36 | print 'var series = ['; |
37 | 37 | $country_data = ''; |
38 | - foreach($airline_array as $airline_item) |
|
38 | + foreach ($airline_array as $airline_item) |
|
39 | 39 | { |
40 | 40 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
41 | 41 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | print '</thead>'; |
83 | 83 | print '<tbody>'; |
84 | 84 | $i = 1; |
85 | - foreach($airline_array as $airline_item) |
|
85 | + foreach ($airline_array as $airline_item) |
|
86 | 86 | { |
87 | 87 | print '<tr>'; |
88 | 88 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | require_once('header.php'); |
14 | 14 | print '<div class="select-item">'; |
15 | 15 | print '<form action="'.$globalURL.'/date" method="post" class="form-inline">'; |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
27 | 27 | print '<br />'; |
28 | 28 | print '<div class="info column">'; |
29 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
29 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | 30 | print '</div>'; |
31 | 31 | |
32 | 32 | include('date-sub-menu.php'); |
33 | 33 | print '<div class="column">'; |
34 | 34 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
35 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
35 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | 36 | |
37 | 37 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date); |
38 | 38 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
42 | 42 | print 'var series = ['; |
43 | 43 | $country_data = ''; |
44 | - foreach($airport_country_array as $airport_item) |
|
44 | + foreach ($airport_country_array as $airport_item) |
|
45 | 45 | { |
46 | 46 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
47 | 47 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | print '</thead>'; |
90 | 90 | print '<tbody>'; |
91 | 91 | $i = 1; |
92 | - foreach($airport_country_array as $airport_item) |
|
92 | + foreach ($airport_country_array as $airport_item) |
|
93 | 93 | { |
94 | 94 | print '<tr>'; |
95 | 95 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Time of Day on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Time of Day on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | require_once('header.php'); |
14 | 14 | print '<div class="select-item">'; |
15 | 15 | print '<form action="'.$globalURL.'/date" method="post" class="form-inline">'; |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
27 | 27 | print '<br />'; |
28 | 28 | print '<div class="info column">'; |
29 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
29 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | 30 | print '</div>'; |
31 | 31 | |
32 | 32 | include('date-sub-menu.php'); |
33 | 33 | print '<div class="column">'; |
34 | 34 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
35 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
35 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | 36 | |
37 | 37 | $hour_array = $Spotter->countAllHoursByDate($date); |
38 | 38 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | $hour_data = ''; |
43 | 43 | $hour_cnt = ''; |
44 | 44 | $last = 0; |
45 | - foreach($hour_array as $hour_item) |
|
45 | + foreach ($hour_array as $hour_item) |
|
46 | 46 | { |
47 | - while($last != $hour_item['hour_name']) { |
|
47 | + while ($last != $hour_item['hour_name']) { |
|
48 | 48 | $hour_data .= '"'.$last.':00",'; |
49 | 49 | $hour_cnt .= '0,'; |
50 | 50 | $last++; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $hour_cnt .= $hour_item['hour_count'].','; |
55 | 55 | } |
56 | 56 | $hour_data = "['x',".substr($hour_data, 0, -1)."]"; |
57 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
57 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
58 | 58 | print 'c3.generate({ |
59 | 59 | bindto: "#chartHour", |
60 | 60 | data: { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | print '</thead>'; |
80 | 80 | print '<tbody>'; |
81 | 81 | $i = 1; |
82 | - foreach($hour_array as $hour_item) |
|
82 | + foreach ($hour_array as $hour_item) |
|
83 | 83 | { |
84 | 84 | print '<tr>'; |
85 | 85 | print '<td>'.$hour_item['hour_name'].':00</td>'; |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Arrival Airports on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Arrival Airports on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | |
14 | 14 | require_once('header.php'); |
15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Arrival Airports").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | $airport_airport_array = $Spotter->countAllArrivalAirportsByDate($date); |
38 | 38 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
39 | 39 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | print '<script>'; |
43 | 43 | print 'var series = ['; |
44 | 44 | $airport_data = ''; |
45 | - foreach($airport_airport_array as $airport_item) |
|
45 | + foreach ($airport_airport_array as $airport_item) |
|
46 | 46 | { |
47 | 47 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
48 | 48 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | print '</thead>'; |
98 | 98 | print '<tbody>'; |
99 | 99 | $i = 1; |
100 | - foreach($airport_airport_array as $airport_item) |
|
100 | + foreach ($airport_airport_array as $airport_item) |
|
101 | 101 | { |
102 | 102 | print '<tr>'; |
103 | 103 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $title = _("Unknown Date"); |
123 | 123 | require_once('header.php'); |
124 | 124 | print '<h1>'._("Error").'</h1>'; |
125 | - print '<p>'._("Sorry, this date does not exist in this database. :(");'</p>'; |
|
125 | + print '<p>'._("Sorry, this date does not exist in this database. :("); '</p>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | require_once('footer.php'); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | 49 | $Tracker = new Tracker($this->db); |
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | 60 | if (isset($flight['lastupdate'])) { |
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
61 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
62 | 62 | if (isset($this->all_tracked[$key]['id'])) { |
63 | 63 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
64 | 64 | /* |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | //$real_arrival = $this->arrival($key); |
70 | 70 | $Tracker = new Tracker($this->db); |
71 | 71 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | - $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
|
72 | + $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']); |
|
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $send = false; |
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | - if(is_array($line) && isset($line['ident'])) { |
|
92 | + if (is_array($line) && isset($line['ident'])) { |
|
93 | 93 | //print_r($line); |
94 | 94 | if (isset($line['ident'])) { |
95 | 95 | |
@@ -113,33 +113,33 @@ discard block |
||
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | 115 | $this->all_tracked[$id] = array(); |
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '')); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
119 | 119 | if (!isset($line['id'])) { |
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
121 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
122 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
123 | 123 | if ($globalAllTracked !== FALSE) $dataFound = true; |
124 | 124 | } |
125 | 125 | |
126 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
126 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
127 | 127 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
128 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
129 | 129 | } else { |
130 | 130 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | 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]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | return ''; |
133 | 133 | } |
134 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
134 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
137 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
137 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
138 | 138 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
139 | 139 | return ''; |
140 | 140 | } elseif (!isset($line['datetime'])) { |
141 | 141 | date_default_timezone_set('UTC'); |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
143 | 143 | } else { |
144 | 144 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
145 | 145 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
151 | 151 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
152 | 152 | $timeelapsed = microtime(true); |
153 | 153 | $Tracker = new Tracker($this->db); |
154 | 154 | $fromsource = NULL; |
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
158 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
159 | 159 | } |
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
166 | 166 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
167 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
168 | 168 | if ($distance > 100 && $distance < 10000) { |
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
171 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
178 | 178 | else unset($timediff); |
179 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
179 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
180 | 180 | 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'])) { |
181 | - 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'],0.1)) { |
|
181 | + 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'], 0.1)) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
187 | 187 | $timeelapsed = microtime(true); |
188 | 188 | $Tracker = new Tracker($this->db); |
189 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
189 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
190 | 190 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
191 | 191 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | 195 | } |
@@ -197,75 +197,75 @@ discard block |
||
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
200 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
201 | 201 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 202 | $dataFound = true; |
203 | 203 | $this->all_tracked[$id]['time_last_coord'] = time(); |
204 | 204 | } |
205 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
205 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | 208 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
210 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
211 | 211 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 212 | $dataFound = true; |
213 | 213 | $this->all_tracked[$id]['time_last_coord'] = time(); |
214 | 214 | } |
215 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
215 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | } else if ($globalDebug && $timediff > 20) { |
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
223 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
222 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
223 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | 229 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
240 | 240 | //$dataFound = true; |
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
244 | 244 | //$dataFound = true; |
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 248 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
|
251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
249 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude'])); |
|
251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
252 | 252 | //$dataFound = true; |
253 | 253 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
264 | 264 | //$dataFound = true; |
265 | 265 | } 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']) { |
266 | - $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']); |
|
267 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | + $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']); |
|
267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
268 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | 269 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -273,54 +273,54 @@ discard block |
||
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | 274 | $this->all_tracked[$id]['lastupdate'] = time(); |
275 | 275 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | - 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'])) { |
|
276 | + 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'])) { |
|
277 | 277 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | 282 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 285 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | - $TrackerLive->db=null; |
|
288 | + $TrackerLive->db = null; |
|
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | 292 | } else { |
293 | 293 | $recent_ident = ''; |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
295 | 295 | } |
296 | 296 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | - if($recent_ident == "") |
|
297 | + if ($recent_ident == "") |
|
298 | 298 | { |
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | 301 | $highlight = ''; |
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | $Tracker = new Tracker($this->db); |
305 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
306 | 306 | $Tracker->db = null; |
307 | 307 | if ($globalDebug && isset($result)) echo $result."\n"; |
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | 311 | // Add source stat in DB |
312 | 312 | $Stats = new Stats($this->db); |
313 | 313 | if (!empty($this->stats)) { |
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
315 | + foreach ($this->stats as $date => $data) { |
|
316 | + foreach ($data as $source => $sourced) { |
|
317 | 317 | //print_r($sourced); |
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
318 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date); |
|
319 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date); |
|
320 | 320 | if (isset($sourced['msg'])) { |
321 | 321 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 322 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
323 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date); |
|
324 | 324 | unset($this->stats[$date][$source]['msg']); |
325 | 325 | } |
326 | 326 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 344 | $TrackerLive = new TrackerLive($this->db); |
345 | 345 | $TrackerLive->deleteLiveTrackerData(); |
346 | - $TrackerLive->db=null; |
|
346 | + $TrackerLive->db = null; |
|
347 | 347 | if ($globalDebug) echo " Done\n"; |
348 | 348 | $this->last_delete = time(); |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
354 | 354 | $Tracker = new Tracker($this->db); |
355 | - $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
355 | + $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | $ignoreImport = false; |
367 | 367 | |
368 | 368 | if (!$ignoreImport) { |
369 | - 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'])) { |
|
369 | + 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'])) { |
|
370 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
372 | 372 | $TrackerLive = new TrackerLive($this->db); |
373 | - $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
373 | + $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
374 | 374 | $TrackerLive->db = null; |
375 | 375 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
377 | 377 | |
378 | 378 | // Put statistics in $this->stats variable |
379 | 379 | |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | $latitude = $globalCenterLatitude; |
391 | 391 | $longitude = $globalCenterLongitude; |
392 | 392 | } |
393 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
393 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
394 | 394 | } else { |
395 | 395 | $latitude = $this->source_location[$source]['latitude']; |
396 | 396 | $longitude = $this->source_location[$source]['longitude']; |
397 | 397 | } |
398 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
398 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
399 | 399 | //$stats_heading = $stats_heading%22.5; |
400 | 400 | $stats_heading = round($stats_heading/22.5); |
401 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
401 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
402 | 402 | $current_date = date('Y-m-d'); |
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | - for ($i=0;$i<=15;$i++) { |
|
405 | + for ($i = 0; $i <= 15; $i++) { |
|
406 | 406 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 419 | end($this->stats[$current_date][$source]['hist']); |
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
421 | 421 | } else $mini = 0; |
422 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
422 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
423 | 423 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
433 | 433 | if ($globalDebug) echo $result."\n"; |
434 | - } 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"; |
|
434 | + } 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"; |
|
435 | 435 | //$this->del(); |
436 | 436 | |
437 | 437 |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | require_once(dirname(__FILE__).'/class.Source.php'); |
8 | 8 | |
9 | 9 | class TrackerImport { |
10 | - private $all_tracked = array(); |
|
11 | - private $last_delete_hourly = 0; |
|
12 | - private $last_delete = 0; |
|
13 | - private $stats = array(); |
|
14 | - private $tmd = 0; |
|
15 | - private $source_location = array(); |
|
16 | - public $db = null; |
|
17 | - public $nb = 0; |
|
10 | + private $all_tracked = array(); |
|
11 | + private $last_delete_hourly = 0; |
|
12 | + private $last_delete = 0; |
|
13 | + private $stats = array(); |
|
14 | + private $tmd = 0; |
|
15 | + private $source_location = array(); |
|
16 | + public $db = null; |
|
17 | + public $nb = 0; |
|
18 | 18 | |
19 | - public function __construct($dbc = null) { |
|
19 | + public function __construct($dbc = null) { |
|
20 | 20 | global $globalBeta; |
21 | 21 | $Connection = new Connection($dbc); |
22 | 22 | $this->db = $Connection->db(); |
@@ -38,50 +38,50 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | */ |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function checkAll() { |
|
43 | + public function checkAll() { |
|
44 | 44 | global $globalDebug; |
45 | 45 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
46 | 46 | foreach ($this->all_tracked as $key => $flight) { |
47 | - if (isset($this->all_tracked[$key]['id'])) { |
|
47 | + if (isset($this->all_tracked[$key]['id'])) { |
|
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | - $Tracker = new Tracker($this->db); |
|
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | - } |
|
49 | + $Tracker = new Tracker($this->db); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | + } |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | - public function del() { |
|
55 | + public function del() { |
|
56 | 56 | global $globalDebug; |
57 | 57 | // Delete old infos |
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | - if (isset($flight['lastupdate'])) { |
|
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | - if (isset($this->all_tracked[$key]['id'])) { |
|
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
60 | + if (isset($flight['lastupdate'])) { |
|
61 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | + if (isset($this->all_tracked[$key]['id'])) { |
|
63 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
64 | 64 | /* |
65 | 65 | $TrackerLive = new TrackerLive(); |
66 | 66 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
67 | 67 | $TrackerLive->db = null; |
68 | 68 | */ |
69 | - //$real_arrival = $this->arrival($key); |
|
70 | - $Tracker = new Tracker($this->db); |
|
71 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
69 | + //$real_arrival = $this->arrival($key); |
|
70 | + $Tracker = new Tracker($this->db); |
|
71 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
72 | 72 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
76 | 76 | // $Tracker->db = null; |
77 | - } |
|
78 | - unset($this->all_tracked[$key]); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
77 | + } |
|
78 | + unset($this->all_tracked[$key]); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function add($line) { |
|
84 | + public function add($line) { |
|
85 | 85 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | 86 | if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
87 | 87 | date_default_timezone_set('UTC'); |
@@ -90,47 +90,47 @@ discard block |
||
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | 92 | if(is_array($line) && isset($line['ident'])) { |
93 | - //print_r($line); |
|
94 | - if (isset($line['ident'])) { |
|
93 | + //print_r($line); |
|
94 | + if (isset($line['ident'])) { |
|
95 | 95 | |
96 | 96 | |
97 | 97 | // Increment message number |
98 | 98 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | - $current_date = date('Y-m-d'); |
|
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
99 | + $current_date = date('Y-m-d'); |
|
100 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | + else $source = ''; |
|
102 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | 110 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
111 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | + else $id = trim($line['id']); |
|
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | - $this->all_tracked[$id] = array(); |
|
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | - if (!isset($line['id'])) { |
|
115 | + $this->all_tracked[$id] = array(); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | + if (!isset($line['id'])) { |
|
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | 121 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
122 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
127 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | 128 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | - } else { |
|
129 | + } else { |
|
130 | 130 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | 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]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | return ''; |
133 | - } |
|
133 | + } |
|
134 | 134 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
152 | 152 | $timeelapsed = microtime(true); |
153 | - $Tracker = new Tracker($this->db); |
|
154 | - $fromsource = NULL; |
|
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
153 | + $Tracker = new Tracker($this->db); |
|
154 | + $fromsource = NULL; |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | 158 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
159 | - } |
|
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | + } |
|
160 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
166 | 166 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | - if ($distance > 100 && $distance < 10000) { |
|
167 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | + if ($distance > 100 && $distance < 10000) { |
|
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | 171 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | - } |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
179 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
176 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | + else unset($timediff); |
|
179 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
180 | 180 | 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'])) { |
181 | - 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'],0.1)) { |
|
181 | + 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'],0.1)) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -192,30 +192,30 @@ discard block |
||
192 | 192 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | - } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | 200 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | - $dataFound = true; |
|
203 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
201 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | + $dataFound = true; |
|
203 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
204 | 204 | } |
205 | 205 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
208 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | 210 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | - $dataFound = true; |
|
213 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
211 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | + $dataFound = true; |
|
213 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
214 | 214 | } |
215 | 215 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
216 | 216 | } |
217 | 217 | |
218 | - } else if ($globalDebug && $timediff > 20) { |
|
218 | + } else if ($globalDebug && $timediff > 20) { |
|
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
@@ -223,131 +223,131 @@ discard block |
||
223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | - } |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
229 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | - //$dataFound = true; |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | + //$dataFound = true; |
|
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | - //$dataFound = true; |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | + //$dataFound = true; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
248 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
249 | 249 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 252 | //$dataFound = true; |
253 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
253 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | - //$dataFound = true; |
|
261 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | + //$dataFound = true; |
|
265 | 265 | } 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']) { |
266 | - $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']); |
|
267 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
266 | + $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']); |
|
267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 272 | |
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | - 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'])) { |
|
277 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
274 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | + 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'])) { |
|
277 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
282 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | 288 | $TrackerLive->db=null; |
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | - } else { |
|
292 | + } else { |
|
293 | 293 | $recent_ident = ''; |
294 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
295 | - } |
|
296 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | - if($recent_ident == "") |
|
298 | - { |
|
295 | + } |
|
296 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | + if($recent_ident == "") |
|
298 | + { |
|
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | - $highlight = ''; |
|
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | - $timeelapsed = microtime(true); |
|
304 | - $Tracker = new Tracker($this->db); |
|
305 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | - $Tracker->db = null; |
|
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + $highlight = ''; |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | + $timeelapsed = microtime(true); |
|
304 | + $Tracker = new Tracker($this->db); |
|
305 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | + $Tracker->db = null; |
|
307 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | - // Add source stat in DB |
|
312 | - $Stats = new Stats($this->db); |
|
313 | - if (!empty($this->stats)) { |
|
311 | + // Add source stat in DB |
|
312 | + $Stats = new Stats($this->db); |
|
313 | + if (!empty($this->stats)) { |
|
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
317 | - //print_r($sourced); |
|
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | - if (isset($sourced['msg'])) { |
|
321 | - if (time() - $sourced['msg']['date'] > 10) { |
|
322 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | - unset($this->stats[$date][$source]['msg']); |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - if ($date != date('Y-m-d')) { |
|
329 | - unset($this->stats[$date]); |
|
330 | - } |
|
331 | - } |
|
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
315 | + foreach($this->stats as $date => $data) { |
|
316 | + foreach($data as $source => $sourced) { |
|
317 | + //print_r($sourced); |
|
318 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | + if (isset($sourced['msg'])) { |
|
321 | + if (time() - $sourced['msg']['date'] > 10) { |
|
322 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | + echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | + unset($this->stats[$date][$source]['msg']); |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + if ($date != date('Y-m-d')) { |
|
329 | + unset($this->stats[$date]); |
|
330 | + } |
|
331 | + } |
|
332 | + if ($globalDebug) echo 'Done'."\n"; |
|
333 | 333 | |
334 | - } |
|
335 | - $Stats->db = null; |
|
334 | + } |
|
335 | + $Stats->db = null; |
|
336 | 336 | |
337 | - $this->del(); |
|
337 | + $this->del(); |
|
338 | 338 | //$ignoreImport = false; |
339 | 339 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 340 | //print_r($this->all_tracked[$id]); |
341 | 341 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | - $TrackerLive = new TrackerLive($this->db); |
|
345 | - $TrackerLive->deleteLiveTrackerData(); |
|
346 | - $TrackerLive->db=null; |
|
347 | - if ($globalDebug) echo " Done\n"; |
|
348 | - $this->last_delete = time(); |
|
342 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | + $TrackerLive = new TrackerLive($this->db); |
|
345 | + $TrackerLive->deleteLiveTrackerData(); |
|
346 | + $TrackerLive->db=null; |
|
347 | + if ($globalDebug) echo " Done\n"; |
|
348 | + $this->last_delete = time(); |
|
349 | 349 | } |
350 | - } else { |
|
350 | + } else { |
|
351 | 351 | $this->all_tracked[$id]['id'] = $recent_ident; |
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | - } |
|
362 | - //adds the spotter LIVE data |
|
363 | - if ($globalDebug) { |
|
361 | + } |
|
362 | + //adds the spotter LIVE data |
|
363 | + if ($globalDebug) { |
|
364 | 364 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
365 | - } |
|
366 | - $ignoreImport = false; |
|
365 | + } |
|
366 | + $ignoreImport = false; |
|
367 | 367 | |
368 | - if (!$ignoreImport) { |
|
368 | + if (!$ignoreImport) { |
|
369 | 369 | 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'])) { |
370 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 405 | for ($i=0;$i<=15;$i++) { |
406 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
406 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
409 | 409 | } else { |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | //var_dump($this->stats); |
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | - end($this->stats[$current_date][$source]['hist']); |
|
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
419 | + end($this->stats[$current_date][$source]['hist']); |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
421 | 421 | } else $mini = 0; |
422 | 422 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
423 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
426 | 426 | } else { |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | |
437 | 437 | |
438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | - $TrackerLive = new TrackerLive($this->db); |
|
441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | - $TrackerLive->db = null; |
|
443 | - //TrackerLive->deleteLiveTrackerData(); |
|
444 | - if ($globalDebug) echo " Done\n"; |
|
445 | - $this->last_delete_hourly = time(); |
|
439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | + $TrackerLive = new TrackerLive($this->db); |
|
441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | + $TrackerLive->db = null; |
|
443 | + //TrackerLive->deleteLiveTrackerData(); |
|
444 | + if ($globalDebug) echo " Done\n"; |
|
445 | + $this->last_delete_hourly = time(); |
|
446 | 446 | } |
447 | 447 | |
448 | - } |
|
449 | - //$ignoreImport = false; |
|
448 | + } |
|
449 | + //$ignoreImport = false; |
|
450 | 450 | } |
451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | 452 | if ($send) return $this->all_tracked[$id]; |
453 | - } |
|
453 | + } |
|
454 | + } |
|
454 | 455 | } |
455 | - } |
|
456 | 456 | } |
457 | 457 | ?> |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | public function checkAll() { |
44 | 44 | global $globalDebug; |
45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
45 | + if ($globalDebug) { |
|
46 | + echo "Update last seen tracked data...\n"; |
|
47 | + } |
|
46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
55 | 57 | public function del() { |
56 | 58 | global $globalDebug; |
57 | 59 | // Delete old infos |
58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
60 | + if ($globalDebug) { |
|
61 | + echo 'Delete old values and update latest data...'."\n"; |
|
62 | + } |
|
59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
60 | 64 | if (isset($flight['lastupdate'])) { |
61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
67 | + if ($globalDebug) { |
|
68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + } |
|
64 | 70 | /* |
65 | 71 | $TrackerLive = new TrackerLive(); |
66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | $Tracker = new Tracker($this->db); |
71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
79 | + if ($globalDebug && $result != 'success') { |
|
80 | + echo '!!! ERROR : '.$result."\n"; |
|
81 | + } |
|
74 | 82 | } |
75 | 83 | // Put in archive |
76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
83 | 91 | |
84 | 92 | public function add($line) { |
85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
95 | + $globalCoordMinChangeTracker = '0.015'; |
|
96 | + } |
|
87 | 97 | date_default_timezone_set('UTC'); |
88 | 98 | $dataFound = false; |
89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
97 | 107 | // Increment message number |
98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | 109 | $current_date = date('Y-m-d'); |
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
110 | + if (isset($line['source_name'])) { |
|
111 | + $source = $line['source_name']; |
|
112 | + } else { |
|
113 | + $source = ''; |
|
114 | + } |
|
115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
116 | + $source = $line['format_source']; |
|
117 | + } |
|
103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
121 | + } else { |
|
122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
123 | + } |
|
107 | 124 | } |
108 | 125 | |
109 | 126 | |
110 | 127 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
128 | + if (!isset($line['id'])) { |
|
129 | + $id = trim($line['ident']); |
|
130 | + } else { |
|
131 | + $id = trim($line['id']); |
|
132 | + } |
|
113 | 133 | |
114 | 134 | if (!isset($this->all_tracked[$id])) { |
115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
119 | 139 | if (!isset($line['id'])) { |
120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
140 | + if (!isset($globalDaemon)) { |
|
141 | + $globalDaemon = TRUE; |
|
142 | + } |
|
121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
144 | + } else { |
|
145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
146 | + } |
|
147 | + if ($globalAllTracked !== FALSE) { |
|
148 | + $dataFound = true; |
|
149 | + } |
|
124 | 150 | } |
125 | 151 | |
126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | 155 | } else { |
130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
131 | - 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]['ident']." - format : ".$line['format_source']."\n"; |
|
156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
160 | + } |
|
132 | 161 | return ''; |
133 | 162 | } |
134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
166 | + } |
|
136 | 167 | return ''; |
137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
171 | + } |
|
139 | 172 | return ''; |
140 | 173 | } elseif (!isset($line['datetime'])) { |
141 | 174 | date_default_timezone_set('UTC'); |
142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
143 | 176 | } else { |
144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
177 | + if ($globalDebug) { |
|
178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
179 | + } |
|
145 | 180 | return ''; |
146 | 181 | } |
147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
153 | 188 | $Tracker = new Tracker($this->db); |
154 | 189 | $fromsource = NULL; |
155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
191 | + if ($globalDebug && $result != 'success') { |
|
192 | + echo '!!! ERROR : '.$result."\n"; |
|
193 | + } |
|
157 | 194 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
195 | + if ($globalDebugTimeElapsed) { |
|
196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
197 | + } |
|
198 | + } |
|
199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | 201 | } |
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 202 | } |
162 | 203 | |
163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
168 | 209 | if ($distance > 100 && $distance < 10000) { |
169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 211 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
212 | + if ($speed < 1000) { |
|
213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
214 | + } |
|
215 | + if ($globalDebug) { |
|
216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
217 | + } |
|
173 | 218 | } |
174 | 219 | } |
175 | 220 | |
176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
224 | + } else { |
|
225 | + unset($timediff); |
|
226 | + } |
|
179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
180 | 228 | 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'])) { |
181 | 229 | 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'],0.1)) { |
@@ -183,20 +231,30 @@ discard block |
||
183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
185 | 233 | |
186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
234 | + if ($globalDebug) { |
|
235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
236 | + } |
|
187 | 237 | $timeelapsed = microtime(true); |
188 | 238 | $Tracker = new Tracker($this->db); |
189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
240 | + if (!empty($all_country)) { |
|
241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
242 | + } |
|
191 | 243 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
244 | + if ($globalDebugTimeElapsed) { |
|
245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
246 | + } |
|
193 | 247 | $this->tmd = 0; |
194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
250 | + } |
|
195 | 251 | } |
196 | 252 | } |
197 | 253 | |
198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
257 | + } |
|
200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 264 | } |
207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
266 | + if ($line['longitude'] > 180) { |
|
267 | + $line['longitude'] = $line['longitude'] - 360; |
|
268 | + } |
|
269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
271 | + } |
|
210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
226 | 288 | } |
227 | 289 | } |
228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
292 | + $dataFound = true; |
|
293 | + } |
|
230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
231 | 295 | } |
232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
246 | 310 | |
247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
315 | + } |
|
250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
258 | 324 | } |
259 | 325 | |
260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
329 | + } |
|
262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
264 | 332 | //$dataFound = true; |
265 | 333 | } 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']) { |
266 | 334 | $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']); |
267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
341 | + } |
|
270 | 342 | } |
271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | 348 | 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'])) { |
277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
350 | + if ($globalDebug) { |
|
351 | + echo "Check if aircraft is already in DB..."; |
|
352 | + } |
|
279 | 353 | $timeelapsed = microtime(true); |
280 | 354 | $TrackerLive = new TrackerLive($this->db); |
281 | 355 | if (isset($line['id'])) { |
282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
357 | + if ($globalDebugTimeElapsed) { |
|
358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + } |
|
284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | - } else $recent_ident = ''; |
|
362 | + if ($globalDebugTimeElapsed) { |
|
363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
364 | + } |
|
365 | + } else { |
|
366 | + $recent_ident = ''; |
|
367 | + } |
|
288 | 368 | $TrackerLive->db=null; |
289 | 369 | |
290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
370 | + if ($globalDebug && $recent_ident == '') { |
|
371 | + echo " Not in DB.\n"; |
|
372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
373 | + echo " Already in DB.\n"; |
|
374 | + } |
|
292 | 375 | } else { |
293 | 376 | $recent_ident = ''; |
294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | 380 | if($recent_ident == "") |
298 | 381 | { |
299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
382 | + if ($globalDebug) { |
|
383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
384 | + } |
|
300 | 385 | //adds the spotter data for the archive |
301 | 386 | $highlight = ''; |
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
389 | + } |
|
303 | 390 | $timeelapsed = microtime(true); |
304 | 391 | $Tracker = new Tracker($this->db); |
305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
306 | 393 | $Tracker->db = null; |
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
394 | + if ($globalDebug && isset($result)) { |
|
395 | + echo $result."\n"; |
|
396 | + } |
|
397 | + if ($globalDebugTimeElapsed) { |
|
398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + } |
|
309 | 400 | |
310 | 401 | |
311 | 402 | // Add source stat in DB |
312 | 403 | $Stats = new Stats($this->db); |
313 | 404 | if (!empty($this->stats)) { |
314 | - if ($globalDebug) echo 'Add source stats : '; |
|
405 | + if ($globalDebug) { |
|
406 | + echo 'Add source stats : '; |
|
407 | + } |
|
315 | 408 | foreach($this->stats as $date => $data) { |
316 | 409 | foreach($data as $source => $sourced) { |
317 | 410 | //print_r($sourced); |
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
411 | + if (isset($sourced['polar'])) { |
|
412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
413 | + } |
|
414 | + if (isset($sourced['hist'])) { |
|
415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
416 | + } |
|
320 | 417 | if (isset($sourced['msg'])) { |
321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
329 | 426 | unset($this->stats[$date]); |
330 | 427 | } |
331 | 428 | } |
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
429 | + if ($globalDebug) { |
|
430 | + echo 'Done'."\n"; |
|
431 | + } |
|
333 | 432 | |
334 | 433 | } |
335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 439 | //print_r($this->all_tracked[$id]); |
341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
441 | + if ($globalDebug) { |
|
442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
443 | + } |
|
343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 445 | $TrackerLive = new TrackerLive($this->db); |
345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
346 | 447 | $TrackerLive->db=null; |
347 | - if ($globalDebug) echo " Done\n"; |
|
448 | + if ($globalDebug) { |
|
449 | + echo " Done\n"; |
|
450 | + } |
|
348 | 451 | $this->last_delete = time(); |
349 | 452 | } |
350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
367 | 470 | |
368 | 471 | if (!$ignoreImport) { |
369 | 472 | 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'])) { |
370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
473 | + if ($globalDebug) { |
|
474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
475 | + } |
|
371 | 476 | $timeelapsed = microtime(true); |
372 | 477 | $TrackerLive = new TrackerLive($this->db); |
373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
374 | 479 | $TrackerLive->db = null; |
375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
481 | + if ($globalDebugTimeElapsed) { |
|
482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
483 | + } |
|
377 | 484 | |
378 | 485 | // Put statistics in $this->stats variable |
379 | 486 | |
380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
489 | + if ($source == '') { |
|
490 | + $source = $this->all_tracked[$id]['format_source']; |
|
491 | + } |
|
383 | 492 | if (!isset($this->source_location[$source])) { |
384 | 493 | $Location = new Source($this->db); |
385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
400 | 509 | $stats_heading = round($stats_heading/22.5); |
401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
402 | 511 | $current_date = date('Y-m-d'); |
403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
512 | + if ($stats_heading == 16) { |
|
513 | + $stats_heading = 0; |
|
514 | + } |
|
404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 516 | for ($i=0;$i<=15;$i++) { |
406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 530 | end($this->stats[$current_date][$source]['hist']); |
420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
421 | - } else $mini = 0; |
|
532 | + } else { |
|
533 | + $mini = 0; |
|
534 | + } |
|
422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
429 | 542 | } |
430 | 543 | |
431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
433 | - if ($globalDebug) echo $result."\n"; |
|
434 | - } 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"; |
|
545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
546 | + $send = true; |
|
547 | + } |
|
548 | + if ($globalDebug) { |
|
549 | + echo $result."\n"; |
|
550 | + } |
|
551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
553 | + } |
|
435 | 554 | //$this->del(); |
436 | 555 | |
437 | 556 | |
438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
558 | + if ($globalDebug) { |
|
559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
560 | + } |
|
440 | 561 | $TrackerLive = new TrackerLive($this->db); |
441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
442 | 563 | $TrackerLive->db = null; |
443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
444 | - if ($globalDebug) echo " Done\n"; |
|
565 | + if ($globalDebug) { |
|
566 | + echo " Done\n"; |
|
567 | + } |
|
445 | 568 | $this->last_delete_hourly = time(); |
446 | 569 | } |
447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
449 | 572 | //$ignoreImport = false; |
450 | 573 | } |
451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | - if ($send) return $this->all_tracked[$id]; |
|
575 | + if ($send) { |
|
576 | + return $this->all_tracked[$id]; |
|
577 | + } |
|
453 | 578 | } |
454 | 579 | } |
455 | 580 | } |