@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | 51 | $Marine = new Marine($this->db); |
52 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
52 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | 62 | if (isset($flight['lastupdate'])) { |
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //$real_arrival = $this->arrival($key); |
72 | 72 | $Marine = new Marine($this->db); |
73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']); |
|
74 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']); |
|
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $send = false; |
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | - if(is_array($line) && isset($line['mmsi'])) { |
|
94 | + if (is_array($line) && isset($line['mmsi'])) { |
|
95 | 95 | //print_r($line); |
96 | 96 | if (isset($line['mmsi'])) { |
97 | 97 | |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | 116 | $this->all_tracked[$id] = array(); |
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','type' => '','status' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'type' => '', 'status' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
120 | 120 | if (!isset($line['id'])) { |
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
122 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
124 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
125 | 125 | } |
126 | 126 | |
127 | 127 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
128 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
128 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
129 | 129 | $Marine = new Marine($this->db); |
130 | 130 | $identity = $Marine->getIdentity($line['mmsi']); |
131 | 131 | if (!empty($identity)) { |
@@ -140,38 +140,38 @@ discard block |
||
140 | 140 | |
141 | 141 | //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'])) { |
142 | 142 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
144 | 144 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
145 | 145 | $timeelapsed = microtime(true); |
146 | 146 | $Marine = new Marine($this->db); |
147 | 147 | $fromsource = NULL; |
148 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
148 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
149 | 149 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
150 | 150 | $Marine->db = null; |
151 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
151 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
152 | 152 | } |
153 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (isset($line['speed']) && $line['speed'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
159 | 159 | } 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'])) { |
160 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
160 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
161 | 161 | if ($distance > 1000 && $distance < 10000) { |
162 | 162 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
163 | 163 | $speed = $speed*3.6; |
164 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
164 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
165 | 165 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
170 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
171 | 171 | else unset($timediff); |
172 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
172 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
173 | 173 | 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'])) { |
174 | - 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'])) { |
|
174 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
175 | 175 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
176 | 176 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
177 | 177 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
180 | 180 | $timeelapsed = microtime(true); |
181 | 181 | $Marine = new Marine($this->db); |
182 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
182 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
183 | 183 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
184 | 184 | $Marine->db = null; |
185 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
185 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
186 | 186 | $this->tmd = 0; |
187 | 187 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
188 | 188 | } |
@@ -190,66 +190,66 @@ discard block |
||
190 | 190 | |
191 | 191 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
192 | 192 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
193 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
193 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
194 | 194 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
195 | 195 | $dataFound = true; |
196 | 196 | $this->all_tracked[$id]['time_last_coord'] = time(); |
197 | 197 | } |
198 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
198 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
199 | 199 | } |
200 | 200 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
201 | 201 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
202 | 202 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
203 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
203 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
204 | 204 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
205 | 205 | $dataFound = true; |
206 | 206 | $this->all_tracked[$id]['time_last_coord'] = time(); |
207 | 207 | } |
208 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
208 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | } else if ($globalDebug && $timediff > 20) { |
212 | 212 | $this->tmd = $this->tmd + 1; |
213 | 213 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
214 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
215 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
214 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
215 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
216 | 216 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
217 | 217 | } |
218 | 218 | } |
219 | 219 | if (isset($line['last_update']) && $line['last_update'] != '') { |
220 | 220 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
222 | 222 | } |
223 | 223 | if (isset($line['format_source']) && $line['format_source'] != '') { |
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
225 | 225 | } |
226 | 226 | if (isset($line['source_name']) && $line['source_name'] != '') { |
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['status']) && $line['status'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
234 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
234 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | if (isset($line['heading']) && $line['heading'] != '') { |
238 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
240 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
238 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
240 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
241 | 241 | //$dataFound = true; |
242 | 242 | } 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']) { |
243 | - $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']); |
|
244 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
245 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
243 | + $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']); |
|
244 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
245 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
246 | 246 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
247 | 247 | } |
248 | 248 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
249 | 249 | |
250 | 250 | if (isset($line['datetime'])) { |
251 | 251 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
253 | 253 | } else { |
254 | 254 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
255 | 255 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -257,48 +257,48 @@ discard block |
||
257 | 257 | } |
258 | 258 | } else { |
259 | 259 | date_default_timezone_set('UTC'); |
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
264 | 264 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
265 | 265 | $this->all_tracked[$id]['lastupdate'] = time(); |
266 | 266 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
267 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
267 | + 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'])) { |
|
268 | 268 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
269 | 269 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
270 | 270 | $timeelapsed = microtime(true); |
271 | 271 | $MarineLive = new MarineLive($this->db); |
272 | 272 | if (isset($line['id'])) { |
273 | 273 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
274 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
274 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
275 | 275 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
276 | 276 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
277 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
277 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
278 | 278 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
279 | 279 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
280 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
280 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
281 | 281 | } else $recent_ident = ''; |
282 | - $MarineLive->db=null; |
|
282 | + $MarineLive->db = null; |
|
283 | 283 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
284 | 284 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
285 | 285 | } else { |
286 | 286 | $recent_ident = ''; |
287 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
287 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
288 | 288 | } |
289 | 289 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
290 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
290 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
291 | 291 | { |
292 | 292 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
293 | 293 | //adds the spotter data for the archive |
294 | 294 | $highlight = ''; |
295 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
295 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
296 | 296 | $timeelapsed = microtime(true); |
297 | 297 | $Marine = new Marine($this->db); |
298 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
298 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
299 | 299 | $Marine->db = null; |
300 | 300 | if ($globalDebug && isset($result)) echo $result."\n"; |
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
302 | 302 | |
303 | 303 | /* |
304 | 304 | // Add source stat in DB |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
337 | 337 | $MarineLive = new MarineLive($this->db); |
338 | 338 | $MarineLive->deleteLiveMarineData(); |
339 | - $MarineLive->db=null; |
|
339 | + $MarineLive->db = null; |
|
340 | 340 | if ($globalDebug) echo " Done\n"; |
341 | 341 | $this->last_delete = time(); |
342 | 342 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $this->all_tracked[$id]['addedMarine'] = 1; |
346 | 346 | if (isset($globalDaemon) && !$globalDaemon) { |
347 | 347 | $Marine = new Marine($this->db); |
348 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
348 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
349 | 349 | $Marine->db = null; |
350 | 350 | } |
351 | 351 | |
@@ -359,14 +359,14 @@ discard block |
||
359 | 359 | $ignoreImport = false; |
360 | 360 | |
361 | 361 | if (!$ignoreImport) { |
362 | - 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'])) { |
|
362 | + 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'])) { |
|
363 | 363 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
364 | 364 | $timeelapsed = microtime(true); |
365 | 365 | $MarineLive = new MarineLive($this->db); |
366 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
366 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
367 | 367 | $MarineLive->db = null; |
368 | 368 | $this->all_tracked[$id]['putinarchive'] = false; |
369 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
369 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
370 | 370 | |
371 | 371 | // Put statistics in $this->stats variable |
372 | 372 | /* |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $this->all_tracked[$id]['lastupdate'] = time(); |
426 | 426 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
427 | 427 | if ($globalDebug) echo $result."\n"; |
428 | - } 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"; |
|
428 | + } 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"; |
|
429 | 429 | //$this->del(); |
430 | 430 | |
431 | 431 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_query = "SELECT tracker_output.* FROM tracker_output"; |
6 | 6 | |
7 | -class Tracker{ |
|
7 | +class Tracker { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -18,33 +18,33 @@ discard block |
||
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | 20 | |
21 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
21 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
23 | 23 | $filters = array(); |
24 | 24 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
25 | 25 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
26 | 26 | $filters = $globalStatsFilters[$globalFilterName]; |
27 | 27 | } else { |
28 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
28 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | if (isset($filter[0]['source'])) { |
32 | - $filters = array_merge($filters,$filter); |
|
32 | + $filters = array_merge($filters, $filter); |
|
33 | 33 | } |
34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
34 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
35 | 35 | $filter_query_join = ''; |
36 | 36 | $filter_query_where = ''; |
37 | - foreach($filters as $flt) { |
|
37 | + foreach ($filters as $flt) { |
|
38 | 38 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($filter['source']) && !empty($filter['source'])) { |
47 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
47 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
48 | 48 | } |
49 | 49 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
50 | 50 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
74 | 74 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
75 | 75 | if ($filter_query_where != '') { |
76 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
76 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
77 | 77 | } |
78 | 78 | $filter_query = $filter_query_join.$filter_query_where; |
79 | 79 | return $filter_query; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return Array the spotter information |
89 | 89 | * |
90 | 90 | */ |
91 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
91 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
94 | 94 | if (!is_string($query)) |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $sth = $this->db->prepare($query.$limitQuery); |
109 | 109 | $sth->execute($params); |
110 | 110 | } catch (PDOException $e) { |
111 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
111 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
112 | 112 | exit(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $num_rows = 0; |
116 | 116 | $spotter_array = array(); |
117 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
118 | 118 | { |
119 | 119 | $num_rows++; |
120 | 120 | $temp_array = array(); |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | { |
171 | 171 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
172 | 172 | } else { |
173 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
173 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
174 | 174 | } |
175 | 175 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
176 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
177 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
176 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
177 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
178 | 178 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
179 | 179 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
180 | 180 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
181 | 181 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
182 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
183 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
182 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
183 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
184 | 184 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
185 | 185 | } |
186 | 186 | } |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | { |
218 | 218 | $limit_array = explode(",", $limit); |
219 | 219 | |
220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
220 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
221 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
222 | 222 | |
223 | 223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
224 | 224 | { |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
236 | 236 | } |
237 | 237 | |
238 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
238 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
239 | 239 | |
240 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
240 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
241 | 241 | |
242 | 242 | return $spotter_array; |
243 | 243 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | if ($id == '') return array(); |
257 | 257 | $additional_query = "tracker_output.famtrackid = :id"; |
258 | 258 | $query_values = array(':id' => $id); |
259 | - $query = $global_query." WHERE ".$additional_query." "; |
|
260 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
259 | + $query = $global_query." WHERE ".$additional_query." "; |
|
260 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
261 | 261 | return $spotter_array; |
262 | 262 | } |
263 | 263 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $query_values = array(); |
277 | 277 | $limit_query = ''; |
278 | 278 | $additional_query = ''; |
279 | - $filter_query = $this->getFilter($filter,true,true); |
|
279 | + $filter_query = $this->getFilter($filter, true, true); |
|
280 | 280 | if ($ident != "") |
281 | 281 | { |
282 | 282 | if (!is_string($ident)) |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | { |
293 | 293 | $limit_array = explode(",", $limit); |
294 | 294 | |
295 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
296 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
295 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
296 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
297 | 297 | |
298 | 298 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
299 | 299 | { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | return $spotter_array; |
318 | 318 | } |
319 | 319 | |
320 | - public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
320 | + public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
321 | 321 | { |
322 | 322 | global $global_query, $globalTimezone, $globalDBdriver; |
323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $limit_query = ''; |
326 | 326 | $additional_query = ''; |
327 | 327 | |
328 | - $filter_query = $this->getFilter($filter,true,true); |
|
328 | + $filter_query = $this->getFilter($filter, true, true); |
|
329 | 329 | |
330 | 330 | if ($date != "") |
331 | 331 | { |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | { |
352 | 352 | $limit_array = explode(",", $limit); |
353 | 353 | |
354 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
355 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
354 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
355 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
356 | 356 | |
357 | 357 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
358 | 358 | { |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | * @return Array list of source name |
384 | 384 | * |
385 | 385 | */ |
386 | - public function getAllSourceName($type = '',$filters = array()) |
|
386 | + public function getAllSourceName($type = '', $filters = array()) |
|
387 | 387 | { |
388 | - $filter_query = $this->getFilter($filters,true,true); |
|
388 | + $filter_query = $this->getFilter($filters, true, true); |
|
389 | 389 | $query_values = array(); |
390 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
390 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
391 | 391 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
392 | 392 | if ($type != '') { |
393 | 393 | $query_values = array(':type' => $type); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $source_array = array(); |
403 | 403 | $temp_array = array(); |
404 | 404 | |
405 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
405 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
406 | 406 | { |
407 | 407 | $temp_array['source_name'] = $row['source_name']; |
408 | 408 | $source_array[] = $temp_array; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getAllIdents($filters = array()) |
421 | 421 | { |
422 | - $filter_query = $this->getFilter($filters,true,true); |
|
423 | - $query = "SELECT DISTINCT tracker_output.ident |
|
422 | + $filter_query = $this->getFilter($filters, true, true); |
|
423 | + $query = "SELECT DISTINCT tracker_output.ident |
|
424 | 424 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
425 | 425 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
426 | 426 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $ident_array = array(); |
431 | 431 | $temp_array = array(); |
432 | 432 | |
433 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
433 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
434 | 434 | { |
435 | 435 | $temp_array['ident'] = $row['ident']; |
436 | 436 | $ident_array[] = $temp_array; |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | } else $offset = '+00:00'; |
456 | 456 | |
457 | 457 | if ($globalDBdriver == 'mysql') { |
458 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
458 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
459 | 459 | FROM tracker_output |
460 | 460 | WHERE tracker_output.date <> '' |
461 | 461 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
462 | 462 | } else { |
463 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
463 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
464 | 464 | FROM tracker_output |
465 | 465 | WHERE tracker_output.date <> '' |
466 | 466 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $date_array = array(); |
473 | 473 | $temp_array = array(); |
474 | 474 | |
475 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
475 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
476 | 476 | { |
477 | 477 | $temp_array['date'] = $row['date']; |
478 | 478 | |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | * @return String success or false |
492 | 492 | * |
493 | 493 | */ |
494 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
494 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
495 | 495 | { |
496 | 496 | |
497 | 497 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
498 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
498 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
499 | 499 | |
500 | 500 | try { |
501 | 501 | $sth = $this->db->prepare($query); |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
520 | 520 | { |
521 | 521 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
522 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
522 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
523 | 523 | |
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * @param String $verticalrate vertival rate of flight |
560 | 560 | * @return String success or false |
561 | 561 | */ |
562 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
562 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
563 | 563 | { |
564 | 564 | global $globalURL; |
565 | 565 | |
@@ -627,21 +627,21 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | |
630 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
630 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
631 | 631 | { |
632 | 632 | $date = date("Y-m-d H:i:s", time()); |
633 | 633 | } |
634 | 634 | |
635 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
636 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
637 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
638 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
639 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
640 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
641 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
642 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
643 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
644 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
635 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
636 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
637 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
638 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
639 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
640 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
641 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
642 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
643 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
644 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
645 | 645 | |
646 | 646 | if ($latitude == '' && $longitude == '') { |
647 | 647 | $latitude = 0; |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | } |
650 | 650 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
651 | 651 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
652 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
652 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | 653 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
654 | 654 | |
655 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
655 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
656 | 656 | |
657 | 657 | try { |
658 | 658 | |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | { |
679 | 679 | global $globalDBdriver, $globalTimezone; |
680 | 680 | if ($globalDBdriver == 'mysql') { |
681 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
681 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
682 | 682 | WHERE tracker_output.ident = :ident |
683 | 683 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
684 | 684 | AND tracker_output.date < UTC_TIMESTAMP()"; |
685 | 685 | $query_data = array(':ident' => $ident); |
686 | 686 | } else { |
687 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
687 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
688 | 688 | WHERE tracker_output.ident = :ident |
689 | 689 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
690 | 690 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute($query_data); |
696 | - $ident_result=''; |
|
697 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
696 | + $ident_result = ''; |
|
697 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
698 | 698 | { |
699 | 699 | $ident_result = $row['ident']; |
700 | 700 | } |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | return false; |
721 | 721 | } else { |
722 | 722 | $q_array = explode(" ", $q); |
723 | - foreach ($q_array as $q_item){ |
|
724 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
723 | + foreach ($q_array as $q_item) { |
|
724 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
725 | 725 | $additional_query .= " AND ("; |
726 | 726 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
727 | 727 | $additional_query .= ")"; |
@@ -729,11 +729,11 @@ discard block |
||
729 | 729 | } |
730 | 730 | } |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
732 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
733 | 733 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
734 | 734 | AND tracker_output.date < UTC_TIMESTAMP()"; |
735 | 735 | } else { |
736 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
736 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
737 | 737 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
738 | 738 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
739 | 739 | } |
@@ -806,11 +806,11 @@ discard block |
||
806 | 806 | * @return Array the callsign list |
807 | 807 | * |
808 | 808 | */ |
809 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
809 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
810 | 810 | { |
811 | 811 | global $globalDBdriver; |
812 | - $filter_query = $this->getFilter($filters,true,true); |
|
813 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
812 | + $filter_query = $this->getFilter($filters, true, true); |
|
813 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
814 | 814 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
815 | 815 | if ($olderthanmonths > 0) { |
816 | 816 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -824,28 +824,28 @@ discard block |
||
824 | 824 | if ($year != '') { |
825 | 825 | if ($globalDBdriver == 'mysql') { |
826 | 826 | $query .= " AND YEAR(tracker_output.date) = :year"; |
827 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
827 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
828 | 828 | } else { |
829 | 829 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
830 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
830 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
831 | 831 | } |
832 | 832 | } |
833 | 833 | if ($month != '') { |
834 | 834 | if ($globalDBdriver == 'mysql') { |
835 | 835 | $query .= " AND MONTH(tracker_output.date) = :month"; |
836 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
836 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
837 | 837 | } else { |
838 | 838 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
839 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
839 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | if ($day != '') { |
843 | 843 | if ($globalDBdriver == 'mysql') { |
844 | 844 | $query .= " AND DAY(tracker_output.date) = :day"; |
845 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
845 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
846 | 846 | } else { |
847 | 847 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
848 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
848 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
849 | 849 | } |
850 | 850 | } |
851 | 851 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | $callsign_array = array(); |
858 | 858 | $temp_array = array(); |
859 | 859 | |
860 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
860 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
861 | 861 | { |
862 | 862 | $temp_array['callsign_icao'] = $row['ident']; |
863 | 863 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | $date_array = array(); |
910 | 910 | $temp_array = array(); |
911 | 911 | |
912 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
912 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | 913 | { |
914 | 914 | $temp_array['date_name'] = $row['date_name']; |
915 | 915 | $temp_array['date_count'] = $row['date_count']; |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $datetime = new DateTime(); |
936 | 936 | $offset = $datetime->format('P'); |
937 | 937 | } else $offset = '+00:00'; |
938 | - $filter_query = $this->getFilter($filters,true,true); |
|
938 | + $filter_query = $this->getFilter($filters, true, true); |
|
939 | 939 | if ($globalDBdriver == 'mysql') { |
940 | 940 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
941 | 941 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $date_array = array(); |
957 | 957 | $temp_array = array(); |
958 | 958 | |
959 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
959 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
960 | 960 | { |
961 | 961 | $temp_array['date_name'] = $row['date_name']; |
962 | 962 | $temp_array['date_count'] = $row['date_count']; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $datetime = new DateTime(); |
982 | 982 | $offset = $datetime->format('P'); |
983 | 983 | } else $offset = '+00:00'; |
984 | - $filter_query = $this->getFilter($filters,true,true); |
|
984 | + $filter_query = $this->getFilter($filters, true, true); |
|
985 | 985 | if ($globalDBdriver == 'mysql') { |
986 | 986 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
987 | 987 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $date_array = array(); |
1003 | 1003 | $temp_array = array(); |
1004 | 1004 | |
1005 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1005 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1006 | 1006 | { |
1007 | 1007 | $temp_array['date_name'] = $row['date_name']; |
1008 | 1008 | $temp_array['date_count'] = $row['date_count']; |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | $date_array = array(); |
1050 | 1050 | $temp_array = array(); |
1051 | 1051 | |
1052 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1052 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1053 | 1053 | { |
1054 | 1054 | $temp_array['month_name'] = $row['month_name']; |
1055 | 1055 | $temp_array['year_name'] = $row['year_name']; |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | $datetime = new DateTime(); |
1079 | 1079 | $offset = $datetime->format('P'); |
1080 | 1080 | } else $offset = '+00:00'; |
1081 | - $filter_query = $this->getFilter($filters,true,true); |
|
1081 | + $filter_query = $this->getFilter($filters, true, true); |
|
1082 | 1082 | if ($globalDBdriver == 'mysql') { |
1083 | 1083 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1084 | 1084 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | $date_array = array(); |
1100 | 1100 | $temp_array = array(); |
1101 | 1101 | |
1102 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1102 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1103 | 1103 | { |
1104 | 1104 | $temp_array['year_name'] = $row['year_name']; |
1105 | 1105 | $temp_array['month_name'] = $row['month_name']; |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | * @return Array the hour list |
1120 | 1120 | * |
1121 | 1121 | */ |
1122 | - public function countAllHours($orderby,$filters = array()) |
|
1122 | + public function countAllHours($orderby, $filters = array()) |
|
1123 | 1123 | { |
1124 | 1124 | global $globalTimezone, $globalDBdriver; |
1125 | 1125 | if ($globalTimezone != '') { |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | $hour_array = array(); |
1168 | 1168 | $temp_array = array(); |
1169 | 1169 | |
1170 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1170 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1171 | 1171 | { |
1172 | 1172 | $temp_array['hour_name'] = $row['hour_name']; |
1173 | 1173 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1189,8 +1189,8 @@ discard block |
||
1189 | 1189 | public function countAllHoursByDate($date, $filters = array()) |
1190 | 1190 | { |
1191 | 1191 | global $globalTimezone, $globalDBdriver; |
1192 | - $filter_query = $this->getFilter($filters,true,true); |
|
1193 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1192 | + $filter_query = $this->getFilter($filters, true, true); |
|
1193 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1194 | 1194 | if ($globalTimezone != '') { |
1195 | 1195 | date_default_timezone_set($globalTimezone); |
1196 | 1196 | $datetime = new DateTime($date); |
@@ -1198,12 +1198,12 @@ discard block |
||
1198 | 1198 | } else $offset = '+00:00'; |
1199 | 1199 | |
1200 | 1200 | if ($globalDBdriver == 'mysql') { |
1201 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1201 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1202 | 1202 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1203 | 1203 | GROUP BY hour_name |
1204 | 1204 | ORDER BY hour_name ASC"; |
1205 | 1205 | } else { |
1206 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1206 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1207 | 1207 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1208 | 1208 | GROUP BY hour_name |
1209 | 1209 | ORDER BY hour_name ASC"; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $hour_array = array(); |
1216 | 1216 | $temp_array = array(); |
1217 | 1217 | |
1218 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1218 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1219 | 1219 | { |
1220 | 1220 | $temp_array['hour_name'] = $row['hour_name']; |
1221 | 1221 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1237,8 +1237,8 @@ discard block |
||
1237 | 1237 | public function countAllHoursByIdent($ident, $filters = array()) |
1238 | 1238 | { |
1239 | 1239 | global $globalTimezone, $globalDBdriver; |
1240 | - $filter_query = $this->getFilter($filters,true,true); |
|
1241 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1240 | + $filter_query = $this->getFilter($filters, true, true); |
|
1241 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1242 | 1242 | if ($globalTimezone != '') { |
1243 | 1243 | date_default_timezone_set($globalTimezone); |
1244 | 1244 | $datetime = new DateTime(); |
@@ -1246,12 +1246,12 @@ discard block |
||
1246 | 1246 | } else $offset = '+00:00'; |
1247 | 1247 | |
1248 | 1248 | if ($globalDBdriver == 'mysql') { |
1249 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1249 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1250 | 1250 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1251 | 1251 | GROUP BY hour_name |
1252 | 1252 | ORDER BY hour_name ASC"; |
1253 | 1253 | } else { |
1254 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1254 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1255 | 1255 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1256 | 1256 | GROUP BY hour_name |
1257 | 1257 | ORDER BY hour_name ASC"; |
@@ -1259,12 +1259,12 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | |
1261 | 1261 | $sth = $this->db->prepare($query); |
1262 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1262 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1263 | 1263 | |
1264 | 1264 | $hour_array = array(); |
1265 | 1265 | $temp_array = array(); |
1266 | 1266 | |
1267 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1267 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1268 | 1268 | { |
1269 | 1269 | $temp_array['hour_name'] = $row['hour_name']; |
1270 | 1270 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1283,32 +1283,32 @@ discard block |
||
1283 | 1283 | * @return Integer the number of flights |
1284 | 1284 | * |
1285 | 1285 | */ |
1286 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
1286 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
1287 | 1287 | { |
1288 | 1288 | global $globalDBdriver; |
1289 | - $queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
|
1289 | + $queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
|
1290 | 1290 | $query_values = array(); |
1291 | 1291 | $query = ''; |
1292 | 1292 | if ($year != '') { |
1293 | 1293 | if ($globalDBdriver == 'mysql') { |
1294 | 1294 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1295 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1295 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1296 | 1296 | } else { |
1297 | 1297 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1298 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1298 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1299 | 1299 | } |
1300 | 1300 | } |
1301 | 1301 | if ($month != '') { |
1302 | 1302 | if ($globalDBdriver == 'mysql') { |
1303 | 1303 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1304 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1304 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1305 | 1305 | } else { |
1306 | 1306 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1307 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1307 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1308 | 1308 | } |
1309 | 1309 | } |
1310 | 1310 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1311 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1311 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1312 | 1312 | |
1313 | 1313 | $sth = $this->db->prepare($queryi); |
1314 | 1314 | $sth->execute($query_values); |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | public function countAllHoursFromToday($filters = array()) |
1326 | 1326 | { |
1327 | 1327 | global $globalTimezone, $globalDBdriver; |
1328 | - $filter_query = $this->getFilter($filters,true,true); |
|
1328 | + $filter_query = $this->getFilter($filters, true, true); |
|
1329 | 1329 | if ($globalTimezone != '') { |
1330 | 1330 | date_default_timezone_set($globalTimezone); |
1331 | 1331 | $datetime = new DateTime(); |
@@ -1333,12 +1333,12 @@ discard block |
||
1333 | 1333 | } else $offset = '+00:00'; |
1334 | 1334 | |
1335 | 1335 | if ($globalDBdriver == 'mysql') { |
1336 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1336 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1337 | 1337 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1338 | 1338 | GROUP BY hour_name |
1339 | 1339 | ORDER BY hour_name ASC"; |
1340 | 1340 | } else { |
1341 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1341 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1342 | 1342 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1343 | 1343 | GROUP BY hour_name |
1344 | 1344 | ORDER BY hour_name ASC"; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | $hour_array = array(); |
1351 | 1351 | $temp_array = array(); |
1352 | 1352 | |
1353 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1353 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1354 | 1354 | { |
1355 | 1355 | $temp_array['hour_name'] = $row['hour_name']; |
1356 | 1356 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | */ |
1370 | 1370 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1371 | 1371 | { |
1372 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1372 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1373 | 1373 | |
1374 | - $query = "SELECT tracker_output.tracker_id |
|
1374 | + $query = "SELECT tracker_output.tracker_id |
|
1375 | 1375 | FROM tracker_output |
1376 | 1376 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1377 | 1377 | |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | $sth = $this->db->prepare($query); |
1380 | 1380 | $sth->execute(); |
1381 | 1381 | |
1382 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1382 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1383 | 1383 | { |
1384 | 1384 | return $row['tracker_id']; |
1385 | 1385 | } |
@@ -1404,23 +1404,23 @@ discard block |
||
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | $current_date = date("Y-m-d H:i:s"); |
1407 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1407 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1408 | 1408 | |
1409 | 1409 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1410 | 1410 | |
1411 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1411 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1412 | 1412 | $years = $time_array['years']; |
1413 | 1413 | |
1414 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1414 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1415 | 1415 | $months = $time_array['months']; |
1416 | 1416 | |
1417 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1417 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1418 | 1418 | $days = $time_array['days']; |
1419 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1419 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1420 | 1420 | $hours = $time_array['hours']; |
1421 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1421 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1422 | 1422 | $minutes = $time_array['minutes']; |
1423 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1423 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1424 | 1424 | |
1425 | 1425 | return $time_array; |
1426 | 1426 | } |
@@ -1443,63 +1443,63 @@ discard block |
||
1443 | 1443 | $temp_array['direction_degree'] = $direction; |
1444 | 1444 | $temp_array['direction_shortname'] = "N"; |
1445 | 1445 | $temp_array['direction_fullname'] = "North"; |
1446 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1446 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1447 | 1447 | $temp_array['direction_degree'] = $direction; |
1448 | 1448 | $temp_array['direction_shortname'] = "NNE"; |
1449 | 1449 | $temp_array['direction_fullname'] = "North-Northeast"; |
1450 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1450 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1451 | 1451 | $temp_array['direction_degree'] = $direction; |
1452 | 1452 | $temp_array['direction_shortname'] = "NE"; |
1453 | 1453 | $temp_array['direction_fullname'] = "Northeast"; |
1454 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1454 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1455 | 1455 | $temp_array['direction_degree'] = $direction; |
1456 | 1456 | $temp_array['direction_shortname'] = "ENE"; |
1457 | 1457 | $temp_array['direction_fullname'] = "East-Northeast"; |
1458 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1458 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1459 | 1459 | $temp_array['direction_degree'] = $direction; |
1460 | 1460 | $temp_array['direction_shortname'] = "E"; |
1461 | 1461 | $temp_array['direction_fullname'] = "East"; |
1462 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1462 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1463 | 1463 | $temp_array['direction_degree'] = $direction; |
1464 | 1464 | $temp_array['direction_shortname'] = "ESE"; |
1465 | 1465 | $temp_array['direction_fullname'] = "East-Southeast"; |
1466 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1466 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1467 | 1467 | $temp_array['direction_degree'] = $direction; |
1468 | 1468 | $temp_array['direction_shortname'] = "SE"; |
1469 | 1469 | $temp_array['direction_fullname'] = "Southeast"; |
1470 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1470 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1471 | 1471 | $temp_array['direction_degree'] = $direction; |
1472 | 1472 | $temp_array['direction_shortname'] = "SSE"; |
1473 | 1473 | $temp_array['direction_fullname'] = "South-Southeast"; |
1474 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1474 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1475 | 1475 | $temp_array['direction_degree'] = $direction; |
1476 | 1476 | $temp_array['direction_shortname'] = "S"; |
1477 | 1477 | $temp_array['direction_fullname'] = "South"; |
1478 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1478 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1479 | 1479 | $temp_array['direction_degree'] = $direction; |
1480 | 1480 | $temp_array['direction_shortname'] = "SSW"; |
1481 | 1481 | $temp_array['direction_fullname'] = "South-Southwest"; |
1482 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1482 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1483 | 1483 | $temp_array['direction_degree'] = $direction; |
1484 | 1484 | $temp_array['direction_shortname'] = "SW"; |
1485 | 1485 | $temp_array['direction_fullname'] = "Southwest"; |
1486 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1486 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1487 | 1487 | $temp_array['direction_degree'] = $direction; |
1488 | 1488 | $temp_array['direction_shortname'] = "WSW"; |
1489 | 1489 | $temp_array['direction_fullname'] = "West-Southwest"; |
1490 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1490 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1491 | 1491 | $temp_array['direction_degree'] = $direction; |
1492 | 1492 | $temp_array['direction_shortname'] = "W"; |
1493 | 1493 | $temp_array['direction_fullname'] = "West"; |
1494 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1494 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1495 | 1495 | $temp_array['direction_degree'] = $direction; |
1496 | 1496 | $temp_array['direction_shortname'] = "WNW"; |
1497 | 1497 | $temp_array['direction_fullname'] = "West-Northwest"; |
1498 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1498 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1499 | 1499 | $temp_array['direction_degree'] = $direction; |
1500 | 1500 | $temp_array['direction_shortname'] = "NW"; |
1501 | 1501 | $temp_array['direction_fullname'] = "Northwest"; |
1502 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1502 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1503 | 1503 | $temp_array['direction_degree'] = $direction; |
1504 | 1504 | $temp_array['direction_shortname'] = "NNW"; |
1505 | 1505 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1516,11 +1516,11 @@ discard block |
||
1516 | 1516 | * @param Float $longitude longitute of the flight |
1517 | 1517 | * @return String the countrie |
1518 | 1518 | */ |
1519 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1519 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1520 | 1520 | { |
1521 | 1521 | global $globalDBdriver, $globalDebug; |
1522 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1523 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1522 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1523 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1524 | 1524 | |
1525 | 1525 | $Connection = new Connection($this->db); |
1526 | 1526 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | public function getCountryFromISO2($iso2) |
1561 | 1561 | { |
1562 | 1562 | global $globalDBdriver, $globalDebug; |
1563 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1563 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1564 | 1564 | |
1565 | 1565 | $Connection = new Connection($this->db); |
1566 | 1566 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | |
1609 | 1609 | $bitly_data = json_decode($bitly_data); |
1610 | 1610 | $bitly_url = ''; |
1611 | - if ($bitly_data->status_txt = "OK"){ |
|
1611 | + if ($bitly_data->status_txt = "OK") { |
|
1612 | 1612 | $bitly_url = $bitly_data->data->url; |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | |
1619 | 1619 | public function getOrderBy() |
1620 | 1620 | { |
1621 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1621 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1622 | 1622 | |
1623 | 1623 | return $orderby; |
1624 | 1624 |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | $currentdate = date('Y-m-d'); |
30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
31 | 31 | if (!empty($sourcestat)) { |
32 | - foreach($sourcestat as $srcst) { |
|
32 | + foreach ($sourcestat as $srcst) { |
|
33 | 33 | $type = $srcst['stats_type']; |
34 | 34 | if ($type == 'polar' || $type == 'hist') { |
35 | 35 | $source = $srcst['source_name']; |
36 | 36 | $data = $srcst['source_data']; |
37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
37 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - public function get_Schedule($id,$ident) { |
|
43 | + public function get_Schedule($id, $ident) { |
|
44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
45 | 45 | // Get schedule here, so it's done only one time |
46 | 46 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | 67 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
70 | 70 | // Should also check if route schedule = route from DB |
71 | 71 | if ($schedule['DepartureAirportIATA'] != '') { |
72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
89 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
90 | 90 | } |
91 | 91 | } else $scheduleexist = true; |
92 | 92 | } else $scheduleexist = true; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | if ($scheduleexist) { |
95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
96 | 96 | $sch = $Schedule->getSchedule($operator); |
97 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
97 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
98 | 98 | } |
99 | 99 | $Spotter->db = null; |
100 | 100 | $Schedule->db = null; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
121 | 121 | $Spotter = new Spotter($this->db); |
122 | 122 | $real_arrival = $this->arrival($key); |
123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $airport_time = ''; |
134 | 134 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
137 | 137 | if (isset($closestAirports[0])) { |
138 | 138 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 139 | $airport_icao = $closestAirports[0]['icao']; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
152 | 152 | $airport_icao = $closestAirports[0]['icao']; |
153 | 153 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 154 | } else { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } else { |
162 | 162 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
163 | 163 | } |
164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
164 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
173 | 173 | foreach ($this->all_flights as $key => $flight) { |
174 | 174 | if (isset($flight['lastupdate'])) { |
175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
175 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
176 | 176 | if (isset($this->all_flights[$key]['id'])) { |
177 | 177 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
178 | 178 | /* |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $real_arrival = $this->arrival($key); |
184 | 184 | $Spotter = new Spotter($this->db); |
185 | 185 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
186 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | } |
189 | 189 | // Put in archive |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $send = false; |
220 | 220 | |
221 | 221 | // SBS format is CSV format |
222 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
222 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
223 | 223 | //print_r($line); |
224 | 224 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
225 | 225 | |
@@ -252,25 +252,25 @@ discard block |
||
252 | 252 | |
253 | 253 | if (!isset($this->all_flights[$id])) { |
254 | 254 | $this->all_flights[$id] = array(); |
255 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
257 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
255 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
257 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
258 | 258 | if (!isset($line['id'])) { |
259 | 259 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
260 | 260 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
261 | 261 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
262 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
262 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
263 | 263 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
264 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
264 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
265 | 265 | if ($globalAllFlights !== FALSE) $dataFound = true; |
266 | 266 | } |
267 | 267 | if (isset($line['source_type']) && $line['source_type'] != '') { |
268 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
268 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | //print_r($this->all_flights); |
272 | 272 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
273 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
273 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
274 | 274 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
275 | 275 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
276 | 276 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -278,41 +278,41 @@ discard block |
||
278 | 278 | $timeelapsed = microtime(true); |
279 | 279 | $Spotter = new Spotter($this->db); |
280 | 280 | if (isset($this->all_flights[$id]['source_type'])) { |
281 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
281 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
282 | 282 | } else { |
283 | 283 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
284 | 284 | } |
285 | 285 | $Spotter->db = null; |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
287 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
288 | 288 | } |
289 | 289 | if ($globalAllFlights !== FALSE) $dataFound = true; |
290 | 290 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
291 | 291 | } |
292 | 292 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
294 | 294 | } |
295 | 295 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
296 | 296 | // Get aircraft ICAO from aircraft name |
297 | 297 | $Spotter = new Spotter($this->db); |
298 | 298 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
299 | 299 | $Spotter->db = null; |
300 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
300 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
301 | 301 | } |
302 | 302 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
303 | 303 | if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
304 | 304 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
305 | 305 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
306 | 306 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
307 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
307 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
308 | 308 | } |
309 | 309 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
310 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
310 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
311 | 311 | } |
312 | 312 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
313 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
313 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
314 | 314 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
315 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
315 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
316 | 316 | } else { |
317 | 317 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
318 | 318 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | } |
326 | 326 | } else { |
327 | 327 | date_default_timezone_set('UTC'); |
328 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
332 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
332 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
333 | 333 | } |
334 | 334 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
335 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
335 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
336 | 336 | } |
337 | 337 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
339 | 339 | } |
340 | 340 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
341 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
346 | 346 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
347 | 347 | $timeelapsed = microtime(true); |
348 | 348 | $Spotter = new Spotter($this->db); |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
353 | 353 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
354 | 354 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
355 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
355 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
356 | 356 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
357 | 357 | $Spotter->db = null; |
358 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
358 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /* |
@@ -366,24 +366,24 @@ discard block |
||
366 | 366 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
367 | 367 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
368 | 368 | */ |
369 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
369 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
370 | 370 | |
371 | 371 | //$putinarchive = true; |
372 | 372 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
373 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
373 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
374 | 374 | } |
375 | 375 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
377 | 377 | } |
378 | 378 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
380 | 380 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
381 | 381 | $timeelapsed = microtime(true); |
382 | 382 | $Spotter = new Spotter($this->db); |
383 | 383 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
384 | 384 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
386 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
386 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
387 | 387 | |
388 | 388 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
389 | 389 | $timeelapsed = microtime(true); |
@@ -396,34 +396,34 @@ discard block |
||
396 | 396 | $Translation->db = null; |
397 | 397 | } |
398 | 398 | $Spotter->db = null; |
399 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
400 | 400 | |
401 | 401 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
402 | 402 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
403 | 403 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
404 | 404 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
405 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
405 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | if (!isset($globalFork)) $globalFork = TRUE; |
409 | 409 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
410 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
410 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | if (isset($line['speed']) && $line['speed'] != '') { |
416 | 416 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
418 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
418 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
419 | 419 | //$dataFound = true; |
420 | 420 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
421 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
421 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
422 | 422 | if ($distance > 1000 && $distance < 10000) { |
423 | 423 | // use datetime |
424 | 424 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
425 | 425 | $speed = $speed*3.6; |
426 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
426 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
427 | 427 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
428 | 428 | } |
429 | 429 | } |
@@ -431,11 +431,11 @@ discard block |
||
431 | 431 | |
432 | 432 | |
433 | 433 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
434 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
434 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
435 | 435 | else unset($timediff); |
436 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
436 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
437 | 437 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
438 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
438 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
439 | 439 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
440 | 440 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
441 | 441 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
444 | 444 | $timeelapsed = microtime(true); |
445 | 445 | $Spotter = new Spotter($this->db); |
446 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
446 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
447 | 447 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
448 | 448 | $Spotter->db = null; |
449 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
449 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
450 | 450 | $this->tmd = 0; |
451 | 451 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
452 | 452 | } |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
456 | 456 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
457 | 457 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
458 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
458 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
459 | 459 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
460 | 460 | $dataFound = true; |
461 | 461 | $this->all_flights[$id]['time_last_coord'] = time(); |
462 | 462 | } |
463 | 463 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
465 | 465 | /* |
466 | 466 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
467 | 467 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -479,13 +479,13 @@ discard block |
||
479 | 479 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
480 | 480 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
481 | 481 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
482 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
482 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
483 | 483 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
484 | 484 | $dataFound = true; |
485 | 485 | $this->all_flights[$id]['time_last_coord'] = time(); |
486 | 486 | } |
487 | 487 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
488 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
488 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
489 | 489 | /* |
490 | 490 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
491 | 491 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -503,46 +503,46 @@ discard block |
||
503 | 503 | } else if ($globalDebug && $timediff > 20) { |
504 | 504 | $this->tmd = $this->tmd + 1; |
505 | 505 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
506 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
507 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
506 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
507 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
508 | 508 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
509 | 509 | } |
510 | 510 | } |
511 | 511 | if (isset($line['last_update']) && $line['last_update'] != '') { |
512 | 512 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
514 | 514 | } |
515 | 515 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
516 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
516 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
517 | 517 | //$dataFound = true; |
518 | 518 | } |
519 | 519 | if (isset($line['format_source']) && $line['format_source'] != '') { |
520 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
520 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
521 | 521 | } |
522 | 522 | if (isset($line['source_name']) && $line['source_name'] != '') { |
523 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
523 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
524 | 524 | } |
525 | 525 | if (isset($line['emergency']) && $line['emergency'] != '') { |
526 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
526 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
527 | 527 | //$dataFound = true; |
528 | 528 | } |
529 | 529 | if (isset($line['ground']) && $line['ground'] != '') { |
530 | 530 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
531 | 531 | // Here we force archive of flight because after ground it's a new one (or should be) |
532 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
533 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
534 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
535 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
536 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
532 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
533 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
534 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
535 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
536 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
537 | 537 | } |
538 | 538 | if ($line['ground'] != 1) $line['ground'] = 0; |
539 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
539 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
540 | 540 | //$dataFound = true; |
541 | 541 | } |
542 | 542 | if (isset($line['squawk']) && $line['squawk'] != '') { |
543 | 543 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
544 | 544 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
545 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
545 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
546 | 546 | $highlight = ''; |
547 | 547 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
548 | 548 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -550,47 +550,47 @@ discard block |
||
550 | 550 | if ($highlight != '') { |
551 | 551 | $timeelapsed = microtime(true); |
552 | 552 | $Spotter = new Spotter($this->db); |
553 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
553 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
554 | 554 | $Spotter->db = null; |
555 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
555 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
556 | 556 | |
557 | 557 | //$putinarchive = true; |
558 | 558 | //$highlight = ''; |
559 | 559 | } |
560 | 560 | |
561 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
561 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
562 | 562 | //$dataFound = true; |
563 | 563 | } |
564 | 564 | |
565 | 565 | if (isset($line['altitude']) && $line['altitude'] != '') { |
566 | 566 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
567 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
569 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
567 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
569 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
570 | 570 | //$dataFound = true; |
571 | 571 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
572 | 572 | } |
573 | 573 | |
574 | 574 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
575 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
575 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | if (isset($line['heading']) && $line['heading'] != '') { |
579 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
580 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
581 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
579 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
580 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
581 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
582 | 582 | //$dataFound = true; |
583 | 583 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
584 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
585 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
586 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
584 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
585 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
586 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
587 | 587 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
588 | 588 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
589 | 589 | // If not enough messages and ACARS set heading to 0 |
590 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
590 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
591 | 591 | } |
592 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
593 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
592 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
593 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
594 | 594 | |
595 | 595 | // print_r($this->all_flights[$id]); |
596 | 596 | //gets the callsign from the last hour |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
601 | 601 | $this->all_flights[$id]['lastupdate'] = time(); |
602 | 602 | if ($this->all_flights[$id]['addedSpotter'] == 0) { |
603 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
603 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
604 | 604 | //print_r($this->all_flights); |
605 | 605 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
606 | 606 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -610,61 +610,61 @@ discard block |
||
610 | 610 | $SpotterLive = new SpotterLive($this->db); |
611 | 611 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
612 | 612 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
613 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
613 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
614 | 614 | } elseif (isset($line['id'])) { |
615 | 615 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
616 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
616 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
617 | 617 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
618 | 618 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
619 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
619 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
620 | 620 | } else $recent_ident = ''; |
621 | - $SpotterLive->db=null; |
|
621 | + $SpotterLive->db = null; |
|
622 | 622 | |
623 | 623 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
624 | 624 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
625 | 625 | } else { |
626 | 626 | $recent_ident = ''; |
627 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
627 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
628 | 628 | } |
629 | 629 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
630 | - if($recent_ident == "") |
|
630 | + if ($recent_ident == "") |
|
631 | 631 | { |
632 | 632 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
633 | 633 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
634 | 634 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
635 | 635 | //adds the spotter data for the archive |
636 | 636 | $ignoreImport = false; |
637 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
637 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
638 | 638 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
639 | 639 | $ignoreImport = true; |
640 | 640 | } |
641 | 641 | } |
642 | 642 | if (count($globalAirportAccept) > 0) { |
643 | 643 | $ignoreImport = true; |
644 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
644 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
645 | 645 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
646 | 646 | $ignoreImport = false; |
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
650 | 650 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
651 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
652 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
651 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
652 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
653 | 653 | $ignoreImport = true; |
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
657 | 657 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
658 | 658 | $ignoreImport = true; |
659 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
660 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
659 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
660 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
661 | 661 | $ignoreImport = false; |
662 | 662 | } |
663 | 663 | } |
664 | 664 | } |
665 | 665 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
666 | 666 | $ignoreImport = true; |
667 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
667 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
668 | 668 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
669 | 669 | $ignoreImport = false; |
670 | 670 | } |
@@ -676,27 +676,27 @@ discard block |
||
676 | 676 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
677 | 677 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
678 | 678 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
679 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
679 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
680 | 680 | $timeelapsed = microtime(true); |
681 | 681 | $Spotter = new Spotter($this->db); |
682 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
682 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
683 | 683 | $Spotter->db = null; |
684 | 684 | if ($globalDebug && isset($result)) echo $result."\n"; |
685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
685 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
686 | 686 | |
687 | 687 | // Add source stat in DB |
688 | 688 | $Stats = new Stats($this->db); |
689 | 689 | if (!empty($this->stats)) { |
690 | 690 | if ($globalDebug) echo 'Add source stats : '; |
691 | - foreach($this->stats as $date => $data) { |
|
692 | - foreach($data as $source => $sourced) { |
|
691 | + foreach ($this->stats as $date => $data) { |
|
692 | + foreach ($data as $source => $sourced) { |
|
693 | 693 | //print_r($sourced); |
694 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
695 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
694 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
695 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
696 | 696 | if (isset($sourced['msg'])) { |
697 | 697 | if (time() - $sourced['msg']['date'] > 10) { |
698 | 698 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
699 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
699 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
700 | 700 | unset($this->stats[$date][$source]['msg']); |
701 | 701 | } |
702 | 702 | } |
@@ -732,18 +732,18 @@ discard block |
||
732 | 732 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
733 | 733 | $SpotterLive = new SpotterLive($this->db); |
734 | 734 | $SpotterLive->deleteLiveSpotterData(); |
735 | - $SpotterLive->db=null; |
|
735 | + $SpotterLive->db = null; |
|
736 | 736 | if ($globalDebug) echo " Done\n"; |
737 | 737 | $this->last_delete = time(); |
738 | 738 | } |
739 | 739 | } else { |
740 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
740 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
741 | 741 | $this->all_flights[$id]['id'] = $recent_ident; |
742 | 742 | $this->all_flights[$id]['addedSpotter'] = 1; |
743 | 743 | } |
744 | 744 | if (isset($globalDaemon) && !$globalDaemon) { |
745 | 745 | $Spotter = new Spotter($this->db); |
746 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
746 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
747 | 747 | $Spotter->db = null; |
748 | 748 | } |
749 | 749 | |
@@ -767,37 +767,37 @@ discard block |
||
767 | 767 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
768 | 768 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
769 | 769 | |
770 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
770 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
771 | 771 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
772 | 772 | $ignoreImport = true; |
773 | 773 | } |
774 | 774 | } |
775 | 775 | if (count($globalAirportAccept) > 0) { |
776 | 776 | $ignoreImport = true; |
777 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
777 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
778 | 778 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
779 | 779 | $ignoreImport = false; |
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
783 | 783 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
784 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
785 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
784 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
785 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
786 | 786 | $ignoreImport = true; |
787 | 787 | } |
788 | 788 | } |
789 | 789 | } |
790 | 790 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
791 | 791 | $ignoreImport = true; |
792 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
793 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
792 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
793 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
794 | 794 | $ignoreImport = false; |
795 | 795 | } |
796 | 796 | } |
797 | 797 | } |
798 | 798 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
799 | 799 | $ignoreImport = true; |
800 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
800 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
801 | 801 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
802 | 802 | $ignoreImport = false; |
803 | 803 | } |
@@ -805,14 +805,14 @@ discard block |
||
805 | 805 | } |
806 | 806 | |
807 | 807 | if (!$ignoreImport) { |
808 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
808 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
809 | 809 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
810 | 810 | $timeelapsed = microtime(true); |
811 | 811 | $SpotterLive = new SpotterLive($this->db); |
812 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
812 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
813 | 813 | $SpotterLive->db = null; |
814 | 814 | $this->all_flights[$id]['putinarchive'] = false; |
815 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
815 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
816 | 816 | |
817 | 817 | // Put statistics in $this->stats variable |
818 | 818 | //if ($line['format_source'] != 'aprs') { |
@@ -830,19 +830,19 @@ discard block |
||
830 | 830 | $latitude = $globalCenterLatitude; |
831 | 831 | $longitude = $globalCenterLongitude; |
832 | 832 | } |
833 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
833 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
834 | 834 | } else { |
835 | 835 | $latitude = $this->source_location[$source]['latitude']; |
836 | 836 | $longitude = $this->source_location[$source]['longitude']; |
837 | 837 | } |
838 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
838 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
839 | 839 | //$stats_heading = $stats_heading%22.5; |
840 | 840 | $stats_heading = round($stats_heading/22.5); |
841 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
841 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
842 | 842 | $current_date = date('Y-m-d'); |
843 | 843 | if ($stats_heading == 16) $stats_heading = 0; |
844 | 844 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
845 | - for ($i=0;$i<=15;$i++) { |
|
845 | + for ($i = 0; $i <= 15; $i++) { |
|
846 | 846 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
847 | 847 | } |
848 | 848 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -857,9 +857,9 @@ discard block |
||
857 | 857 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
858 | 858 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
859 | 859 | end($this->stats[$current_date][$source]['hist']); |
860 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
860 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
861 | 861 | } else $mini = 0; |
862 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
862 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
863 | 863 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
864 | 864 | } |
865 | 865 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
873 | 873 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
874 | 874 | if ($globalDebug) echo $result."\n"; |
875 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
875 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
876 | 876 | //$this->del(); |
877 | 877 | |
878 | 878 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute(); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | echo $e->getMessage(); |
165 | 165 | die; |
166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
181 | 181 | date_default_timezone_set('UTC'); |
182 | 182 | |
183 | - $filter_query = $this->getFilter($filter,true,true); |
|
183 | + $filter_query = $this->getFilter($filter, true, true); |
|
184 | 184 | |
185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
186 | 186 | if ($globalDBdriver == 'mysql') { |
187 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
187 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | 190 | } else { |
191 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
191 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | echo $e->getMessage(); |
201 | 201 | die; |
202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
216 | - $filter_query = $this->getFilter($filter,true,true); |
|
216 | + $filter_query = $this->getFilter($filter, true, true); |
|
217 | 217 | |
218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo $e->getMessage(); |
229 | 229 | die; |
230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | $filter_query = $this->getFilter($filter); |
248 | 248 | |
249 | 249 | if (is_array($coord)) { |
250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
254 | 254 | } else return array(); |
255 | 255 | if ($globalDBdriver == 'mysql') { |
256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | if ($interval == '1m') |
303 | 303 | { |
304 | 304 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
305 | - } else if ($interval == '15m'){ |
|
305 | + } else if ($interval == '15m') { |
|
306 | 306 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
307 | 307 | } |
308 | 308 | } |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
311 | 311 | } |
312 | 312 | |
313 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
313 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
314 | 314 | WHERE tracker_live.latitude <> '' |
315 | 315 | AND tracker_live.longitude <> '' |
316 | 316 | ".$additional_query." |
317 | 317 | HAVING distance < :radius |
318 | 318 | ORDER BY distance"; |
319 | 319 | |
320 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
320 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
321 | 321 | |
322 | 322 | return $spotter_array; |
323 | 323 | } |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
338 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
338 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
339 | 339 | |
340 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
340 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
341 | 341 | |
342 | 342 | return $spotter_array; |
343 | 343 | } |
@@ -348,16 +348,16 @@ discard block |
||
348 | 348 | * @return Array the spotter information |
349 | 349 | * |
350 | 350 | */ |
351 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
351 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
352 | 352 | { |
353 | 353 | $Tracker = new Tracker($this->db); |
354 | 354 | date_default_timezone_set('UTC'); |
355 | 355 | |
356 | 356 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
357 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
357 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
358 | 358 | |
359 | - $date = date('c',$date); |
|
360 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
359 | + $date = date('c', $date); |
|
360 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
361 | 361 | |
362 | 362 | return $spotter_array; |
363 | 363 | } |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | |
376 | 376 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
377 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
377 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
378 | 378 | |
379 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
379 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
@@ -387,15 +387,15 @@ discard block |
||
387 | 387 | * @return Array the spotter information |
388 | 388 | * |
389 | 389 | */ |
390 | - public function getDateLiveTrackerDataById($id,$date) |
|
390 | + public function getDateLiveTrackerDataById($id, $date) |
|
391 | 391 | { |
392 | 392 | $Tracker = new Tracker($this->db); |
393 | 393 | date_default_timezone_set('UTC'); |
394 | 394 | |
395 | 395 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
396 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | - $date = date('c',$date); |
|
398 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
396 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | + $date = date('c', $date); |
|
398 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
399 | 399 | |
400 | 400 | return $spotter_array; |
401 | 401 | } |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | date_default_timezone_set('UTC'); |
413 | 413 | |
414 | 414 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
415 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
415 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
416 | 416 | |
417 | 417 | try { |
418 | 418 | |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(array(':ident' => $ident)); |
421 | - } catch(PDOException $e) { |
|
421 | + } catch (PDOException $e) { |
|
422 | 422 | echo $e->getMessage(); |
423 | 423 | die; |
424 | 424 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @return Array the spotter information |
434 | 434 | * |
435 | 435 | */ |
436 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
436 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
439 | 439 | date_default_timezone_set('UTC'); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | try { |
453 | 453 | $sth = $this->db->prepare($query); |
454 | 454 | $sth->execute(array(':id' => $id)); |
455 | - } catch(PDOException $e) { |
|
455 | + } catch (PDOException $e) { |
|
456 | 456 | echo $e->getMessage(); |
457 | 457 | die; |
458 | 458 | } |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | { |
471 | 471 | date_default_timezone_set('UTC'); |
472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
473 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
473 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
474 | 474 | try { |
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(array(':ident' => $ident)); |
478 | - } catch(PDOException $e) { |
|
478 | + } catch (PDOException $e) { |
|
479 | 479 | echo $e->getMessage(); |
480 | 480 | die; |
481 | 481 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | $sth = $this->db->prepare($query); |
507 | 507 | $sth->execute(); |
508 | - } catch(PDOException $e) { |
|
508 | + } catch (PDOException $e) { |
|
509 | 509 | return "error"; |
510 | 510 | } |
511 | 511 | |
@@ -528,14 +528,14 @@ discard block |
||
528 | 528 | |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | return "error"; |
533 | 533 | } |
534 | 534 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
535 | 535 | $i = 0; |
536 | - $j =0; |
|
536 | + $j = 0; |
|
537 | 537 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
538 | - foreach($all as $row) |
|
538 | + foreach ($all as $row) |
|
539 | 539 | { |
540 | 540 | $i++; |
541 | 541 | $j++; |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | if ($globalDebug) echo "."; |
544 | 544 | try { |
545 | 545 | |
546 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
546 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
547 | 547 | $sth->execute(); |
548 | - } catch(PDOException $e) { |
|
548 | + } catch (PDOException $e) { |
|
549 | 549 | return "error"; |
550 | 550 | } |
551 | 551 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -556,9 +556,9 @@ discard block |
||
556 | 556 | if ($i > 0) { |
557 | 557 | try { |
558 | 558 | |
559 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
559 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
560 | 560 | $sth->execute(); |
561 | - } catch(PDOException $e) { |
|
561 | + } catch (PDOException $e) { |
|
562 | 562 | return "error"; |
563 | 563 | } |
564 | 564 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | $sth = $this->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error"; |
576 | 576 | } |
577 | 577 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | public function deleteLiveTrackerDataByIdent($ident) |
620 | 620 | { |
621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
622 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
622 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
623 | 623 | |
624 | 624 | try { |
625 | 625 | |
626 | 626 | $sth = $this->db->prepare($query); |
627 | 627 | $sth->execute(array(':ident' => $ident)); |
628 | - } catch(PDOException $e) { |
|
628 | + } catch (PDOException $e) { |
|
629 | 629 | return "error"; |
630 | 630 | } |
631 | 631 | |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | public function deleteLiveTrackerDataById($id) |
642 | 642 | { |
643 | 643 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
644 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
644 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
645 | 645 | |
646 | 646 | try { |
647 | 647 | |
648 | 648 | $sth = $this->db->prepare($query); |
649 | 649 | $sth->execute(array(':id' => $id)); |
650 | - } catch(PDOException $e) { |
|
650 | + } catch (PDOException $e) { |
|
651 | 651 | return "error"; |
652 | 652 | } |
653 | 653 | |
@@ -665,13 +665,13 @@ discard block |
||
665 | 665 | { |
666 | 666 | global $globalDBdriver, $globalTimezone; |
667 | 667 | if ($globalDBdriver == 'mysql') { |
668 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
668 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
669 | 669 | WHERE tracker_live.ident = :ident |
670 | 670 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
671 | 671 | AND tracker_live.date < UTC_TIMESTAMP()'; |
672 | 672 | $query_data = array(':ident' => $ident); |
673 | 673 | } else { |
674 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
674 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
675 | 675 | WHERE tracker_live.ident = :ident |
676 | 676 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
677 | 677 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | |
681 | 681 | $sth = $this->db->prepare($query); |
682 | 682 | $sth->execute($query_data); |
683 | - $ident_result=''; |
|
684 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
683 | + $ident_result = ''; |
|
684 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
685 | 685 | { |
686 | 686 | $ident_result = $row['ident']; |
687 | 687 | } |
@@ -698,13 +698,13 @@ discard block |
||
698 | 698 | { |
699 | 699 | global $globalDBdriver, $globalTimezone; |
700 | 700 | if ($globalDBdriver == 'mysql') { |
701 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
701 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
702 | 702 | WHERE tracker_live.ident = :ident |
703 | 703 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
704 | 704 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
705 | 705 | $query_data = array(':ident' => $ident); |
706 | 706 | } else { |
707 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
707 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
708 | 708 | WHERE tracker_live.ident = :ident |
709 | 709 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
710 | 710 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | |
714 | 714 | $sth = $this->db->prepare($query); |
715 | 715 | $sth->execute($query_data); |
716 | - $ident_result=''; |
|
717 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
716 | + $ident_result = ''; |
|
717 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
718 | 718 | { |
719 | 719 | $ident_result = $row['famtrackid']; |
720 | 720 | } |
@@ -731,13 +731,13 @@ discard block |
||
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalTimezone; |
733 | 733 | if ($globalDBdriver == 'mysql') { |
734 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
734 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
735 | 735 | WHERE tracker_live.famtrackid = :id |
736 | 736 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
737 | 737 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
738 | 738 | $query_data = array(':id' => $id); |
739 | 739 | } else { |
740 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
740 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
741 | 741 | WHERE tracker_live.famtrackid = :id |
742 | 742 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
743 | 743 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | |
747 | 747 | $sth = $this->db->prepare($query); |
748 | 748 | $sth->execute($query_data); |
749 | - $ident_result=''; |
|
750 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
749 | + $ident_result = ''; |
|
750 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
751 | 751 | { |
752 | 752 | $ident_result = $row['famtrackid']; |
753 | 753 | } |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * @return String success or false |
766 | 766 | * |
767 | 767 | */ |
768 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
768 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
769 | 769 | { |
770 | 770 | global $globalURL, $globalArchive, $globalDebug; |
771 | 771 | $Common = new Common(); |
@@ -824,31 +824,31 @@ discard block |
||
824 | 824 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
825 | 825 | |
826 | 826 | |
827 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
828 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
829 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
832 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
833 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
834 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
835 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
836 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
837 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
838 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
839 | - |
|
840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
827 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
828 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
829 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
831 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
832 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
833 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
834 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
835 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
836 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
837 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
838 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
839 | + |
|
840 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
841 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
842 | 842 | |
843 | - $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
843 | + $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
844 | 844 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
845 | 845 | |
846 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
846 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
847 | 847 | try { |
848 | 848 | |
849 | 849 | $sth = $this->db->prepare($query); |
850 | 850 | $sth->execute($query_values); |
851 | - } catch(PDOException $e) { |
|
851 | + } catch (PDOException $e) { |
|
852 | 852 | return "error : ".$e->getMessage(); |
853 | 853 | } |
854 | 854 | /* |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | public function getOrderBy() |
867 | 867 | { |
868 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
868 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
869 | 869 | return $orderby; |
870 | 870 | } |
871 | 871 |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 37; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver; |
11 | 11 | if ($dbc === null) { |
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | 13 | if ($user === null && $pass === null) { |
14 | 14 | $this->createDBConnection(); |
15 | 15 | } else { |
16 | - $this->createDBConnection(null,$user,$pass); |
|
16 | + $this->createDBConnection(null, $user, $pass); |
|
17 | 17 | } |
18 | 18 | } else { |
19 | 19 | $this->createDBConnection($dbname); |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | while (true) { |
92 | 92 | try { |
93 | 93 | if ($globalDBSdriver == 'mysql') { |
94 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
94 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
95 | 95 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
96 | 96 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
97 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
97 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
98 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
99 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
100 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
101 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
102 | 102 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
103 | 103 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
104 | 104 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
109 | 109 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
110 | 110 | } else { |
111 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
111 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
112 | 112 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
113 | 113 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
114 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
114 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
115 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
116 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
117 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
118 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
119 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
120 | 120 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
121 | 121 | } |
122 | 122 | break; |
123 | - } catch(PDOException $e) { |
|
123 | + } catch (PDOException $e) { |
|
124 | 124 | $i++; |
125 | 125 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
126 | 126 | //exit; |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | try { |
145 | 145 | //$Connection = new Connection(); |
146 | 146 | $results = $this->db->query($query); |
147 | - } catch(PDOException $e) { |
|
147 | + } catch (PDOException $e) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | - if($results->rowCount()>0) { |
|
150 | + if ($results->rowCount() > 0) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | else return false; |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - } catch(PDOException $e) { |
|
172 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
171 | + } catch (PDOException $e) { |
|
172 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
173 | 173 | throw $e; |
174 | 174 | } |
175 | 175 | //echo 'error ! '.$e->getMessage(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | /* |
182 | 182 | * Check if index exist |
183 | 183 | */ |
184 | - public function indexExists($table,$index) |
|
184 | + public function indexExists($table, $index) |
|
185 | 185 | { |
186 | 186 | global $globalDBdriver, $globalDBname; |
187 | 187 | if ($globalDBdriver == 'mysql') { |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | try { |
193 | 193 | //$Connection = new Connection(); |
194 | 194 | $results = $this->db->query($query); |
195 | - } catch(PDOException $e) { |
|
195 | + } catch (PDOException $e) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
199 | - if($nb[0]['nb'] > 0) { |
|
199 | + if ($nb[0]['nb'] > 0) { |
|
200 | 200 | return true; |
201 | 201 | } |
202 | 202 | else return false; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
212 | 212 | try { |
213 | 213 | $results = $this->db->query($query); |
214 | - } catch(PDOException $e) { |
|
214 | + } catch (PDOException $e) { |
|
215 | 215 | return "error : ".$e->getMessage()."\n"; |
216 | 216 | } |
217 | 217 | $columns = array(); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | return $columns; |
224 | 224 | } |
225 | 225 | |
226 | - public function getColumnType($table,$column) { |
|
226 | + public function getColumnType($table, $column) { |
|
227 | 227 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
228 | 228 | $tomet = $select->getColumnMeta(0); |
229 | 229 | return $tomet['native_type']; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * Check if a column name exist in a table |
234 | 234 | * @return Boolean column exist or not |
235 | 235 | */ |
236 | - public function checkColumnName($table,$name) |
|
236 | + public function checkColumnName($table, $name) |
|
237 | 237 | { |
238 | 238 | global $globalDBdriver, $globalDBname; |
239 | 239 | if ($globalDBdriver == 'mysql') { |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | } |
244 | 244 | try { |
245 | 245 | $sth = $this->db()->prepare($query); |
246 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
247 | - } catch(PDOException $e) { |
|
246 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
247 | + } catch (PDOException $e) { |
|
248 | 248 | echo "error : ".$e->getMessage()."\n"; |
249 | 249 | } |
250 | 250 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | return "error : ".$e->getMessage()."\n"; |
288 | 288 | } |
289 | 289 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | try { |
157 | 157 | $sth = $this->db->prepare($query); |
158 | 158 | $sth->execute(); |
159 | - } catch(PDOException $e) { |
|
159 | + } catch (PDOException $e) { |
|
160 | 160 | echo $e->getMessage(); |
161 | 161 | die; |
162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
177 | 177 | date_default_timezone_set('UTC'); |
178 | 178 | |
179 | - $filter_query = $this->getFilter($filter,true,true); |
|
179 | + $filter_query = $this->getFilter($filter, true, true); |
|
180 | 180 | |
181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
182 | 182 | if ($globalDBdriver == 'mysql') { |
183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | 186 | } else { |
187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | try { |
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | - } catch(PDOException $e) { |
|
195 | + } catch (PDOException $e) { |
|
196 | 196 | echo $e->getMessage(); |
197 | 197 | die; |
198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
212 | - $filter_query = $this->getFilter($filter,true,true); |
|
212 | + $filter_query = $this->getFilter($filter, true, true); |
|
213 | 213 | |
214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $sth = $this->db->prepare($query); |
222 | 222 | $sth->execute(); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | echo $e->getMessage(); |
225 | 225 | die; |
226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | $filter_query = $this->getFilter($filter); |
244 | 244 | |
245 | 245 | if (is_array($coord)) { |
246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
250 | 250 | } else return array(); |
251 | 251 | if ($globalDBdriver == 'mysql') { |
252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if ($interval == '1m') |
299 | 299 | { |
300 | 300 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
301 | - } else if ($interval == '15m'){ |
|
301 | + } else if ($interval == '15m') { |
|
302 | 302 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
303 | 303 | } |
304 | 304 | } |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
307 | 307 | } |
308 | 308 | |
309 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
309 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
310 | 310 | WHERE marine_live.latitude <> '' |
311 | 311 | AND marine_live.longitude <> '' |
312 | 312 | ".$additional_query." |
313 | 313 | HAVING distance < :radius |
314 | 314 | ORDER BY distance"; |
315 | 315 | |
316 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
316 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
317 | 317 | |
318 | 318 | return $spotter_array; |
319 | 319 | } |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | date_default_timezone_set('UTC'); |
332 | 332 | |
333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
334 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
334 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
335 | 335 | |
336 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
336 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
337 | 337 | |
338 | 338 | return $spotter_array; |
339 | 339 | } |
@@ -344,16 +344,16 @@ discard block |
||
344 | 344 | * @return Array the spotter information |
345 | 345 | * |
346 | 346 | */ |
347 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
347 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
348 | 348 | { |
349 | 349 | $Marine = new Marine($this->db); |
350 | 350 | date_default_timezone_set('UTC'); |
351 | 351 | |
352 | 352 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
353 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
353 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
354 | 354 | |
355 | - $date = date('c',$date); |
|
356 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
355 | + $date = date('c', $date); |
|
356 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
357 | 357 | |
358 | 358 | return $spotter_array; |
359 | 359 | } |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | date_default_timezone_set('UTC'); |
371 | 371 | |
372 | 372 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
373 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
373 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
374 | 374 | |
375 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
375 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
376 | 376 | |
377 | 377 | return $spotter_array; |
378 | 378 | } |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | * @return Array the spotter information |
384 | 384 | * |
385 | 385 | */ |
386 | - public function getDateLiveMarineDataById($id,$date) |
|
386 | + public function getDateLiveMarineDataById($id, $date) |
|
387 | 387 | { |
388 | 388 | $Marine = new Marine($this->db); |
389 | 389 | date_default_timezone_set('UTC'); |
390 | 390 | |
391 | 391 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
392 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | - $date = date('c',$date); |
|
394 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
392 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | + $date = date('c', $date); |
|
394 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
395 | 395 | |
396 | 396 | return $spotter_array; |
397 | 397 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return Array the spotter information |
404 | 404 | * |
405 | 405 | */ |
406 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
406 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
407 | 407 | { |
408 | 408 | global $globalDBdriver, $globalLiveInterval; |
409 | 409 | date_default_timezone_set('UTC'); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | try { |
423 | 423 | $sth = $this->db->prepare($query); |
424 | 424 | $sth->execute(array(':id' => $id)); |
425 | - } catch(PDOException $e) { |
|
425 | + } catch (PDOException $e) { |
|
426 | 426 | echo $e->getMessage(); |
427 | 427 | die; |
428 | 428 | } |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | { |
441 | 441 | date_default_timezone_set('UTC'); |
442 | 442 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
443 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
443 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
444 | 444 | try { |
445 | 445 | |
446 | 446 | $sth = $this->db->prepare($query); |
447 | 447 | $sth->execute(array(':ident' => $ident)); |
448 | - } catch(PDOException $e) { |
|
448 | + } catch (PDOException $e) { |
|
449 | 449 | echo $e->getMessage(); |
450 | 450 | die; |
451 | 451 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(); |
478 | - } catch(PDOException $e) { |
|
478 | + } catch (PDOException $e) { |
|
479 | 479 | return "error"; |
480 | 480 | } |
481 | 481 | |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | |
499 | 499 | $sth = $this->db->prepare($query); |
500 | 500 | $sth->execute(); |
501 | - } catch(PDOException $e) { |
|
501 | + } catch (PDOException $e) { |
|
502 | 502 | return "error"; |
503 | 503 | } |
504 | 504 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
505 | 505 | $i = 0; |
506 | - $j =0; |
|
506 | + $j = 0; |
|
507 | 507 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
508 | - foreach($all as $row) |
|
508 | + foreach ($all as $row) |
|
509 | 509 | { |
510 | 510 | $i++; |
511 | 511 | $j++; |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | if ($globalDebug) echo "."; |
514 | 514 | try { |
515 | 515 | |
516 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
516 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
517 | 517 | $sth->execute(); |
518 | - } catch(PDOException $e) { |
|
518 | + } catch (PDOException $e) { |
|
519 | 519 | return "error"; |
520 | 520 | } |
521 | 521 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | if ($i > 0) { |
527 | 527 | try { |
528 | 528 | |
529 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
529 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
530 | 530 | $sth->execute(); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | return "error"; |
533 | 533 | } |
534 | 534 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | $sth = $this->db->prepare($query); |
543 | 543 | $sth->execute(); |
544 | - } catch(PDOException $e) { |
|
544 | + } catch (PDOException $e) { |
|
545 | 545 | return "error"; |
546 | 546 | } |
547 | 547 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | public function deleteLiveMarineDataByIdent($ident) |
590 | 590 | { |
591 | 591 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
592 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
592 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
593 | 593 | |
594 | 594 | try { |
595 | 595 | |
596 | 596 | $sth = $this->db->prepare($query); |
597 | 597 | $sth->execute(array(':ident' => $ident)); |
598 | - } catch(PDOException $e) { |
|
598 | + } catch (PDOException $e) { |
|
599 | 599 | return "error"; |
600 | 600 | } |
601 | 601 | |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | public function deleteLiveMarineDataById($id) |
612 | 612 | { |
613 | 613 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
614 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
614 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
615 | 615 | |
616 | 616 | try { |
617 | 617 | |
618 | 618 | $sth = $this->db->prepare($query); |
619 | 619 | $sth->execute(array(':id' => $id)); |
620 | - } catch(PDOException $e) { |
|
620 | + } catch (PDOException $e) { |
|
621 | 621 | return "error"; |
622 | 622 | } |
623 | 623 | |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | { |
636 | 636 | global $globalDBdriver, $globalTimezone; |
637 | 637 | if ($globalDBdriver == 'mysql') { |
638 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
638 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
639 | 639 | WHERE marine_live.ident = :ident |
640 | 640 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
641 | 641 | AND marine_live.date < UTC_TIMESTAMP()'; |
642 | 642 | $query_data = array(':ident' => $ident); |
643 | 643 | } else { |
644 | - $query = "SELECT marine_live.ident FROM marine_live |
|
644 | + $query = "SELECT marine_live.ident FROM marine_live |
|
645 | 645 | WHERE marine_live.ident = :ident |
646 | 646 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
647 | 647 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | |
651 | 651 | $sth = $this->db->prepare($query); |
652 | 652 | $sth->execute($query_data); |
653 | - $ident_result=''; |
|
654 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
653 | + $ident_result = ''; |
|
654 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
655 | 655 | { |
656 | 656 | $ident_result = $row['ident']; |
657 | 657 | } |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | { |
669 | 669 | global $globalDBdriver, $globalTimezone; |
670 | 670 | if ($globalDBdriver == 'mysql') { |
671 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
671 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
672 | 672 | WHERE marine_live.ident = :ident |
673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
674 | 674 | // AND marine_live.date < UTC_TIMESTAMP()"; |
675 | 675 | $query_data = array(':ident' => $ident); |
676 | 676 | } else { |
677 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
677 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
678 | 678 | WHERE marine_live.ident = :ident |
679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
680 | 680 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | |
684 | 684 | $sth = $this->db->prepare($query); |
685 | 685 | $sth->execute($query_data); |
686 | - $ident_result=''; |
|
687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
686 | + $ident_result = ''; |
|
687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
688 | 688 | { |
689 | 689 | $ident_result = $row['fammarine_id']; |
690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
701 | 701 | { |
702 | 702 | global $globalDBdriver, $globalTimezone; |
703 | 703 | if ($globalDBdriver == 'mysql') { |
704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
705 | 705 | WHERE marine_live.fammarine_id = :id |
706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
708 | 708 | $query_data = array(':id' => $id); |
709 | 709 | } else { |
710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
711 | 711 | WHERE marine_live.fammarine_id = :id |
712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | |
717 | 717 | $sth = $this->db->prepare($query); |
718 | 718 | $sth->execute($query_data); |
719 | - $ident_result=''; |
|
720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
719 | + $ident_result = ''; |
|
720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
721 | 721 | { |
722 | 722 | $ident_result = $row['fammarine_id']; |
723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
737 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
738 | 738 | WHERE marine_live.mmsi = :mmsi |
739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
741 | 741 | $query_data = array(':mmsi' => $mmsi); |
742 | 742 | } else { |
743 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
743 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
744 | 744 | WHERE marine_live.mmsi = :mmsi |
745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
752 | + $ident_result = ''; |
|
753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
754 | 754 | { |
755 | 755 | $ident_result = $row['fammarine_id']; |
756 | 756 | } |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @return String success or false |
769 | 769 | * |
770 | 770 | */ |
771 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
771 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
772 | 772 | { |
773 | 773 | global $globalURL, $globalArchive, $globalDebug; |
774 | 774 | $Common = new Common(); |
@@ -820,31 +820,31 @@ discard block |
||
820 | 820 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
821 | 821 | |
822 | 822 | |
823 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
824 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
825 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
826 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
827 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
828 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
829 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
830 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
831 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
832 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
833 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
834 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
835 | - |
|
836 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
837 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
823 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
824 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
825 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
826 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
827 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
828 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
829 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
830 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
831 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
832 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
833 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
834 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
835 | + |
|
836 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
837 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
838 | 838 | |
839 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status) |
|
839 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status) |
|
840 | 840 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status)'; |
841 | 841 | |
842 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status); |
|
842 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status); |
|
843 | 843 | try { |
844 | 844 | |
845 | 845 | $sth = $this->db->prepare($query); |
846 | 846 | $sth->execute($query_values); |
847 | - } catch(PDOException $e) { |
|
847 | + } catch (PDOException $e) { |
|
848 | 848 | return "error : ".$e->getMessage(); |
849 | 849 | } |
850 | 850 | /* |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | |
862 | 862 | public function getOrderBy() |
863 | 863 | { |
864 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
864 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
865 | 865 | return $orderby; |
866 | 866 | } |
867 | 867 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | 51 | $Tracker = new Tracker($this->db); |
52 | - $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']); |
|
52 | + $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']); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | 62 | if (isset($flight['lastupdate'])) { |
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
63 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
64 | 64 | if (isset($this->all_tracked[$key]['id'])) { |
65 | 65 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
66 | 66 | /* |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //$real_arrival = $this->arrival($key); |
72 | 72 | $Tracker = new Tracker($this->db); |
73 | 73 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
74 | - $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']); |
|
74 | + $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']); |
|
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $send = false; |
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | - if(is_array($line) && isset($line['ident'])) { |
|
94 | + if (is_array($line) && isset($line['ident'])) { |
|
95 | 95 | //print_r($line); |
96 | 96 | if (isset($line['ident'])) { |
97 | 97 | |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | 116 | $this->all_tracked[$id] = array(); |
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
120 | 120 | if (!isset($line['id'])) { |
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
122 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
124 | 124 | if ($globalAllTracked !== FALSE) $dataFound = true; |
125 | 125 | } |
126 | 126 | |
127 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
127 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
128 | 128 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
130 | 130 | } else { |
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -134,43 +134,43 @@ discard block |
||
134 | 134 | } |
135 | 135 | } else { |
136 | 136 | date_default_timezone_set('UTC'); |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | //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'])) { |
141 | 141 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
143 | 143 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
144 | 144 | $timeelapsed = microtime(true); |
145 | 145 | $Tracker = new Tracker($this->db); |
146 | 146 | $fromsource = NULL; |
147 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
147 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
148 | 148 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
149 | 149 | $Tracker->db = null; |
150 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
150 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
151 | 151 | } |
152 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
152 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | if (isset($line['speed']) && $line['speed'] != '') { |
156 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
156 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
158 | 158 | } 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'])) { |
159 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
159 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
160 | 160 | if ($distance > 1000 && $distance < 10000) { |
161 | 161 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
162 | 162 | $speed = $speed*3.6; |
163 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
163 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
164 | 164 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
169 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
169 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
170 | 170 | else unset($timediff); |
171 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
171 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
172 | 172 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
173 | - 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'])) { |
|
173 | + 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'])) { |
|
174 | 174 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
175 | 175 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
176 | 176 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
179 | 179 | $timeelapsed = microtime(true); |
180 | 180 | $Tracker = new Tracker($this->db); |
181 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
181 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
182 | 182 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
183 | 183 | $Tracker->db = null; |
184 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
184 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
185 | 185 | $this->tmd = 0; |
186 | 186 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
187 | 187 | } |
@@ -189,73 +189,73 @@ discard block |
||
189 | 189 | |
190 | 190 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
191 | 191 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
192 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
192 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
193 | 193 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
194 | 194 | $dataFound = true; |
195 | 195 | $this->all_tracked[$id]['time_last_coord'] = time(); |
196 | 196 | } |
197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
198 | 198 | } |
199 | 199 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
200 | 200 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
201 | 201 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
202 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
202 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
203 | 203 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
204 | 204 | $dataFound = true; |
205 | 205 | $this->all_tracked[$id]['time_last_coord'] = time(); |
206 | 206 | } |
207 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
207 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | } else if ($globalDebug && $timediff > 20) { |
211 | 211 | $this->tmd = $this->tmd + 1; |
212 | 212 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
213 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
214 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
213 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
214 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
215 | 215 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
216 | 216 | } |
217 | 217 | } |
218 | 218 | if (isset($line['last_update']) && $line['last_update'] != '') { |
219 | 219 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
221 | 221 | } |
222 | 222 | if (isset($line['format_source']) && $line['format_source'] != '') { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
224 | 224 | } |
225 | 225 | if (isset($line['source_name']) && $line['source_name'] != '') { |
226 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
226 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
227 | 227 | } |
228 | 228 | if (isset($line['comment']) && $line['comment'] != '') { |
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
230 | 230 | //$dataFound = true; |
231 | 231 | } |
232 | 232 | if (isset($line['type']) && $line['type'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
234 | 234 | //$dataFound = true; |
235 | 235 | } |
236 | 236 | |
237 | 237 | if (isset($line['altitude']) && $line['altitude'] != '') { |
238 | 238 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
239 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
240 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
|
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
239 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
240 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100))); |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
242 | 242 | //$dataFound = true; |
243 | 243 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | if (isset($line['heading']) && $line['heading'] != '') { |
251 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
253 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
251 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
253 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
254 | 254 | //$dataFound = true; |
255 | 255 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
256 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
258 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
256 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
258 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | 259 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
260 | 260 | } |
261 | 261 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -263,39 +263,39 @@ discard block |
||
263 | 263 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
264 | 264 | $this->all_tracked[$id]['lastupdate'] = time(); |
265 | 265 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
266 | - 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'])) { |
|
266 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
267 | 267 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
268 | 268 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
269 | 269 | $timeelapsed = microtime(true); |
270 | 270 | $TrackerLive = new TrackerLive($this->db); |
271 | 271 | if (isset($line['id'])) { |
272 | 272 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
273 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
273 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
274 | 274 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
275 | 275 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
276 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
276 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
277 | 277 | } else $recent_ident = ''; |
278 | - $TrackerLive->db=null; |
|
278 | + $TrackerLive->db = null; |
|
279 | 279 | |
280 | 280 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
281 | 281 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
282 | 282 | } else { |
283 | 283 | $recent_ident = ''; |
284 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
284 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
285 | 285 | } |
286 | 286 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
287 | - if($recent_ident == "") |
|
287 | + if ($recent_ident == "") |
|
288 | 288 | { |
289 | 289 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
290 | 290 | //adds the spotter data for the archive |
291 | 291 | $highlight = ''; |
292 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
292 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
293 | 293 | $timeelapsed = microtime(true); |
294 | 294 | $Tracker = new Tracker($this->db); |
295 | - $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']); |
|
295 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
296 | 296 | $Tracker->db = null; |
297 | 297 | if ($globalDebug && isset($result)) echo $result."\n"; |
298 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
298 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
299 | 299 | |
300 | 300 | /* |
301 | 301 | // Add source stat in DB |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
334 | 334 | $TrackerLive = new TrackerLive($this->db); |
335 | 335 | $TrackerLive->deleteLiveTrackerData(); |
336 | - $TrackerLive->db=null; |
|
336 | + $TrackerLive->db = null; |
|
337 | 337 | if ($globalDebug) echo " Done\n"; |
338 | 338 | $this->last_delete = time(); |
339 | 339 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $this->all_tracked[$id]['addedTracker'] = 1; |
343 | 343 | if (isset($globalDaemon) && !$globalDaemon) { |
344 | 344 | $Tracker = new Tracker($this->db); |
345 | - $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']); |
|
345 | + $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']); |
|
346 | 346 | $Tracker->db = null; |
347 | 347 | } |
348 | 348 | |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | $ignoreImport = false; |
357 | 357 | |
358 | 358 | if (!$ignoreImport) { |
359 | - 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'])) { |
|
359 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
360 | 360 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
361 | 361 | $timeelapsed = microtime(true); |
362 | 362 | $TrackerLive = new TrackerLive($this->db); |
363 | - $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']); |
|
363 | + $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
364 | 364 | $TrackerLive->db = null; |
365 | 365 | $this->all_tracked[$id]['putinarchive'] = false; |
366 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
366 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
367 | 367 | |
368 | 368 | // Put statistics in $this->stats variable |
369 | 369 | /* |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $this->all_tracked[$id]['lastupdate'] = time(); |
423 | 423 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
424 | 424 | if ($globalDebug) echo $result."\n"; |
425 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
425 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
426 | 426 | //$this->del(); |
427 | 427 | |
428 | 428 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime); |
|
17 | 17 | /* |
18 | 18 | if (empty($spotter_array)) { |
19 | 19 | $from_archive = true; |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | if (isset($_GET['famtrackid'])) { |
34 | - $famtrackid = filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING); |
|
34 | + $famtrackid = filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING); |
|
35 | 35 | if (isset($_GET['currenttime'])) { |
36 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
36 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
37 | 37 | $currenttime = round($currenttime/1000); |
38 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime); |
|
38 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime); |
|
39 | 39 | /* |
40 | 40 | if (empty($spotter_array)) { |
41 | 41 | $from_archive = true; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
63 | 63 | { |
64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
65 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
65 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
66 | 66 | } else $image = $spotter_item['image_thumbnail']; |
67 | 67 | |
68 | 68 | } |