@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if (isset($this->all_tracked[$key]['id'])) { |
| 51 | 51 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 52 | 52 | $Marine = new Marine($this->db); |
| 53 | - $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 | + $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']); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 62 | 62 | foreach ($this->all_tracked as $key => $flight) { |
| 63 | 63 | if (isset($flight['lastupdate'])) { |
| 64 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 64 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 65 | 65 | if (isset($this->all_tracked[$key]['id'])) { |
| 66 | 66 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
| 67 | 67 | /* |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | //$real_arrival = $this->arrival($key); |
| 73 | 73 | $Marine = new Marine($this->db); |
| 74 | 74 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 75 | - $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 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']); |
|
| 76 | 76 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 77 | 77 | } |
| 78 | 78 | // Put in archive |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $send = false; |
| 93 | 93 | |
| 94 | 94 | // SBS format is CSV format |
| 95 | - if(is_array($line) && isset($line['mmsi'])) { |
|
| 95 | + if (is_array($line) && isset($line['mmsi'])) { |
|
| 96 | 96 | //print_r($line); |
| 97 | 97 | if (isset($line['mmsi'])) { |
| 98 | 98 | |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | if (!isset($this->all_tracked[$id])) { |
| 118 | 118 | $this->all_tracked[$id] = array(); |
| 119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 120 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '')); |
|
| 121 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 120 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '')); |
|
| 121 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 122 | 122 | if (!isset($line['id'])) { |
| 123 | 123 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 124 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 125 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 124 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 125 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 126 | 126 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 131 | 131 | $Marine = new Marine($this->db); |
| 132 | 132 | $identity = $Marine->getIdentity($line['mmsi']); |
| 133 | 133 | if (!empty($identity)) { |
@@ -139,59 +139,59 @@ discard block |
||
| 139 | 139 | //$dataFound = true; |
| 140 | 140 | } |
| 141 | 141 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 143 | 143 | } |
| 144 | 144 | if (isset($line['type']) && $line['type'] != '') { |
| 145 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 146 | 146 | } |
| 147 | 147 | if (isset($line['imo']) && $line['imo'] != '') { |
| 148 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 148 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 149 | 149 | } |
| 150 | 150 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 152 | 152 | } |
| 153 | 153 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | //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'])) { |
| 162 | 162 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 164 | 164 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 165 | 165 | $timeelapsed = microtime(true); |
| 166 | 166 | $Marine = new Marine($this->db); |
| 167 | 167 | $fromsource = NULL; |
| 168 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 168 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 169 | 169 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 170 | 170 | $Marine->db = null; |
| 171 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 171 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 172 | 172 | } |
| 173 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 173 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if (isset($line['speed']) && $line['speed'] != '') { |
| 177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 179 | 179 | } 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'])) { |
| 180 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 180 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 181 | 181 | if ($distance > 1000 && $distance < 10000) { |
| 182 | 182 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 183 | 183 | $speed = $speed*3.6; |
| 184 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 184 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 185 | 185 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 190 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 190 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 191 | 191 | else unset($timediff); |
| 192 | - 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')))) { |
|
| 192 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
| 193 | 193 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 194 | - 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'])) { |
|
| 194 | + 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'])) { |
|
| 195 | 195 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 196 | 196 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 197 | 197 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 200 | 200 | $timeelapsed = microtime(true); |
| 201 | 201 | $Marine = new Marine($this->db); |
| 202 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 202 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 203 | 203 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 204 | 204 | $Marine->db = null; |
| 205 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 205 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 206 | 206 | $this->tmd = 0; |
| 207 | 207 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 208 | 208 | } |
@@ -210,66 +210,66 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 212 | 212 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 213 | - 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') { |
|
| 213 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 214 | 214 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 215 | 215 | $dataFound = true; |
| 216 | 216 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 217 | 217 | } |
| 218 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 218 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 219 | 219 | } |
| 220 | 220 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 221 | 221 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 222 | 222 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 223 | - 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') { |
|
| 223 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 224 | 224 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 225 | 225 | $dataFound = true; |
| 226 | 226 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 227 | 227 | } |
| 228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | } else if ($globalDebug && $timediff > 20) { |
| 232 | 232 | $this->tmd = $this->tmd + 1; |
| 233 | 233 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 234 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 235 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 234 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 235 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 236 | 236 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 240 | 240 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 242 | 242 | } |
| 243 | 243 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 244 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 244 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 245 | 245 | } |
| 246 | 246 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 248 | 248 | } |
| 249 | 249 | if (isset($line['status']) && $line['status'] != '') { |
| 250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | if (isset($line['heading']) && $line['heading'] != '') { |
| 258 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 259 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 258 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 259 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 261 | 261 | //$dataFound = true; |
| 262 | 262 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 263 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 264 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 265 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 263 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 264 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 265 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 266 | 266 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 267 | 267 | } |
| 268 | 268 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 269 | 269 | |
| 270 | 270 | if (isset($line['datetime'])) { |
| 271 | 271 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 272 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 273 | 273 | } else { |
| 274 | 274 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 275 | 275 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -277,48 +277,48 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } else { |
| 279 | 279 | date_default_timezone_set('UTC'); |
| 280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | |
| 284 | 284 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 285 | 285 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 286 | 286 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 287 | - 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'])) { |
|
| 287 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 288 | 288 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 289 | 289 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 290 | 290 | $timeelapsed = microtime(true); |
| 291 | 291 | $MarineLive = new MarineLive($this->db); |
| 292 | 292 | if (isset($line['id'])) { |
| 293 | 293 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 294 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 294 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 295 | 295 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 296 | 296 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 297 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 297 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 298 | 298 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 299 | 299 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 300 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 300 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 301 | 301 | } else $recent_ident = ''; |
| 302 | - $MarineLive->db=null; |
|
| 302 | + $MarineLive->db = null; |
|
| 303 | 303 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 304 | 304 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 305 | 305 | } else { |
| 306 | 306 | $recent_ident = ''; |
| 307 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 307 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 308 | 308 | } |
| 309 | 309 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 310 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 310 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 311 | 311 | { |
| 312 | 312 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 313 | 313 | //adds the spotter data for the archive |
| 314 | 314 | $highlight = ''; |
| 315 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 315 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 316 | 316 | $timeelapsed = microtime(true); |
| 317 | 317 | $Marine = new Marine($this->db); |
| 318 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 318 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 319 | 319 | $Marine->db = null; |
| 320 | 320 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 321 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 321 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 322 | 322 | |
| 323 | 323 | /* |
| 324 | 324 | // Add source stat in DB |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 357 | 357 | $MarineLive = new MarineLive($this->db); |
| 358 | 358 | $MarineLive->deleteLiveMarineData(); |
| 359 | - $MarineLive->db=null; |
|
| 359 | + $MarineLive->db = null; |
|
| 360 | 360 | if ($globalDebug) echo " Done\n"; |
| 361 | 361 | $this->last_delete = time(); |
| 362 | 362 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 366 | 366 | if (isset($globalDaemon) && !$globalDaemon) { |
| 367 | 367 | $Marine = new Marine($this->db); |
| 368 | - $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']); |
|
| 368 | + $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']); |
|
| 369 | 369 | $Marine->db = null; |
| 370 | 370 | } |
| 371 | 371 | |
@@ -379,14 +379,14 @@ discard block |
||
| 379 | 379 | $ignoreImport = false; |
| 380 | 380 | |
| 381 | 381 | if (!$ignoreImport) { |
| 382 | - 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'])) { |
|
| 382 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 383 | 383 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 384 | 384 | $timeelapsed = microtime(true); |
| 385 | 385 | $MarineLive = new MarineLive($this->db); |
| 386 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 386 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 387 | 387 | $MarineLive->db = null; |
| 388 | 388 | $this->all_tracked[$id]['putinarchive'] = false; |
| 389 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 389 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 390 | 390 | |
| 391 | 391 | // Put statistics in $this->stats variable |
| 392 | 392 | /* |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 446 | 446 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 447 | 447 | if ($globalDebug) echo $result."\n"; |
| 448 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 448 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 449 | 449 | //$this->del(); |
| 450 | 450 | |
| 451 | 451 | |
@@ -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 = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$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 = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 772 | 772 | { |
| 773 | 773 | global $globalURL, $globalArchive, $globalDebug; |
| 774 | 774 | $Common = new Common(); |
@@ -820,36 +820,36 @@ 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 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 836 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 837 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 838 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 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 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 836 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 837 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 838 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 839 | 839 | |
| 840 | 840 | |
| 841 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 842 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 841 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 842 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 843 | 843 | if ($arrival_date == '') $arrival_date = NULL; |
| 844 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 844 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 845 | 845 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 846 | 846 | |
| 847 | - $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,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 847 | + $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, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 848 | 848 | try { |
| 849 | 849 | |
| 850 | 850 | $sth = $this->db->prepare($query); |
| 851 | 851 | $sth->execute($query_values); |
| 852 | - } catch(PDOException $e) { |
|
| 852 | + } catch (PDOException $e) { |
|
| 853 | 853 | return "error : ".$e->getMessage(); |
| 854 | 854 | } |
| 855 | 855 | /* |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | public function getOrderBy() |
| 868 | 868 | { |
| 869 | - $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")); |
|
| 869 | + $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")); |
|
| 870 | 870 | return $orderby; |
| 871 | 871 | } |
| 872 | 872 | |
@@ -14,12 +14,12 @@ discard block |
||
| 14 | 14 | * @param Array $headers header to submit with the form |
| 15 | 15 | * @return String the result |
| 16 | 16 | */ |
| 17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
| 17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
| 18 | 18 | global $globalProxy, $globalForceIPv4; |
| 19 | 19 | $ch = curl_init(); |
| 20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
| 21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
| 22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
| 23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
| 32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
| 33 | 33 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
| 35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
| 41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
| 42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
| 42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
| 43 | 43 | if ($type == 'post') { |
| 44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
| 45 | 45 | if (is_array($data)) { |
| 46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
| 47 | 47 | $data_string = ''; |
| 48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 49 | 49 | rtrim($data_string, '&'); |
| 50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
| 51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | if ($cookie != '') { |
| 59 | 59 | if (is_array($cookie)) { |
| 60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
| 60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
| 61 | 61 | } else { |
| 62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
| 63 | 63 | } |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | $info = curl_getinfo($ch); |
| 70 | 70 | //var_dump($info); |
| 71 | 71 | curl_close($ch); |
| 72 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
| 72 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
| 73 | 73 | echo "Cloudflare Detected\n"; |
| 74 | 74 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
| 75 | 75 | $useragent = UAgent::random(); |
| 76 | 76 | cloudflare::useUserAgent($useragent); |
| 77 | 77 | if ($clearanceCookie = cloudflare::bypass($url)) { |
| 78 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
| 78 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
| 79 | 79 | } |
| 80 | 80 | } else { |
| 81 | 81 | return $result; |
@@ -116,27 +116,27 @@ discard block |
||
| 116 | 116 | if ($data == '') return array(); |
| 117 | 117 | $html = str_get_html($data); |
| 118 | 118 | if ($html === false) return array(); |
| 119 | - $tabledata=array(); |
|
| 120 | - foreach($html->find('tr') as $element) |
|
| 119 | + $tabledata = array(); |
|
| 120 | + foreach ($html->find('tr') as $element) |
|
| 121 | 121 | { |
| 122 | 122 | $td = array(); |
| 123 | - foreach( $element->find('th') as $row) |
|
| 123 | + foreach ($element->find('th') as $row) |
|
| 124 | 124 | { |
| 125 | 125 | $td [] = trim($row->plaintext); |
| 126 | 126 | } |
| 127 | - $td=array_filter($td); |
|
| 127 | + $td = array_filter($td); |
|
| 128 | 128 | $tabledata[] = $td; |
| 129 | 129 | |
| 130 | 130 | $td = array(); |
| 131 | 131 | $tdi = array(); |
| 132 | - foreach( $element->find('td') as $row) |
|
| 132 | + foreach ($element->find('td') as $row) |
|
| 133 | 133 | { |
| 134 | 134 | $td [] = trim($row->plaintext); |
| 135 | 135 | $tdi [] = trim($row->innertext); |
| 136 | 136 | } |
| 137 | - $td=array_filter($td); |
|
| 138 | - $tdi=array_filter($tdi); |
|
| 139 | - $tabledata[]=array_merge($td,$tdi); |
|
| 137 | + $td = array_filter($td); |
|
| 138 | + $tdi = array_filter($tdi); |
|
| 139 | + $tabledata[] = array_merge($td, $tdi); |
|
| 140 | 140 | } |
| 141 | 141 | $html->clear(); |
| 142 | 142 | unset($html); |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | public function text2array($data) { |
| 152 | 152 | $html = str_get_html($data); |
| 153 | 153 | if ($html === false) return array(); |
| 154 | - $tabledata=array(); |
|
| 155 | - foreach($html->find('p') as $element) |
|
| 154 | + $tabledata = array(); |
|
| 155 | + foreach ($html->find('p') as $element) |
|
| 156 | 156 | { |
| 157 | 157 | $tabledata [] = trim($element->plaintext); |
| 158 | 158 | } |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
| 175 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
| 175 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
| 176 | 176 | if ($unit == "km") { |
| 177 | - return round($dist * 1.609344); |
|
| 177 | + return round($dist*1.609344); |
|
| 178 | 178 | } elseif ($unit == "m") { |
| 179 | - return round($dist * 1.609344 * 1000); |
|
| 179 | + return round($dist*1.609344*1000); |
|
| 180 | 180 | } elseif ($unit == "mile" || $unit == "mi") { |
| 181 | 181 | return round($dist); |
| 182 | 182 | } elseif ($unit == "nm") { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param float $distance distance covered |
| 193 | 193 | * @return whether distance is realistic |
| 194 | 194 | */ |
| 195 | - public function withinThreshold ($timeDifference, $distance) { |
|
| 195 | + public function withinThreshold($timeDifference, $distance) { |
|
| 196 | 196 | $x = abs($timeDifference); |
| 197 | 197 | $d = abs($distance); |
| 198 | 198 | if ($x == 0 || $d == 0) return true; |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | return ($array !== array_values($array)); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function isInteger($input){ |
|
| 211 | + public function isInteger($input) { |
|
| 212 | 212 | return(ctype_digit(strval($input))); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
| 216 | - public function convertDec($dms,$latlong) { |
|
| 216 | + public function convertDec($dms, $latlong) { |
|
| 217 | 217 | if ($latlong == 'latitude') { |
| 218 | 218 | $deg = substr($dms, 0, 2); |
| 219 | 219 | $min = substr($dms, 2, 4); |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | $deg = substr($dms, 0, 3); |
| 222 | 222 | $min = substr($dms, 3, 5); |
| 223 | 223 | } |
| 224 | - return $deg+(($min*60)/3600); |
|
| 224 | + return $deg + (($min*60)/3600); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public function convertDM($coord,$latlong) { |
|
| 227 | + public function convertDM($coord, $latlong) { |
|
| 228 | 228 | if ($latlong == 'latitude') { |
| 229 | 229 | if ($coord < 0) $NSEW = 'S'; |
| 230 | 230 | else $NSEW = 'N'; |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | $coord = abs($coord); |
| 236 | 236 | $deg = floor($coord); |
| 237 | - $coord = ($coord-$deg)*60; |
|
| 237 | + $coord = ($coord - $deg)*60; |
|
| 238 | 238 | $min = $coord; |
| 239 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
| 239 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | public function xcopy($source, $dest) |
| 249 | 249 | { |
| 250 | 250 | $files = glob($source.'*.*'); |
| 251 | - foreach($files as $file){ |
|
| 252 | - $file_to_go = str_replace($source,$dest,$file); |
|
| 251 | + foreach ($files as $file) { |
|
| 252 | + $file_to_go = str_replace($source, $dest, $file); |
|
| 253 | 253 | copy($file, $file_to_go); |
| 254 | 254 | } |
| 255 | 255 | return true; |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | * @param String $url url to check |
| 261 | 261 | * @return bool Return true on succes false on failure |
| 262 | 262 | */ |
| 263 | - public function urlexist($url){ |
|
| 264 | - $headers=get_headers($url); |
|
| 265 | - return stripos($headers[0],"200 OK")?true:false; |
|
| 263 | + public function urlexist($url) { |
|
| 264 | + $headers = get_headers($url); |
|
| 265 | + return stripos($headers[0], "200 OK") ? true : false; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | public function hex2str($hex) { |
| 274 | 274 | $str = ''; |
| 275 | 275 | $hexln = strlen($hex); |
| 276 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 276 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
| 277 | 277 | return $str; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -282,33 +282,33 @@ discard block |
||
| 282 | 282 | //difference in longitudinal coordinates |
| 283 | 283 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
| 284 | 284 | //difference in the phi of latitudinal coordinates |
| 285 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
| 285 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
| 286 | 286 | //we need to recalculate $dLon if it is greater than pi |
| 287 | - if(abs($dLon) > pi()) { |
|
| 288 | - if($dLon > 0) { |
|
| 289 | - $dLon = (2 * pi() - $dLon) * -1; |
|
| 287 | + if (abs($dLon) > pi()) { |
|
| 288 | + if ($dLon > 0) { |
|
| 289 | + $dLon = (2*pi() - $dLon)*-1; |
|
| 290 | 290 | } else { |
| 291 | - $dLon = 2 * pi() + $dLon; |
|
| 291 | + $dLon = 2*pi() + $dLon; |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | //return the angle, normalized |
| 295 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
| 295 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
| 298 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
| 299 | 299 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
| 300 | - $a = -($lon2-$lon1); |
|
| 300 | + $a = -($lon2 - $lon1); |
|
| 301 | 301 | $b = $lat2 - $lat1; |
| 302 | - $c = -($a*$lat1+$b*$lon1); |
|
| 303 | - $d = $a*$lat3+$b*$lon3+$c; |
|
| 302 | + $c = -($a*$lat1 + $b*$lon1); |
|
| 303 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
| 304 | 304 | if ($d > -$approx && $d < $approx) return true; |
| 305 | 305 | else return false; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | public function array_merge_noappend() { |
| 309 | 309 | $output = array(); |
| 310 | - foreach(func_get_args() as $array) { |
|
| 311 | - foreach($array as $key => $value) { |
|
| 310 | + foreach (func_get_args() as $array) { |
|
| 311 | + foreach ($array as $key => $value) { |
|
| 312 | 312 | $output[$key] = isset($output[$key]) ? |
| 313 | 313 | array_merge($output[$key], $value) : $value; |
| 314 | 314 | } |
@@ -372,34 +372,34 @@ discard block |
||
| 372 | 372 | return $result; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
| 375 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
| 376 | 376 | global $globalMapRefresh; |
| 377 | 377 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
| 378 | 378 | $r = 6378; |
| 379 | 379 | $latitude = deg2rad($latitude); |
| 380 | 380 | $longitude = deg2rad($longitude); |
| 381 | 381 | $bearing = deg2rad($heading); |
| 382 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
| 383 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
| 384 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
| 382 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
| 383 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
| 384 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
| 387 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
| 388 | 388 | // distance in meter |
| 389 | 389 | $R = 6378.14; |
| 390 | - $latitude1 = $latitude * (M_PI/180); |
|
| 391 | - $longitude1 = $longitude * (M_PI/180); |
|
| 392 | - $brng = $bearing * (M_PI/180); |
|
| 390 | + $latitude1 = $latitude*(M_PI/180); |
|
| 391 | + $longitude1 = $longitude*(M_PI/180); |
|
| 392 | + $brng = $bearing*(M_PI/180); |
|
| 393 | 393 | $d = $distance; |
| 394 | 394 | |
| 395 | 395 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
| 396 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
| 396 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
| 397 | 397 | |
| 398 | - $latitude2 = $latitude2 * (180/M_PI); |
|
| 399 | - $longitude2 = $longitude2 * (180/M_PI); |
|
| 398 | + $latitude2 = $latitude2*(180/M_PI); |
|
| 399 | + $longitude2 = $longitude2*(180/M_PI); |
|
| 400 | 400 | |
| 401 | - $flat = round ($latitude2,6); |
|
| 402 | - $flong = round ($longitude2,6); |
|
| 401 | + $flat = round($latitude2, 6); |
|
| 402 | + $flong = round($longitude2, 6); |
|
| 403 | 403 | /* |
| 404 | 404 | $dx = $distance*cos($bearing); |
| 405 | 405 | $dy = $distance*sin($bearing); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | $flong = $longitude + $dlong; |
| 409 | 409 | $flat = $latitude + $dlat; |
| 410 | 410 | */ |
| 411 | - return array('latitude' => $flat,'longitude' => $flong); |
|
| 411 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -422,14 +422,14 @@ discard block |
||
| 422 | 422 | * @param integer $level GZIP compression level (default: 9) |
| 423 | 423 | * @return string New filename (with .gz appended) if success, or false if operation fails |
| 424 | 424 | */ |
| 425 | - public function gzCompressFile($source, $level = 9){ |
|
| 426 | - $dest = $source . '.gz'; |
|
| 427 | - $mode = 'wb' . $level; |
|
| 425 | + public function gzCompressFile($source, $level = 9) { |
|
| 426 | + $dest = $source.'.gz'; |
|
| 427 | + $mode = 'wb'.$level; |
|
| 428 | 428 | $error = false; |
| 429 | 429 | if ($fp_out = gzopen($dest, $mode)) { |
| 430 | - if ($fp_in = fopen($source,'rb')) { |
|
| 430 | + if ($fp_in = fopen($source, 'rb')) { |
|
| 431 | 431 | while (!feof($fp_in)) |
| 432 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 432 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
| 433 | 433 | fclose($fp_in); |
| 434 | 434 | } else { |
| 435 | 435 | $error = true; |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | public function remove_accents($string) { |
| 448 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 448 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
| 449 | 449 | $chars = array( |
| 450 | 450 | // Decompositions for Latin-1 Supplement |
| 451 | 451 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
| 503 | 503 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
| 504 | 504 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
| 505 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 505 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
| 506 | 506 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
| 507 | 507 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
| 508 | 508 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -518,13 +518,13 @@ discard block |
||
| 518 | 518 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
| 519 | 519 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
| 520 | 520 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
| 521 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 522 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 523 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 524 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 525 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 526 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 527 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 521 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
| 522 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
| 523 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
| 524 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
| 525 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
| 526 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
| 527 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
| 528 | 528 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
| 529 | 529 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
| 530 | 530 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
| 559 | 559 | if (is_numeric($string[$i]) && $concat_flag) { |
| 560 | 560 | $int .= $string[$i]; |
| 561 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
| 561 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
| 562 | 562 | $concat_flag = false; |
| 563 | 563 | } |
| 564 | 564 | } |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | $currentdate = date('Y-m-d'); |
| 31 | 31 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 32 | 32 | if (!empty($sourcestat)) { |
| 33 | - foreach($sourcestat as $srcst) { |
|
| 33 | + foreach ($sourcestat as $srcst) { |
|
| 34 | 34 | $type = $srcst['stats_type']; |
| 35 | 35 | if ($type == 'polar' || $type == 'hist') { |
| 36 | 36 | $source = $srcst['source_name']; |
| 37 | 37 | $data = $srcst['source_data']; |
| 38 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 38 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function get_Schedule($id,$ident) { |
|
| 49 | + public function get_Schedule($id, $ident) { |
|
| 50 | 50 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 51 | 51 | // Get schedule here, so it's done only one time |
| 52 | 52 | |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | $schedule = $Schedule->fetchSchedule($operator); |
| 72 | 72 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 73 | 73 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 74 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 75 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 74 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 75 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 76 | 76 | // Should also check if route schedule = route from DB |
| 77 | 77 | if ($schedule['DepartureAirportIATA'] != '') { |
| 78 | 78 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - $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']); |
|
| 95 | + $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']); |
|
| 96 | 96 | } |
| 97 | 97 | } else $scheduleexist = true; |
| 98 | 98 | } else $scheduleexist = true; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if ($scheduleexist) { |
| 101 | 101 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 102 | 102 | $sch = $Schedule->getSchedule($operator); |
| 103 | - $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'])); |
|
| 103 | + $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'])); |
|
| 104 | 104 | } |
| 105 | 105 | $Spotter->db = null; |
| 106 | 106 | $Schedule->db = null; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 128 | 128 | $Spotter = new Spotter($this->db); |
| 129 | 129 | $real_arrival = $this->arrival($key); |
| 130 | - $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']); |
|
| 130 | + $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']); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $airport_time = ''; |
| 142 | 142 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 143 | 143 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 144 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 144 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 145 | 145 | if (isset($closestAirports[0])) { |
| 146 | 146 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 147 | 147 | $airport_icao = $closestAirports[0]['icao']; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | break; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - } 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))) { |
|
| 159 | + } 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))) { |
|
| 160 | 160 | $airport_icao = $closestAirports[0]['icao']; |
| 161 | 161 | $airport_time = $this->all_flights[$key]['datetime']; |
| 162 | 162 | } else { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } else { |
| 170 | 170 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 171 | 171 | } |
| 172 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 172 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 181 | 181 | foreach ($this->all_flights as $key => $flight) { |
| 182 | 182 | if (isset($flight['lastupdate'])) { |
| 183 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 183 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 184 | 184 | if (isset($this->all_flights[$key]['id'])) { |
| 185 | 185 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
| 186 | 186 | /* |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $real_arrival = $this->arrival($key); |
| 193 | 193 | $Spotter = new Spotter($this->db); |
| 194 | 194 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 195 | - $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']); |
|
| 195 | + $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']); |
|
| 196 | 196 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 197 | 197 | } |
| 198 | 198 | // Put in archive |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $send = false; |
| 230 | 230 | |
| 231 | 231 | // SBS format is CSV format |
| 232 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 232 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
| 233 | 233 | //print_r($line); |
| 234 | 234 | 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)) { |
| 235 | 235 | |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | if (!isset($this->all_flights[$id])) { |
| 264 | 264 | $this->all_flights[$id] = array(); |
| 265 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 266 | - $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' => '')); |
|
| 267 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 265 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 266 | + $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' => '')); |
|
| 267 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 268 | 268 | if (!isset($line['id'])) { |
| 269 | 269 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 270 | 270 | // 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'))); |
| 271 | 271 | // 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'))); |
| 272 | - 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'))); |
|
| 272 | + 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'))); |
|
| 273 | 273 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 274 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 274 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 275 | 275 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 276 | 276 | } |
| 277 | 277 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 278 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
| 278 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | //print_r($this->all_flights); |
| 282 | 282 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 283 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 283 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 284 | 284 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 285 | 285 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 286 | 286 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -288,41 +288,41 @@ discard block |
||
| 288 | 288 | $timeelapsed = microtime(true); |
| 289 | 289 | $Spotter = new Spotter($this->db); |
| 290 | 290 | if (isset($this->all_flights[$id]['source_type'])) { |
| 291 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
| 291 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
| 292 | 292 | } else { |
| 293 | 293 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 294 | 294 | } |
| 295 | 295 | $Spotter->db = null; |
| 296 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 297 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 296 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 297 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 298 | 298 | } |
| 299 | 299 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 300 | 300 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 301 | 301 | } |
| 302 | 302 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 303 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 303 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 304 | 304 | } |
| 305 | 305 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 306 | 306 | // Get aircraft ICAO from aircraft name |
| 307 | 307 | $Spotter = new Spotter($this->db); |
| 308 | 308 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 309 | 309 | $Spotter->db = null; |
| 310 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 310 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 311 | 311 | } |
| 312 | 312 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 313 | 313 | if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
| 314 | 314 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 315 | 315 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 316 | 316 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 317 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 317 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 318 | 318 | } |
| 319 | 319 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 321 | 321 | } |
| 322 | 322 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 323 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
| 323 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
| 324 | 324 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 325 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 325 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 326 | 326 | } else { |
| 327 | 327 | 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"; |
| 328 | 328 | 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"; |
@@ -335,24 +335,24 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | } else { |
| 337 | 337 | date_default_timezone_set('UTC'); |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 342 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 342 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 343 | 343 | } |
| 344 | 344 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 346 | 346 | } |
| 347 | 347 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
| 349 | 349 | } |
| 350 | 350 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | 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'])) { |
| 355 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 355 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 356 | 356 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 357 | 357 | $timeelapsed = microtime(true); |
| 358 | 358 | $Spotter = new Spotter($this->db); |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 363 | 363 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 364 | 364 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 365 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 365 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 366 | 366 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 367 | 367 | $Spotter->db = null; |
| 368 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 368 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /* |
@@ -376,24 +376,24 @@ discard block |
||
| 376 | 376 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 377 | 377 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 378 | 378 | */ |
| 379 | - 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'])); |
|
| 379 | + 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'])); |
|
| 380 | 380 | |
| 381 | 381 | //$putinarchive = true; |
| 382 | 382 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 384 | 384 | } |
| 385 | 385 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 387 | 387 | } |
| 388 | 388 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 389 | - $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' => '')); |
|
| 389 | + $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' => '')); |
|
| 390 | 390 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 391 | 391 | $timeelapsed = microtime(true); |
| 392 | 392 | $Spotter = new Spotter($this->db); |
| 393 | 393 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 394 | 394 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 395 | - $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' => '')); |
|
| 396 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 395 | + $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' => '')); |
|
| 396 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 397 | 397 | |
| 398 | 398 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 399 | 399 | $timeelapsed = microtime(true); |
@@ -406,34 +406,34 @@ discard block |
||
| 406 | 406 | $Translation->db = null; |
| 407 | 407 | } |
| 408 | 408 | $Spotter->db = null; |
| 409 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 409 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 410 | 410 | |
| 411 | 411 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 412 | 412 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 413 | 413 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 414 | 414 | // $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'])); |
| 415 | - $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'])); |
|
| 415 | + $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'])); |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | if (!isset($globalFork)) $globalFork = TRUE; |
| 419 | 419 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 420 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 420 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | if (isset($line['speed']) && $line['speed'] != '') { |
| 426 | 426 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 427 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 428 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 427 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 428 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 429 | 429 | //$dataFound = true; |
| 430 | 430 | } 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'])) { |
| 431 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 431 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 432 | 432 | if ($distance > 1000 && $distance < 10000) { |
| 433 | 433 | // use datetime |
| 434 | 434 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 435 | 435 | $speed = $speed*3.6; |
| 436 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 436 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 437 | 437 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 444 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 444 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 445 | 445 | else unset($timediff); |
| 446 | - 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')))) { |
|
| 446 | + 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')))) { |
|
| 447 | 447 | 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'])) { |
| 448 | - 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'])) { |
|
| 448 | + 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'])) { |
|
| 449 | 449 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 450 | 450 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 451 | 451 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -453,10 +453,10 @@ discard block |
||
| 453 | 453 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 454 | 454 | $timeelapsed = microtime(true); |
| 455 | 455 | $Spotter = new Spotter($this->db); |
| 456 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 456 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 457 | 457 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 458 | 458 | $Spotter->db = null; |
| 459 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 459 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 460 | 460 | $this->tmd = 0; |
| 461 | 461 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 462 | 462 | } |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 466 | 466 | //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) { |
| 467 | 467 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 468 | - 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') { |
|
| 468 | + 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') { |
|
| 469 | 469 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 470 | 470 | $dataFound = true; |
| 471 | 471 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 472 | 472 | } |
| 473 | 473 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 474 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 474 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 475 | 475 | /* |
| 476 | 476 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 477 | 477 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -489,13 +489,13 @@ discard block |
||
| 489 | 489 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 490 | 490 | //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) { |
| 491 | 491 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 492 | - 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') { |
|
| 492 | + 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') { |
|
| 493 | 493 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 494 | 494 | $dataFound = true; |
| 495 | 495 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 496 | 496 | } |
| 497 | 497 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 498 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 498 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 499 | 499 | /* |
| 500 | 500 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 501 | 501 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -513,46 +513,46 @@ discard block |
||
| 513 | 513 | } else if ($globalDebug && $timediff > 20) { |
| 514 | 514 | $this->tmd = $this->tmd + 1; |
| 515 | 515 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 516 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 517 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 516 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 517 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 518 | 518 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 522 | 522 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 523 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 523 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 524 | 524 | } |
| 525 | 525 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 526 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 526 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 527 | 527 | //$dataFound = true; |
| 528 | 528 | } |
| 529 | 529 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 530 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 530 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 531 | 531 | } |
| 532 | 532 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 533 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 533 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 534 | 534 | } |
| 535 | 535 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 536 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 536 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 537 | 537 | //$dataFound = true; |
| 538 | 538 | } |
| 539 | 539 | if (isset($line['ground']) && $line['ground'] != '') { |
| 540 | 540 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 541 | 541 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 542 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 543 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 544 | - 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'))); |
|
| 545 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 546 | - 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'])); |
|
| 542 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 543 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 544 | + 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'))); |
|
| 545 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 546 | + 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'])); |
|
| 547 | 547 | } |
| 548 | 548 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 550 | 550 | //$dataFound = true; |
| 551 | 551 | } |
| 552 | 552 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 553 | 553 | 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'])) { |
| 554 | 554 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 555 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 555 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 556 | 556 | $highlight = ''; |
| 557 | 557 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 558 | 558 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -560,47 +560,47 @@ discard block |
||
| 560 | 560 | if ($highlight != '') { |
| 561 | 561 | $timeelapsed = microtime(true); |
| 562 | 562 | $Spotter = new Spotter($this->db); |
| 563 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 563 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 564 | 564 | $Spotter->db = null; |
| 565 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 565 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 566 | 566 | |
| 567 | 567 | //$putinarchive = true; |
| 568 | 568 | //$highlight = ''; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 571 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 572 | 572 | //$dataFound = true; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 576 | 576 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 577 | - 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; |
|
| 578 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 579 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 577 | + 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; |
|
| 578 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 579 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 580 | 580 | //$dataFound = true; |
| 581 | 581 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 585 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 585 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | if (isset($line['heading']) && $line['heading'] != '') { |
| 589 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 590 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 591 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 589 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 590 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 591 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 592 | 592 | //$dataFound = true; |
| 593 | 593 | } 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']) { |
| 594 | - $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']); |
|
| 595 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 596 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 594 | + $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']); |
|
| 595 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 596 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 597 | 597 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
| 598 | 598 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 599 | 599 | // If not enough messages and ACARS set heading to 0 |
| 600 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 600 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 601 | 601 | } |
| 602 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 603 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 602 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 603 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 604 | 604 | |
| 605 | 605 | // print_r($this->all_flights[$id]); |
| 606 | 606 | //gets the callsign from the last hour |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 611 | 611 | $this->all_flights[$id]['lastupdate'] = time(); |
| 612 | 612 | if ($this->all_flights[$id]['addedSpotter'] == 0) { |
| 613 | - 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'])) { |
|
| 613 | + 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'])) { |
|
| 614 | 614 | //print_r($this->all_flights); |
| 615 | 615 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 616 | 616 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -620,61 +620,61 @@ discard block |
||
| 620 | 620 | $SpotterLive = new SpotterLive($this->db); |
| 621 | 621 | 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')) { |
| 622 | 622 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 623 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 623 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 624 | 624 | } elseif (isset($line['id'])) { |
| 625 | 625 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 626 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 626 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 627 | 627 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 628 | 628 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 629 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 629 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 630 | 630 | } else $recent_ident = ''; |
| 631 | - $SpotterLive->db=null; |
|
| 631 | + $SpotterLive->db = null; |
|
| 632 | 632 | |
| 633 | 633 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 634 | 634 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 635 | 635 | } else { |
| 636 | 636 | $recent_ident = ''; |
| 637 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 637 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 638 | 638 | } |
| 639 | 639 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 640 | - if($recent_ident == "") |
|
| 640 | + if ($recent_ident == "") |
|
| 641 | 641 | { |
| 642 | 642 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 643 | 643 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 644 | 644 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 645 | 645 | //adds the spotter data for the archive |
| 646 | 646 | $ignoreImport = false; |
| 647 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 647 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 648 | 648 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 649 | 649 | $ignoreImport = true; |
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | if (count($globalAirportAccept) > 0) { |
| 653 | 653 | $ignoreImport = true; |
| 654 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 654 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 655 | 655 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 656 | 656 | $ignoreImport = false; |
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 661 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 662 | - 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)) { |
|
| 661 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 662 | + 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)) { |
|
| 663 | 663 | $ignoreImport = true; |
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 668 | 668 | $ignoreImport = true; |
| 669 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 670 | - 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)) { |
|
| 669 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 670 | + 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)) { |
|
| 671 | 671 | $ignoreImport = false; |
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 676 | 676 | $ignoreImport = true; |
| 677 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 677 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 678 | 678 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 679 | 679 | $ignoreImport = false; |
| 680 | 680 | } |
@@ -686,29 +686,29 @@ discard block |
||
| 686 | 686 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 687 | 687 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 688 | 688 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 689 | - 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'))); |
|
| 689 | + 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'))); |
|
| 690 | 690 | $timeelapsed = microtime(true); |
| 691 | 691 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 692 | 692 | $Spotter = new Spotter($this->db); |
| 693 | - $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']); |
|
| 693 | + $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']); |
|
| 694 | 694 | $Spotter->db = null; |
| 695 | 695 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 696 | 696 | } |
| 697 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 697 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 698 | 698 | |
| 699 | 699 | // Add source stat in DB |
| 700 | 700 | $Stats = new Stats($this->db); |
| 701 | 701 | if (!empty($this->stats)) { |
| 702 | 702 | if ($globalDebug) echo 'Add source stats : '; |
| 703 | - foreach($this->stats as $date => $data) { |
|
| 704 | - foreach($data as $source => $sourced) { |
|
| 703 | + foreach ($this->stats as $date => $data) { |
|
| 704 | + foreach ($data as $source => $sourced) { |
|
| 705 | 705 | //print_r($sourced); |
| 706 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 707 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 706 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 707 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 708 | 708 | if (isset($sourced['msg'])) { |
| 709 | 709 | if (time() - $sourced['msg']['date'] > 10) { |
| 710 | 710 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 711 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 711 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 712 | 712 | unset($this->stats[$date][$source]['msg']); |
| 713 | 713 | } |
| 714 | 714 | } |
@@ -745,20 +745,20 @@ discard block |
||
| 745 | 745 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 746 | 746 | $SpotterLive = new SpotterLive($this->db); |
| 747 | 747 | $SpotterLive->deleteLiveSpotterData(); |
| 748 | - $SpotterLive->db=null; |
|
| 748 | + $SpotterLive->db = null; |
|
| 749 | 749 | } |
| 750 | 750 | if ($globalDebug) echo " Done\n"; |
| 751 | 751 | $this->last_delete = time(); |
| 752 | 752 | } |
| 753 | 753 | } else { |
| 754 | - 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')) { |
|
| 754 | + 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')) { |
|
| 755 | 755 | $this->all_flights[$id]['id'] = $recent_ident; |
| 756 | 756 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 757 | 757 | } |
| 758 | 758 | if (isset($globalDaemon) && !$globalDaemon) { |
| 759 | 759 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 760 | 760 | $Spotter = new Spotter($this->db); |
| 761 | - $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']); |
|
| 761 | + $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']); |
|
| 762 | 762 | $Spotter->db = null; |
| 763 | 763 | } |
| 764 | 764 | } |
@@ -783,37 +783,37 @@ discard block |
||
| 783 | 783 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 784 | 784 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 785 | 785 | |
| 786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 786 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 788 | 788 | $ignoreImport = true; |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | if (count($globalAirportAccept) > 0) { |
| 792 | 792 | $ignoreImport = true; |
| 793 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 793 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 794 | 794 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 795 | 795 | $ignoreImport = false; |
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 800 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 801 | - 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)) { |
|
| 800 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 801 | + 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)) { |
|
| 802 | 802 | $ignoreImport = true; |
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 807 | 807 | $ignoreImport = true; |
| 808 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 809 | - 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)) { |
|
| 808 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 809 | + 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)) { |
|
| 810 | 810 | $ignoreImport = false; |
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 815 | 815 | $ignoreImport = true; |
| 816 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 816 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 817 | 817 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 818 | 818 | $ignoreImport = false; |
| 819 | 819 | } |
@@ -821,19 +821,19 @@ discard block |
||
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | if (!$ignoreImport) { |
| 824 | - 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'])) { |
|
| 824 | + 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'])) { |
|
| 825 | 825 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 826 | 826 | $timeelapsed = microtime(true); |
| 827 | 827 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 828 | 828 | $SpotterLive = new SpotterLive($this->db); |
| 829 | - $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']); |
|
| 829 | + $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']); |
|
| 830 | 830 | $SpotterLive->db = null; |
| 831 | 831 | } |
| 832 | 832 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 833 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['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']); |
|
| 833 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['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']); |
|
| 834 | 834 | } |
| 835 | 835 | $this->all_flights[$id]['putinarchive'] = false; |
| 836 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 836 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 837 | 837 | |
| 838 | 838 | // Put statistics in $this->stats variable |
| 839 | 839 | //if ($line['format_source'] != 'aprs') { |
@@ -851,19 +851,19 @@ discard block |
||
| 851 | 851 | $latitude = $globalCenterLatitude; |
| 852 | 852 | $longitude = $globalCenterLongitude; |
| 853 | 853 | } |
| 854 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 854 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 855 | 855 | } else { |
| 856 | 856 | $latitude = $this->source_location[$source]['latitude']; |
| 857 | 857 | $longitude = $this->source_location[$source]['longitude']; |
| 858 | 858 | } |
| 859 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 859 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 860 | 860 | //$stats_heading = $stats_heading%22.5; |
| 861 | 861 | $stats_heading = round($stats_heading/22.5); |
| 862 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 862 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 863 | 863 | $current_date = date('Y-m-d'); |
| 864 | 864 | if ($stats_heading == 16) $stats_heading = 0; |
| 865 | 865 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 866 | - for ($i=0;$i<=15;$i++) { |
|
| 866 | + for ($i = 0; $i <= 15; $i++) { |
|
| 867 | 867 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 868 | 868 | } |
| 869 | 869 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -878,9 +878,9 @@ discard block |
||
| 878 | 878 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 879 | 879 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 880 | 880 | end($this->stats[$current_date][$source]['hist']); |
| 881 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 881 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 882 | 882 | } else $mini = 0; |
| 883 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 883 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 884 | 884 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 885 | 885 | } |
| 886 | 886 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 894 | 894 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 895 | 895 | if ($globalDebug) echo $result."\n"; |
| 896 | - } 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"; |
|
| 896 | + } 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"; |
|
| 897 | 897 | //$this->del(); |
| 898 | 898 | |
| 899 | 899 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 5 | 5 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 6 | 6 | |
| 7 | -class Marine{ |
|
| 7 | +class Marine { |
|
| 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 fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 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(); |
@@ -169,17 +169,17 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 171 | 171 | } else { |
| 172 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 172 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 173 | 173 | } |
| 174 | 174 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 175 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 176 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 175 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 176 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 177 | 177 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 178 | 178 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 179 | 179 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 180 | 180 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 181 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 182 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 181 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 182 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 183 | 183 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $limit_array = explode(",", $limit); |
| 218 | 218 | |
| 219 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 220 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 219 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 220 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 221 | 221 | |
| 222 | 222 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 223 | 223 | { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 237 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 238 | 238 | |
| 239 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 239 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 240 | 240 | |
| 241 | 241 | return $spotter_array; |
| 242 | 242 | } |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | if ($id == '') return array(); |
| 256 | 256 | $additional_query = "marine_output.fammarine_id = :id"; |
| 257 | 257 | $query_values = array(':id' => $id); |
| 258 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 259 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 258 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 259 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 260 | 260 | return $spotter_array; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $query_values = array(); |
| 276 | 276 | $limit_query = ''; |
| 277 | 277 | $additional_query = ''; |
| 278 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 278 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 279 | 279 | if ($ident != "") |
| 280 | 280 | { |
| 281 | 281 | if (!is_string($ident)) |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | $limit_array = explode(",", $limit); |
| 293 | 293 | |
| 294 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 295 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 294 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 295 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 296 | 296 | |
| 297 | 297 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 298 | 298 | { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | return $spotter_array; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 319 | + public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 320 | 320 | { |
| 321 | 321 | global $global_query, $globalTimezone, $globalDBdriver; |
| 322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $limit_query = ''; |
| 325 | 325 | $additional_query = ''; |
| 326 | 326 | |
| 327 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 327 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 328 | 328 | |
| 329 | 329 | if ($date != "") |
| 330 | 330 | { |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | $limit_array = explode(",", $limit); |
| 352 | 352 | |
| 353 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 354 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 353 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 354 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 355 | 355 | |
| 356 | 356 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 357 | 357 | { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | * @return Array list of source name |
| 383 | 383 | * |
| 384 | 384 | */ |
| 385 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 385 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 386 | 386 | { |
| 387 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 387 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 388 | 388 | $query_values = array(); |
| 389 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 389 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 390 | 390 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 391 | 391 | if ($type != '') { |
| 392 | 392 | $query_values = array(':type' => $type); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $source_array = array(); |
| 402 | 402 | $temp_array = array(); |
| 403 | 403 | |
| 404 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 404 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 405 | 405 | { |
| 406 | 406 | $temp_array['source_name'] = $row['source_name']; |
| 407 | 407 | $source_array[] = $temp_array; |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function getAllIdents($filters = array()) |
| 420 | 420 | { |
| 421 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 422 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 421 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 422 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 423 | 423 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 424 | 424 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $ident_array = array(); |
| 430 | 430 | $temp_array = array(); |
| 431 | 431 | |
| 432 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 432 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 433 | 433 | { |
| 434 | 434 | $temp_array['ident'] = $row['ident']; |
| 435 | 435 | $ident_array[] = $temp_array; |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | public function getIdentity($mmsi) |
| 448 | 448 | { |
| 449 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 449 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 450 | 450 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 451 | 451 | $sth = $this->db->prepare($query); |
| 452 | 452 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | } else $offset = '+00:00'; |
| 472 | 472 | |
| 473 | 473 | if ($globalDBdriver == 'mysql') { |
| 474 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 474 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 475 | 475 | FROM marine_output |
| 476 | 476 | WHERE marine_output.date <> '' |
| 477 | 477 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 478 | 478 | } else { |
| 479 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 479 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 480 | 480 | FROM marine_output |
| 481 | 481 | WHERE marine_output.date <> '' |
| 482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $date_array = array(); |
| 489 | 489 | $temp_array = array(); |
| 490 | 490 | |
| 491 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 491 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 492 | 492 | { |
| 493 | 493 | $temp_array['date'] = $row['date']; |
| 494 | 494 | |
@@ -507,11 +507,11 @@ discard block |
||
| 507 | 507 | * @return String success or false |
| 508 | 508 | * |
| 509 | 509 | */ |
| 510 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 510 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 511 | 511 | { |
| 512 | 512 | |
| 513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 514 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 515 | 515 | |
| 516 | 516 | try { |
| 517 | 517 | $sth = $this->db->prepare($query); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 535 | 535 | { |
| 536 | 536 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 537 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 538 | 538 | |
| 539 | 539 | try { |
| 540 | 540 | $sth = $this->db->prepare($query); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * @param String $verticalrate vertival rate of flight |
| 573 | 573 | * @return String success or false |
| 574 | 574 | */ |
| 575 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
|
| 575 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '') |
|
| 576 | 576 | { |
| 577 | 577 | global $globalURL; |
| 578 | 578 | |
@@ -639,25 +639,25 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | |
| 642 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 642 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 643 | 643 | { |
| 644 | 644 | $date = date("Y-m-d H:i:s", time()); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 648 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 649 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 650 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 652 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 653 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 654 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 655 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 656 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 657 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 658 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 659 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 660 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 647 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 648 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 649 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 650 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 652 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 653 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 654 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 655 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 656 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 657 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 658 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 659 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 660 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 661 | 661 | |
| 662 | 662 | if ($latitude == '' && $longitude == '') { |
| 663 | 663 | $latitude = 0; |
@@ -666,10 +666,10 @@ discard block |
||
| 666 | 666 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 667 | 667 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 668 | 668 | if ($arrival_date == '') $arrival_date = NULL; |
| 669 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 669 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 670 | 670 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 671 | 671 | |
| 672 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 672 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 673 | 673 | try { |
| 674 | 674 | |
| 675 | 675 | $sth = $this->db->prepare($query); |
@@ -694,13 +694,13 @@ discard block |
||
| 694 | 694 | { |
| 695 | 695 | global $globalDBdriver, $globalTimezone; |
| 696 | 696 | if ($globalDBdriver == 'mysql') { |
| 697 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 697 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 698 | 698 | WHERE marine_output.ident = :ident |
| 699 | 699 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 700 | 700 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 701 | 701 | $query_data = array(':ident' => $ident); |
| 702 | 702 | } else { |
| 703 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 703 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 704 | 704 | WHERE marine_output.ident = :ident |
| 705 | 705 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 706 | 706 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | $sth = $this->db->prepare($query); |
| 711 | 711 | $sth->execute($query_data); |
| 712 | - $ident_result=''; |
|
| 713 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 712 | + $ident_result = ''; |
|
| 713 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 714 | 714 | { |
| 715 | 715 | $ident_result = $row['ident']; |
| 716 | 716 | } |
@@ -736,8 +736,8 @@ discard block |
||
| 736 | 736 | return false; |
| 737 | 737 | } else { |
| 738 | 738 | $q_array = explode(" ", $q); |
| 739 | - foreach ($q_array as $q_item){ |
|
| 740 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 739 | + foreach ($q_array as $q_item) { |
|
| 740 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 741 | 741 | $additional_query .= " AND ("; |
| 742 | 742 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 743 | 743 | $additional_query .= ")"; |
@@ -745,11 +745,11 @@ discard block |
||
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | 747 | if ($globalDBdriver == 'mysql') { |
| 748 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 748 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 749 | 749 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 750 | 750 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 751 | 751 | } else { |
| 752 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 752 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 753 | 753 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 754 | 754 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 755 | 755 | } |
@@ -822,11 +822,11 @@ discard block |
||
| 822 | 822 | * @return Array the callsign list |
| 823 | 823 | * |
| 824 | 824 | */ |
| 825 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 825 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 826 | 826 | { |
| 827 | 827 | global $globalDBdriver; |
| 828 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 829 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 828 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 829 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 830 | 830 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 831 | 831 | if ($olderthanmonths > 0) { |
| 832 | 832 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -840,28 +840,28 @@ discard block |
||
| 840 | 840 | if ($year != '') { |
| 841 | 841 | if ($globalDBdriver == 'mysql') { |
| 842 | 842 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 843 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 843 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 844 | 844 | } else { |
| 845 | 845 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 846 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 846 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 847 | 847 | } |
| 848 | 848 | } |
| 849 | 849 | if ($month != '') { |
| 850 | 850 | if ($globalDBdriver == 'mysql') { |
| 851 | 851 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 852 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 852 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 853 | 853 | } else { |
| 854 | 854 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 855 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 855 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | if ($day != '') { |
| 859 | 859 | if ($globalDBdriver == 'mysql') { |
| 860 | 860 | $query .= " AND DAY(marine_output.date) = :day"; |
| 861 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 861 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 862 | 862 | } else { |
| 863 | 863 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 864 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 864 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | $callsign_array = array(); |
| 874 | 874 | $temp_array = array(); |
| 875 | 875 | |
| 876 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 876 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 877 | 877 | { |
| 878 | 878 | $temp_array['callsign_icao'] = $row['ident']; |
| 879 | 879 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | $date_array = array(); |
| 926 | 926 | $temp_array = array(); |
| 927 | 927 | |
| 928 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 928 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 929 | 929 | { |
| 930 | 930 | $temp_array['date_name'] = $row['date_name']; |
| 931 | 931 | $temp_array['date_count'] = $row['date_count']; |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | $datetime = new DateTime(); |
| 952 | 952 | $offset = $datetime->format('P'); |
| 953 | 953 | } else $offset = '+00:00'; |
| 954 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 954 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 955 | 955 | if ($globalDBdriver == 'mysql') { |
| 956 | 956 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 957 | 957 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | $date_array = array(); |
| 973 | 973 | $temp_array = array(); |
| 974 | 974 | |
| 975 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 975 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 976 | 976 | { |
| 977 | 977 | $temp_array['date_name'] = $row['date_name']; |
| 978 | 978 | $temp_array['date_count'] = $row['date_count']; |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | $datetime = new DateTime(); |
| 998 | 998 | $offset = $datetime->format('P'); |
| 999 | 999 | } else $offset = '+00:00'; |
| 1000 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1000 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1001 | 1001 | if ($globalDBdriver == 'mysql') { |
| 1002 | 1002 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1003 | 1003 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | $date_array = array(); |
| 1019 | 1019 | $temp_array = array(); |
| 1020 | 1020 | |
| 1021 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1021 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | $temp_array['date_name'] = $row['date_name']; |
| 1024 | 1024 | $temp_array['date_count'] = $row['date_count']; |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | $date_array = array(); |
| 1066 | 1066 | $temp_array = array(); |
| 1067 | 1067 | |
| 1068 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1068 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1069 | 1069 | { |
| 1070 | 1070 | $temp_array['month_name'] = $row['month_name']; |
| 1071 | 1071 | $temp_array['year_name'] = $row['year_name']; |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | $datetime = new DateTime(); |
| 1095 | 1095 | $offset = $datetime->format('P'); |
| 1096 | 1096 | } else $offset = '+00:00'; |
| 1097 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1097 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1098 | 1098 | if ($globalDBdriver == 'mysql') { |
| 1099 | 1099 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1100 | 1100 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | $date_array = array(); |
| 1116 | 1116 | $temp_array = array(); |
| 1117 | 1117 | |
| 1118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1119 | 1119 | { |
| 1120 | 1120 | $temp_array['year_name'] = $row['year_name']; |
| 1121 | 1121 | $temp_array['month_name'] = $row['month_name']; |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | * @return Array the hour list |
| 1136 | 1136 | * |
| 1137 | 1137 | */ |
| 1138 | - public function countAllHours($orderby,$filters = array()) |
|
| 1138 | + public function countAllHours($orderby, $filters = array()) |
|
| 1139 | 1139 | { |
| 1140 | 1140 | global $globalTimezone, $globalDBdriver; |
| 1141 | 1141 | if ($globalTimezone != '') { |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $hour_array = array(); |
| 1184 | 1184 | $temp_array = array(); |
| 1185 | 1185 | |
| 1186 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1186 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1187 | 1187 | { |
| 1188 | 1188 | $temp_array['hour_name'] = $row['hour_name']; |
| 1189 | 1189 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1205,8 +1205,8 @@ discard block |
||
| 1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
| 1206 | 1206 | { |
| 1207 | 1207 | global $globalTimezone, $globalDBdriver; |
| 1208 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1209 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1208 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1209 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1210 | 1210 | if ($globalTimezone != '') { |
| 1211 | 1211 | date_default_timezone_set($globalTimezone); |
| 1212 | 1212 | $datetime = new DateTime($date); |
@@ -1214,12 +1214,12 @@ discard block |
||
| 1214 | 1214 | } else $offset = '+00:00'; |
| 1215 | 1215 | |
| 1216 | 1216 | if ($globalDBdriver == 'mysql') { |
| 1217 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1217 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1218 | 1218 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1219 | 1219 | GROUP BY hour_name |
| 1220 | 1220 | ORDER BY hour_name ASC"; |
| 1221 | 1221 | } else { |
| 1222 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1222 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1223 | 1223 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1224 | 1224 | GROUP BY hour_name |
| 1225 | 1225 | ORDER BY hour_name ASC"; |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | $hour_array = array(); |
| 1232 | 1232 | $temp_array = array(); |
| 1233 | 1233 | |
| 1234 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1234 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1235 | 1235 | { |
| 1236 | 1236 | $temp_array['hour_name'] = $row['hour_name']; |
| 1237 | 1237 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1253,8 +1253,8 @@ discard block |
||
| 1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1254 | 1254 | { |
| 1255 | 1255 | global $globalTimezone, $globalDBdriver; |
| 1256 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1257 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1256 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1257 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1258 | 1258 | if ($globalTimezone != '') { |
| 1259 | 1259 | date_default_timezone_set($globalTimezone); |
| 1260 | 1260 | $datetime = new DateTime(); |
@@ -1262,12 +1262,12 @@ discard block |
||
| 1262 | 1262 | } else $offset = '+00:00'; |
| 1263 | 1263 | |
| 1264 | 1264 | if ($globalDBdriver == 'mysql') { |
| 1265 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1265 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1266 | 1266 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1267 | 1267 | GROUP BY hour_name |
| 1268 | 1268 | ORDER BY hour_name ASC"; |
| 1269 | 1269 | } else { |
| 1270 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1270 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1271 | 1271 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1272 | 1272 | GROUP BY hour_name |
| 1273 | 1273 | ORDER BY hour_name ASC"; |
@@ -1275,12 +1275,12 @@ discard block |
||
| 1275 | 1275 | |
| 1276 | 1276 | |
| 1277 | 1277 | $sth = $this->db->prepare($query); |
| 1278 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1278 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1279 | 1279 | |
| 1280 | 1280 | $hour_array = array(); |
| 1281 | 1281 | $temp_array = array(); |
| 1282 | 1282 | |
| 1283 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1283 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1284 | 1284 | { |
| 1285 | 1285 | $temp_array['hour_name'] = $row['hour_name']; |
| 1286 | 1286 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1299,32 +1299,32 @@ discard block |
||
| 1299 | 1299 | * @return Integer the number of flights |
| 1300 | 1300 | * |
| 1301 | 1301 | */ |
| 1302 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
| 1302 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
| 1303 | 1303 | { |
| 1304 | 1304 | global $globalDBdriver; |
| 1305 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1305 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1306 | 1306 | $query_values = array(); |
| 1307 | 1307 | $query = ''; |
| 1308 | 1308 | if ($year != '') { |
| 1309 | 1309 | if ($globalDBdriver == 'mysql') { |
| 1310 | 1310 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1311 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1311 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1312 | 1312 | } else { |
| 1313 | 1313 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1314 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1314 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | } |
| 1317 | 1317 | if ($month != '') { |
| 1318 | 1318 | if ($globalDBdriver == 'mysql') { |
| 1319 | 1319 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1320 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1320 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1321 | 1321 | } else { |
| 1322 | 1322 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1323 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1323 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1324 | 1324 | } |
| 1325 | 1325 | } |
| 1326 | 1326 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1327 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1327 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1328 | 1328 | |
| 1329 | 1329 | $sth = $this->db->prepare($queryi); |
| 1330 | 1330 | $sth->execute($query_values); |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | public function countAllHoursFromToday($filters = array()) |
| 1342 | 1342 | { |
| 1343 | 1343 | global $globalTimezone, $globalDBdriver; |
| 1344 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1344 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1345 | 1345 | if ($globalTimezone != '') { |
| 1346 | 1346 | date_default_timezone_set($globalTimezone); |
| 1347 | 1347 | $datetime = new DateTime(); |
@@ -1349,12 +1349,12 @@ discard block |
||
| 1349 | 1349 | } else $offset = '+00:00'; |
| 1350 | 1350 | |
| 1351 | 1351 | if ($globalDBdriver == 'mysql') { |
| 1352 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1352 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1353 | 1353 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1354 | 1354 | GROUP BY hour_name |
| 1355 | 1355 | ORDER BY hour_name ASC"; |
| 1356 | 1356 | } else { |
| 1357 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1357 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1358 | 1358 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1359 | 1359 | GROUP BY hour_name |
| 1360 | 1360 | ORDER BY hour_name ASC"; |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | $hour_array = array(); |
| 1367 | 1367 | $temp_array = array(); |
| 1368 | 1368 | |
| 1369 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1369 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1370 | 1370 | { |
| 1371 | 1371 | $temp_array['hour_name'] = $row['hour_name']; |
| 1372 | 1372 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1385,9 +1385,9 @@ discard block |
||
| 1385 | 1385 | */ |
| 1386 | 1386 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1387 | 1387 | { |
| 1388 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1388 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1389 | 1389 | |
| 1390 | - $query = "SELECT marine_output.marine_id |
|
| 1390 | + $query = "SELECT marine_output.marine_id |
|
| 1391 | 1391 | FROM marine_output |
| 1392 | 1392 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1393 | 1393 | |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | $sth = $this->db->prepare($query); |
| 1396 | 1396 | $sth->execute(); |
| 1397 | 1397 | |
| 1398 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1398 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1399 | 1399 | { |
| 1400 | 1400 | return $row['marine_id']; |
| 1401 | 1401 | } |
@@ -1420,23 +1420,23 @@ discard block |
||
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | 1422 | $current_date = date("Y-m-d H:i:s"); |
| 1423 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1423 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1424 | 1424 | |
| 1425 | 1425 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1426 | 1426 | |
| 1427 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1427 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1428 | 1428 | $years = $time_array['years']; |
| 1429 | 1429 | |
| 1430 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1430 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1431 | 1431 | $months = $time_array['months']; |
| 1432 | 1432 | |
| 1433 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1433 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1434 | 1434 | $days = $time_array['days']; |
| 1435 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1435 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1436 | 1436 | $hours = $time_array['hours']; |
| 1437 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1437 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1438 | 1438 | $minutes = $time_array['minutes']; |
| 1439 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1439 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1440 | 1440 | |
| 1441 | 1441 | return $time_array; |
| 1442 | 1442 | } |
@@ -1459,63 +1459,63 @@ discard block |
||
| 1459 | 1459 | $temp_array['direction_degree'] = $direction; |
| 1460 | 1460 | $temp_array['direction_shortname'] = "N"; |
| 1461 | 1461 | $temp_array['direction_fullname'] = "North"; |
| 1462 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1462 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1463 | 1463 | $temp_array['direction_degree'] = $direction; |
| 1464 | 1464 | $temp_array['direction_shortname'] = "NNE"; |
| 1465 | 1465 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1466 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1466 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1467 | 1467 | $temp_array['direction_degree'] = $direction; |
| 1468 | 1468 | $temp_array['direction_shortname'] = "NE"; |
| 1469 | 1469 | $temp_array['direction_fullname'] = "Northeast"; |
| 1470 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1470 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1471 | 1471 | $temp_array['direction_degree'] = $direction; |
| 1472 | 1472 | $temp_array['direction_shortname'] = "ENE"; |
| 1473 | 1473 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1474 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1474 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1475 | 1475 | $temp_array['direction_degree'] = $direction; |
| 1476 | 1476 | $temp_array['direction_shortname'] = "E"; |
| 1477 | 1477 | $temp_array['direction_fullname'] = "East"; |
| 1478 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1478 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1479 | 1479 | $temp_array['direction_degree'] = $direction; |
| 1480 | 1480 | $temp_array['direction_shortname'] = "ESE"; |
| 1481 | 1481 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1482 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1482 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1483 | 1483 | $temp_array['direction_degree'] = $direction; |
| 1484 | 1484 | $temp_array['direction_shortname'] = "SE"; |
| 1485 | 1485 | $temp_array['direction_fullname'] = "Southeast"; |
| 1486 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1486 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1487 | 1487 | $temp_array['direction_degree'] = $direction; |
| 1488 | 1488 | $temp_array['direction_shortname'] = "SSE"; |
| 1489 | 1489 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1490 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1490 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1491 | 1491 | $temp_array['direction_degree'] = $direction; |
| 1492 | 1492 | $temp_array['direction_shortname'] = "S"; |
| 1493 | 1493 | $temp_array['direction_fullname'] = "South"; |
| 1494 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1494 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1495 | 1495 | $temp_array['direction_degree'] = $direction; |
| 1496 | 1496 | $temp_array['direction_shortname'] = "SSW"; |
| 1497 | 1497 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1498 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1498 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1499 | 1499 | $temp_array['direction_degree'] = $direction; |
| 1500 | 1500 | $temp_array['direction_shortname'] = "SW"; |
| 1501 | 1501 | $temp_array['direction_fullname'] = "Southwest"; |
| 1502 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1502 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1503 | 1503 | $temp_array['direction_degree'] = $direction; |
| 1504 | 1504 | $temp_array['direction_shortname'] = "WSW"; |
| 1505 | 1505 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1506 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1506 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1507 | 1507 | $temp_array['direction_degree'] = $direction; |
| 1508 | 1508 | $temp_array['direction_shortname'] = "W"; |
| 1509 | 1509 | $temp_array['direction_fullname'] = "West"; |
| 1510 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1510 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1511 | 1511 | $temp_array['direction_degree'] = $direction; |
| 1512 | 1512 | $temp_array['direction_shortname'] = "WNW"; |
| 1513 | 1513 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1514 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1514 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1515 | 1515 | $temp_array['direction_degree'] = $direction; |
| 1516 | 1516 | $temp_array['direction_shortname'] = "NW"; |
| 1517 | 1517 | $temp_array['direction_fullname'] = "Northwest"; |
| 1518 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1518 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1519 | 1519 | $temp_array['direction_degree'] = $direction; |
| 1520 | 1520 | $temp_array['direction_shortname'] = "NNW"; |
| 1521 | 1521 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1532,11 +1532,11 @@ discard block |
||
| 1532 | 1532 | * @param Float $longitude longitute of the flight |
| 1533 | 1533 | * @return String the countrie |
| 1534 | 1534 | */ |
| 1535 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1535 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1536 | 1536 | { |
| 1537 | 1537 | global $globalDBdriver, $globalDebug; |
| 1538 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1539 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1538 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1539 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1540 | 1540 | |
| 1541 | 1541 | $Connection = new Connection($this->db); |
| 1542 | 1542 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1576,7 +1576,7 @@ discard block |
||
| 1576 | 1576 | public function getCountryFromISO2($iso2) |
| 1577 | 1577 | { |
| 1578 | 1578 | global $globalDBdriver, $globalDebug; |
| 1579 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1579 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1580 | 1580 | |
| 1581 | 1581 | $Connection = new Connection($this->db); |
| 1582 | 1582 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | |
| 1625 | 1625 | $bitly_data = json_decode($bitly_data); |
| 1626 | 1626 | $bitly_url = ''; |
| 1627 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1627 | + if ($bitly_data->status_txt = "OK") { |
|
| 1628 | 1628 | $bitly_url = $bitly_data->data->url; |
| 1629 | 1629 | } |
| 1630 | 1630 | |
@@ -1634,7 +1634,7 @@ discard block |
||
| 1634 | 1634 | |
| 1635 | 1635 | public function getOrderBy() |
| 1636 | 1636 | { |
| 1637 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_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")); |
|
| 1637 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_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")); |
|
| 1638 | 1638 | |
| 1639 | 1639 | return $orderby; |
| 1640 | 1640 | |
@@ -89,8 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | private function urshift($n, $s) { |
| 92 | - return ($n >= 0) ? ($n >> $s) : |
|
| 93 | - (($n & 0x7fffffff) >> $s) | |
|
| 92 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
| 94 | 93 | (0x40000000 >> ($s - 1)); |
| 95 | 94 | } |
| 96 | 95 | |
@@ -102,7 +101,7 @@ discard block |
||
| 102 | 101 | //$split_input = str_split($input); |
| 103 | 102 | |
| 104 | 103 | /* Find the end of header checking for NULL bytes while doing it. */ |
| 105 | - $splitpos = strpos($input,':'); |
|
| 104 | + $splitpos = strpos($input, ':'); |
|
| 106 | 105 | |
| 107 | 106 | /* Check that end was found and body has at least one byte. */ |
| 108 | 107 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -112,28 +111,28 @@ discard block |
||
| 112 | 111 | |
| 113 | 112 | if ($debug) echo 'input : '.$input."\n"; |
| 114 | 113 | /* Save header and body. */ |
| 115 | - $body = substr($input,$splitpos+1,$input_len); |
|
| 114 | + $body = substr($input, $splitpos + 1, $input_len); |
|
| 116 | 115 | $body_len = strlen($body); |
| 117 | - $header = substr($input,0,$splitpos); |
|
| 116 | + $header = substr($input, 0, $splitpos); |
|
| 118 | 117 | //$header_len = strlen($header); |
| 119 | 118 | if ($debug) echo 'header : '.$header."\n"; |
| 120 | 119 | |
| 121 | 120 | /* Parse source, target and path. */ |
| 122 | 121 | //FLRDF0A52>APRS,qAS,LSTB |
| 123 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
| 122 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
| 124 | 123 | $ident = $matches[1]; |
| 125 | 124 | $all_elements = $matches[2]; |
| 126 | 125 | if ($debug) echo 'ident : '.$ident."\n"; |
| 127 | 126 | $result['ident'] = $ident; |
| 128 | 127 | } else return false; |
| 129 | - $elements = explode(',',$all_elements); |
|
| 128 | + $elements = explode(',', $all_elements); |
|
| 130 | 129 | $source = end($elements); |
| 131 | 130 | $result['source'] = $source; |
| 132 | 131 | foreach ($elements as $element) { |
| 133 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 132 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
| 134 | 133 | //echo "ok"; |
| 135 | 134 | //if ($element == 'TCPIP*') return false; |
| 136 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 135 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
| 137 | 136 | if ($debug) echo 'element : '.$element."\n"; |
| 138 | 137 | return false; |
| 139 | 138 | } |
@@ -146,10 +145,10 @@ discard block |
||
| 146 | 145 | */ |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | - $type = substr($body,0,1); |
|
| 148 | + $type = substr($body, 0, 1); |
|
| 150 | 149 | if ($debug) echo 'type : '.$type."\n"; |
| 151 | 150 | if ($type == ';') { |
| 152 | - $result['ident'] = trim(substr($body,1,9)); |
|
| 151 | + $result['ident'] = trim(substr($body, 1, 9)); |
|
| 153 | 152 | } elseif ($type == ',') { |
| 154 | 153 | // Invalid data or test data |
| 155 | 154 | return false; |
@@ -157,24 +156,24 @@ discard block |
||
| 157 | 156 | |
| 158 | 157 | // Check for Timestamp |
| 159 | 158 | $find = false; |
| 160 | - $body_parse = substr($body,1); |
|
| 159 | + $body_parse = substr($body, 1); |
|
| 161 | 160 | //echo 'Body : '.$body."\n"; |
| 162 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
| 163 | - $body_parse = substr($body_parse,10); |
|
| 161 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
| 162 | + $body_parse = substr($body_parse, 10); |
|
| 164 | 163 | $find = true; |
| 165 | 164 | //echo $body_parse."\n"; |
| 166 | 165 | } |
| 167 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
| 168 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 166 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
| 167 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 169 | 168 | $find = true; |
| 170 | 169 | //echo $body_parse."\n"; |
| 171 | 170 | } |
| 172 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
| 173 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 171 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
| 172 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 174 | 173 | $find = true; |
| 175 | 174 | //echo $body_parse."\n"; |
| 176 | 175 | } |
| 177 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
| 176 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
| 178 | 177 | $find = true; |
| 179 | 178 | //print_r($matches); |
| 180 | 179 | $timestamp = $matches[0]; |
@@ -189,19 +188,19 @@ discard block |
||
| 189 | 188 | // This work or not ? |
| 190 | 189 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 191 | 190 | } |
| 192 | - $body_parse = substr($body_parse,7); |
|
| 191 | + $body_parse = substr($body_parse, 7); |
|
| 193 | 192 | $result['timestamp'] = $timestamp; |
| 194 | 193 | //echo date('Ymd H:i:s',$timestamp); |
| 195 | 194 | } |
| 196 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
| 195 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
| 197 | 196 | $find = true; |
| 198 | 197 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
| 199 | - $body_parse = substr($body_parse,8); |
|
| 198 | + $body_parse = substr($body_parse, 8); |
|
| 200 | 199 | $result['timestamp'] = $timestamp; |
| 201 | 200 | //echo date('Ymd H:i:s',$timestamp); |
| 202 | 201 | } |
| 203 | 202 | //if (strlen($body_parse) > 19) { |
| 204 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 203 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
| 205 | 204 | $find = true; |
| 206 | 205 | // 4658.70N/00707.78Ez |
| 207 | 206 | //print_r(str_split($body_parse)); |
@@ -227,11 +226,11 @@ discard block |
||
| 227 | 226 | */ |
| 228 | 227 | $latitude = $lat + floatval($lat_min)/60; |
| 229 | 228 | $longitude = $lon + floatval($lon_min)/60; |
| 230 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 231 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 229 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
| 230 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
| 232 | 231 | $result['latitude'] = $latitude; |
| 233 | 232 | $result['longitude'] = $longitude; |
| 234 | - $body_parse = substr($body_parse,18); |
|
| 233 | + $body_parse = substr($body_parse, 18); |
|
| 235 | 234 | $body_parse_len = strlen($body_parse); |
| 236 | 235 | } |
| 237 | 236 | $body_parse_len = strlen($body_parse); |
@@ -258,7 +257,7 @@ discard block |
||
| 258 | 257 | //} |
| 259 | 258 | //echo $body_parse; |
| 260 | 259 | if ($type != ';' && $type != '>') { |
| 261 | - $body_parse = substr($body_parse,1); |
|
| 260 | + $body_parse = substr($body_parse, 1); |
|
| 262 | 261 | $body_parse_len = strlen($body_parse); |
| 263 | 262 | $result['symbol_code'] = $symbol_code; |
| 264 | 263 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -269,15 +268,15 @@ discard block |
||
| 269 | 268 | //$body_parse_len = strlen($body_parse); |
| 270 | 269 | if ($body_parse_len >= 7) { |
| 271 | 270 | |
| 272 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 273 | - $course = substr($body_parse,0,3); |
|
| 271 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
| 272 | + $course = substr($body_parse, 0, 3); |
|
| 274 | 273 | $tmp_s = intval($course); |
| 275 | 274 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
| 276 | - $speed = substr($body_parse,4,3); |
|
| 275 | + $speed = substr($body_parse, 4, 3); |
|
| 277 | 276 | if ($speed != '...') { |
| 278 | 277 | $result['speed'] = round($speed*1.852); |
| 279 | 278 | } |
| 280 | - $body_parse = substr($body_parse,7); |
|
| 279 | + $body_parse = substr($body_parse, 7); |
|
| 281 | 280 | } |
| 282 | 281 | // Check PHGR, PHG, RNG |
| 283 | 282 | } |
@@ -287,12 +286,12 @@ discard block |
||
| 287 | 286 | } |
| 288 | 287 | */ |
| 289 | 288 | if (strlen($body_parse) > 0) { |
| 290 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 289 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
| 291 | 290 | $altitude = intval($matches[1]); |
| 292 | 291 | //$result['altitude'] = round($altitude*0.3048); |
| 293 | 292 | $result['altitude'] = $altitude; |
| 294 | 293 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
| 295 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 294 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
| 296 | 295 | } |
| 297 | 296 | } |
| 298 | 297 | |
@@ -303,44 +302,44 @@ discard block |
||
| 303 | 302 | } |
| 304 | 303 | */ |
| 305 | 304 | // DAO |
| 306 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 305 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
| 307 | 306 | $dao = $matches[1]; |
| 308 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 307 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
| 309 | 308 | $dao_split = str_split($dao); |
| 310 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 311 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 309 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
| 310 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
| 312 | 311 | |
| 313 | 312 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 314 | 313 | else $result['latitude'] += $lat_off; |
| 315 | 314 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
| 316 | 315 | else $result['longitude'] += $lon_off; |
| 317 | 316 | } |
| 318 | - $body_parse = substr($body_parse,6); |
|
| 317 | + $body_parse = substr($body_parse, 6); |
|
| 319 | 318 | } |
| 320 | 319 | |
| 321 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
| 320 | + if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
| 322 | 321 | $result['callsign'] = $matches[1]; |
| 323 | 322 | } |
| 324 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 323 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
| 325 | 324 | $result['squawk'] = $matches[1]; |
| 326 | 325 | } |
| 327 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 326 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
| 328 | 327 | $result['aircraft_icao'] = $matches[1]; |
| 329 | 328 | } |
| 330 | 329 | // OGN comment |
| 331 | 330 | // echo "Before OGN : ".$body_parse."\n"; |
| 332 | 331 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
| 333 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 332 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
| 334 | 333 | $id = $matches[1]; |
| 335 | 334 | //$mode = substr($id,0,2); |
| 336 | - $address = substr($id,2); |
|
| 335 | + $address = substr($id, 2); |
|
| 337 | 336 | //print_r($matches); |
| 338 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
| 337 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
| 339 | 338 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
| 340 | 339 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
| 341 | 340 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
| 342 | 341 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
| 343 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
| 342 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
| 344 | 343 | $result['aircrafttype_code'] = $aircraftType; |
| 345 | 344 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
| 346 | 345 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -357,7 +356,7 @@ discard block |
||
| 357 | 356 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
| 358 | 357 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
| 359 | 358 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
| 360 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
| 359 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
| 361 | 360 | $result['stealth'] = $stealth; |
| 362 | 361 | $result['address'] = $address; |
| 363 | 362 | } |
@@ -369,72 +368,72 @@ discard block |
||
| 369 | 368 | //$body_parse = substr($body_parse,1); |
| 370 | 369 | //$body_parse_len = strlen($body_parse); |
| 371 | 370 | |
| 372 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 371 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 373 | 372 | $result['wind_dir'] = intval($matches[1]); |
| 374 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 375 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 376 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 377 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 378 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 373 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
| 374 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
| 375 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
| 376 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 377 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 379 | 378 | $result['wind_dir'] = intval($matches[1]); |
| 380 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 381 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 382 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 383 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 384 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 379 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 380 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 381 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
| 382 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 383 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 385 | 384 | $result['wind_dir'] = intval($matches[1]); |
| 386 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 387 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 388 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 389 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 385 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 386 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 387 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 388 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 390 | 389 | $result['wind_dir'] = intval($matches[1]); |
| 391 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 392 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 393 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 390 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 391 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 392 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 394 | 393 | } |
| 395 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 396 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
| 394 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
| 395 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
| 397 | 396 | } |
| 398 | 397 | } |
| 399 | 398 | } else $result['comment'] = trim($body_parse); |
| 400 | 399 | |
| 401 | 400 | } |
| 402 | 401 | //} |
| 403 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 404 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 402 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
| 403 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
| 405 | 404 | if ($debug) print_r($result); |
| 406 | 405 | return $result; |
| 407 | 406 | } |
| 408 | 407 | |
| 409 | 408 | function connect() { |
| 410 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 409 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 411 | 410 | $aprs_connect = 0; |
| 412 | 411 | $aprs_keep = 120; |
| 413 | 412 | $aprs_last_tx = time(); |
| 414 | 413 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 415 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 414 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 416 | 415 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
| 417 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 416 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 418 | 417 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
| 419 | 418 | else $aprs_pass = '-1'; |
| 420 | 419 | |
| 421 | - $aprs_filter = ''; |
|
| 420 | + $aprs_filter = ''; |
|
| 422 | 421 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 423 | 422 | $Common = new Common(); |
| 424 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
| 423 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
| 425 | 424 | if ($s !== false) { |
| 426 | 425 | echo 'Connected to APRS server! '."\n"; |
| 427 | 426 | $authstart = time(); |
| 428 | 427 | $this->socket = $s; |
| 429 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 430 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
| 428 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
| 429 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
| 431 | 430 | echo $msgin."\n"; |
| 432 | 431 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
| 433 | 432 | echo 'Verified !'; |
| 434 | 433 | return true; |
| 435 | 434 | break; |
| 436 | 435 | } |
| 437 | - if (time()-$authstart > 5) { |
|
| 436 | + if (time() - $authstart > 5) { |
|
| 438 | 437 | echo 'Timeout'; |
| 439 | 438 | break; |
| 440 | 439 | } |
@@ -443,20 +442,20 @@ discard block |
||
| 443 | 442 | } |
| 444 | 443 | |
| 445 | 444 | function send($data) { |
| 446 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
| 445 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
| 447 | 446 | if ($send === FALSE) $this->connect(); |
| 448 | 447 | } |
| 449 | 448 | } |
| 450 | 449 | |
| 451 | 450 | class APRSSpotter extends APRS { |
| 452 | - function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
| 451 | + function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
| 453 | 452 | $Common = new Common(); |
| 454 | 453 | if ($latitude != '' && $longitude != '') { |
| 455 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 456 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 457 | - $coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 458 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 459 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 454 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 455 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 456 | + $coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 457 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 458 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 460 | 459 | $w = $w1.$w2; |
| 461 | 460 | //$w = '00'; |
| 462 | 461 | $custom = ''; |
@@ -473,19 +472,19 @@ discard block |
||
| 473 | 472 | $custom .= 'AI='.$aircraft_icao; |
| 474 | 473 | } |
| 475 | 474 | if ($custom != '') $custom = ' '.$custom; |
| 476 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 475 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 477 | 476 | } |
| 478 | 477 | } |
| 479 | 478 | } |
| 480 | 479 | class APRSMarine extends APRS { |
| 481 | - function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source,$source_name,$over_country) { |
|
| 480 | + function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country) { |
|
| 482 | 481 | $Common = new Common(); |
| 483 | 482 | if ($latitude != '' && $longitude != '') { |
| 484 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 485 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 486 | - $coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 487 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 488 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 483 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 484 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 485 | + $coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 486 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 487 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 489 | 488 | $w = $w1.$w2; |
| 490 | 489 | //$w = '00'; |
| 491 | 490 | $custom = ''; |
@@ -511,7 +510,7 @@ discard block |
||
| 511 | 510 | } |
| 512 | 511 | if ($custom != '') $custom = ' '.$custom; |
| 513 | 512 | $altitude = 0; |
| 514 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 513 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 515 | 514 | } |
| 516 | 515 | } |
| 517 | 516 | } |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | die; |
| 46 | 46 | } |
| 47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 52 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 55 | if (isset($options['s'])) { |
@@ -64,27 +64,27 @@ discard block |
||
| 64 | 64 | else $id_source = 1; |
| 65 | 65 | if (isset($globalServer) && $globalServer) { |
| 66 | 66 | if ($globalDebug) echo "Using Server Mode\n"; |
| 67 | - $SI=new SpotterServer(); |
|
| 67 | + $SI = new SpotterServer(); |
|
| 68 | 68 | /* |
| 69 | 69 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 70 | 70 | $SI = new adsb2aprs(); |
| 71 | 71 | $SI->connect(); |
| 72 | 72 | */ |
| 73 | -} else $SI=new SpotterImport($Connection->db); |
|
| 73 | +} else $SI = new SpotterImport($Connection->db); |
|
| 74 | 74 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 75 | 75 | if (isset($globalMarine) && $globalMarine) { |
| 76 | 76 | $AIS = new AIS(); |
| 77 | 77 | $MI = new MarineImport($Connection->db); |
| 78 | 78 | } |
| 79 | 79 | //$APRS=new APRS($Connection->db); |
| 80 | -$SBS=new SBS(); |
|
| 81 | -$ACARS=new ACARS($Connection->db); |
|
| 82 | -$Common=new Common(); |
|
| 80 | +$SBS = new SBS(); |
|
| 81 | +$ACARS = new ACARS($Connection->db); |
|
| 82 | +$Common = new Common(); |
|
| 83 | 83 | date_default_timezone_set('UTC'); |
| 84 | 84 | //$servertz = system('date +%Z'); |
| 85 | 85 | // signal handler - playing nice with sockets and dump1090 |
| 86 | 86 | if (function_exists('pcntl_fork')) { |
| 87 | - pcntl_signal(SIGINT, function() { |
|
| 87 | + pcntl_signal(SIGINT, function() { |
|
| 88 | 88 | global $sockets; |
| 89 | 89 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 90 | 90 | die("Bye!\n"); |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | function connect_all($hosts) { |
| 102 | 102 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 103 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 103 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 104 | 104 | $reset++; |
| 105 | 105 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 106 | 106 | foreach ($hosts as $id => $value) { |
| 107 | 107 | $host = $value['host']; |
| 108 | 108 | $globalSources[$id]['last_exec'] = 0; |
| 109 | 109 | // Here we check type of source(s) |
| 110 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 111 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 110 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 111 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 112 | 112 | //$formats[$id] = 'deltadbtxt'; |
| 113 | 113 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 114 | 114 | //$last_exec['deltadbtxt'] = 0; |
| 115 | 115 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 116 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 116 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 117 | 117 | //$formats[$id] = 'vatsimtxt'; |
| 118 | 118 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 119 | 119 | //$last_exec['vatsimtxt'] = 0; |
| 120 | 120 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 121 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 121 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 122 | 122 | //$formats[$id] = 'aircraftlistjson'; |
| 123 | 123 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 124 | 124 | //$last_exec['aircraftlistjson'] = 0; |
| 125 | 125 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 126 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 126 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 127 | 127 | //$formats[$id] = 'aircraftlistjson'; |
| 128 | 128 | $globalSources[$id]['format'] = 'opensky'; |
| 129 | 129 | //$last_exec['aircraftlistjson'] = 0; |
| 130 | 130 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 131 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 131 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 132 | 132 | //$formats[$id] = 'radarvirtueljson'; |
| 133 | 133 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 134 | 134 | //$last_exec['radarvirtueljson'] = 0; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 138 | 138 | exit(0); |
| 139 | 139 | } |
| 140 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 140 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 141 | 141 | //$formats[$id] = 'planeupdatefaa'; |
| 142 | 142 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 143 | 143 | //$last_exec['planeupdatefaa'] = 0; |
@@ -146,26 +146,26 @@ discard block |
||
| 146 | 146 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 147 | 147 | exit(0); |
| 148 | 148 | } |
| 149 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 149 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 150 | 150 | //$formats[$id] = 'phpvmacars'; |
| 151 | 151 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 152 | 152 | //$last_exec['phpvmacars'] = 0; |
| 153 | 153 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 154 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 154 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 155 | 155 | //$formats[$id] = 'phpvmacars'; |
| 156 | 156 | $globalSources[$id]['format'] = 'vam'; |
| 157 | 157 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 158 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 158 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 159 | 159 | //$formats[$id] = 'whazzup'; |
| 160 | 160 | $globalSources[$id]['format'] = 'whazzup'; |
| 161 | 161 | //$last_exec['whazzup'] = 0; |
| 162 | 162 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 163 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 163 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 164 | 164 | //$formats[$id] = 'pirepsjson'; |
| 165 | 165 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 166 | 166 | //$last_exec['pirepsjson'] = 0; |
| 167 | 167 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 168 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 168 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 169 | 169 | //$formats[$id] = 'fr24json'; |
| 170 | 170 | $globalSources[$id]['format'] = 'fr24json'; |
| 171 | 171 | //$last_exec['fr24json'] = 0; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 175 | 175 | exit(0); |
| 176 | 176 | } |
| 177 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 177 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 178 | 178 | //$formats[$id] = 'fr24json'; |
| 179 | 179 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 180 | 180 | //$last_exec['fr24json'] = 0; |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | exit(0); |
| 185 | 185 | } |
| 186 | 186 | //} else if (preg_match('/10001/',$host)) { |
| 187 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 187 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 188 | 188 | //$formats[$id] = 'tsv'; |
| 189 | 189 | $globalSources[$id]['format'] = 'tsv'; |
| 190 | 190 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 191 | 191 | } |
| 192 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 192 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 193 | 193 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 194 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 194 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 195 | 195 | if ($idf !== false) { |
| 196 | 196 | $httpfeeds[$id] = $idf; |
| 197 | 197 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 198 | 198 | } |
| 199 | 199 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
| 200 | 200 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 201 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 202 | - $hostport = explode(':',$host); |
|
| 201 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 202 | + $hostport = explode(':', $host); |
|
| 203 | 203 | if (isset($hostport[1])) { |
| 204 | 204 | $port = $hostport[1]; |
| 205 | 205 | $hostn = $hostport[0]; |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | $Common = new Common(); |
| 211 | 211 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 212 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 212 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 213 | 213 | } else { |
| 214 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 214 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 215 | 215 | } |
| 216 | 216 | if ($s) { |
| 217 | 217 | $sockets[$id] = $s; |
| 218 | 218 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 219 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 219 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
| 220 | 220 | //$formats[$id] = 'aprs'; |
| 221 | 221 | $globalSources[$id]['format'] = 'aprs'; |
| 222 | 222 | //$aprs_connect = 0; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 259 | 259 | else $timeout = 20; |
| 260 | 260 | $errno = ''; |
| 261 | -$errstr=''; |
|
| 261 | +$errstr = ''; |
|
| 262 | 262 | |
| 263 | 263 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 264 | 264 | /* Initiate connections to all the hosts simultaneously */ |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | //connect_all($globalSources); |
| 267 | 267 | |
| 268 | 268 | if (isset($globalProxy) && $globalProxy) { |
| 269 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 269 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 270 | 270 | } else { |
| 271 | 271 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 272 | 272 | } |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | if ($use_aprs) { |
| 295 | 295 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 296 | - $APRS=new APRS(); |
|
| 296 | + $APRS = new APRS(); |
|
| 297 | 297 | $aprs_connect = 0; |
| 298 | 298 | $aprs_keep = 120; |
| 299 | 299 | $aprs_last_tx = time(); |
| 300 | 300 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 301 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 301 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 302 | 302 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 303 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 303 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 304 | 304 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 305 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 305 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 306 | 306 | if ($aprs_full) $aprs_filter = ''; |
| 307 | 307 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 308 | 308 | else $aprs_pass = '-1'; |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | sleep(1); |
| 317 | 317 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 318 | 318 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 319 | -$endtime = time()+$globalCronEnd; |
|
| 319 | +$endtime = time() + $globalCronEnd; |
|
| 320 | 320 | $i = 1; |
| 321 | 321 | $tt = array(); |
| 322 | 322 | // Delete all ATC |
| 323 | 323 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 324 | - $ATC=new ATC($Connection->db); |
|
| 324 | + $ATC = new ATC($Connection->db); |
|
| 325 | 325 | } |
| 326 | 326 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 327 | 327 | $ATC->deleteAll(); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 331 | 331 | while ($i > 0) { |
| 332 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 332 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 333 | 333 | // Delete old ATC |
| 334 | 334 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 335 | 335 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | if ($max != $globalMinFetch) { |
| 346 | 346 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 347 | - sleep($globalMinFetch-$max+2); |
|
| 347 | + sleep($globalMinFetch - $max + 2); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | //$buffer = $Common->getData($hosts[$id]); |
| 358 | 358 | $buffer = $Common->getData($value['host']); |
| 359 | 359 | if ($buffer != '') $reset = 0; |
| 360 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 361 | - $buffer = explode('\n',$buffer); |
|
| 360 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 361 | + $buffer = explode('\n', $buffer); |
|
| 362 | 362 | foreach ($buffer as $line) { |
| 363 | 363 | if ($line != '' && count($line) > 7) { |
| 364 | 364 | $line = explode(',', $line); |
@@ -385,11 +385,11 @@ discard block |
||
| 385 | 385 | $last_exec[$id]['last'] = time(); |
| 386 | 386 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 387 | 387 | date_default_timezone_set('CET'); |
| 388 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 388 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 389 | 389 | date_default_timezone_set('UTC'); |
| 390 | 390 | if ($buffer != '') $reset = 0; |
| 391 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 392 | - $buffer = explode('\n',$buffer); |
|
| 391 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 392 | + $buffer = explode('\n', $buffer); |
|
| 393 | 393 | foreach ($buffer as $line) { |
| 394 | 394 | if ($line != '') { |
| 395 | 395 | echo "'".$line."'\n"; |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 408 | 408 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 409 | 409 | if (isset($ais_data['timestamp'])) { |
| 410 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 410 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 411 | 411 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 412 | 412 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 413 | 413 | $add = true; |
@@ -430,12 +430,12 @@ discard block |
||
| 430 | 430 | $w = $e = null; |
| 431 | 431 | |
| 432 | 432 | if (isset($arr[$id])) { |
| 433 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 433 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 434 | 434 | if ($nn > 0) { |
| 435 | 435 | foreach ($httpfeeds as $feed) { |
| 436 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 437 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 438 | - $buffer = explode('\n',$buffer); |
|
| 436 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 437 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 438 | + $buffer = explode('\n', $buffer); |
|
| 439 | 439 | foreach ($buffer as $line) { |
| 440 | 440 | if ($line != '') { |
| 441 | 441 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -451,9 +451,9 @@ discard block |
||
| 451 | 451 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 452 | 452 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 453 | 453 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 454 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 454 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 455 | 455 | if (isset($ais_data['timestamp'])) { |
| 456 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 456 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 457 | 457 | } else { |
| 458 | 458 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 459 | 459 | } |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 470 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 470 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 471 | 471 | if ($buffer != '') { |
| 472 | 472 | //echo $buffer; |
| 473 | - $all_data = json_decode($buffer,true); |
|
| 473 | + $all_data = json_decode($buffer, true); |
|
| 474 | 474 | //print_r($all_data); |
| 475 | 475 | if (isset($all_data[0]['DATA'])) { |
| 476 | 476 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 486 | 486 | $data['imo'] = $line['IMO']; |
| 487 | 487 | //$data['arrival_code'] = $ais_data['destination']; |
| 488 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 488 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
| 489 | 489 | $data['format_source'] = 'myshiptracking'; |
| 490 | 490 | $data['id_source'] = $id_source; |
| 491 | 491 | $MI->add($data); |
@@ -498,11 +498,11 @@ discard block |
||
| 498 | 498 | $last_exec[$id]['last'] = time(); |
| 499 | 499 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 500 | 500 | echo 'Try ?'."\n"; |
| 501 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 501 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 502 | 502 | echo $buffer; |
| 503 | 503 | if ($buffer != '') { |
| 504 | 504 | //echo $buffer; |
| 505 | - $all_data = json_decode($buffer,true); |
|
| 505 | + $all_data = json_decode($buffer, true); |
|
| 506 | 506 | print_r($all_data); |
| 507 | 507 | if (isset($all_data[0]['mmsi'])) { |
| 508 | 508 | foreach ($all_data as $line) { |
@@ -530,27 +530,27 @@ discard block |
||
| 530 | 530 | $last_exec[$id]['last'] = time(); |
| 531 | 531 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 532 | 532 | echo 'download...'; |
| 533 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 533 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 534 | 534 | echo 'done !'."\n"; |
| 535 | 535 | if ($buffer != '') $reset = 0; |
| 536 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 537 | - $buffer = explode('\n',$buffer); |
|
| 536 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 537 | + $buffer = explode('\n', $buffer); |
|
| 538 | 538 | foreach ($buffer as $line) { |
| 539 | 539 | if ($line != '') { |
| 540 | 540 | $data = array(); |
| 541 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 542 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 541 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 542 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 543 | 543 | //$data['status'] = substr($line,21,2); |
| 544 | 544 | //$data['type'] = substr($line,24,3); |
| 545 | - $data['latitude'] = substr($line,29,9); |
|
| 546 | - $data['longitude'] = substr($line,41,9); |
|
| 547 | - $data['speed'] = round(substr($line,51,5)); |
|
| 545 | + $data['latitude'] = substr($line, 29, 9); |
|
| 546 | + $data['longitude'] = substr($line, 41, 9); |
|
| 547 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 548 | 548 | //$data['course'] = substr($line,57,5); |
| 549 | - $data['heading'] = round(substr($line,63,3)); |
|
| 549 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 550 | 550 | //$data['draft'] = substr($line,67,4); |
| 551 | 551 | //$data['length'] = substr($line,72,3); |
| 552 | 552 | //$data['beam'] = substr($line,76,2); |
| 553 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 553 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
| 554 | 554 | //$data['callsign'] = trim(substr($line,100,7); |
| 555 | 555 | //$data['dest'] = substr($line,108,20); |
| 556 | 556 | //$data['etaDate'] = substr($line,129,5); |
@@ -568,8 +568,8 @@ discard block |
||
| 568 | 568 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 569 | 569 | //$buffer = $Common->getData($hosts[$id]); |
| 570 | 570 | $buffer = $Common->getData($value['host']); |
| 571 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 572 | - $buffer = explode('\n',$buffer); |
|
| 571 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 572 | + $buffer = explode('\n', $buffer); |
|
| 573 | 573 | $reset = 0; |
| 574 | 574 | foreach ($buffer as $line) { |
| 575 | 575 | if ($line != '') { |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 581 | 581 | $data['pilot_id'] = $line[1]; |
| 582 | 582 | $data['pilot_name'] = $line[2]; |
| 583 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 583 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 584 | 584 | $data['ident'] = $line[0]; // ident |
| 585 | 585 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 586 | 586 | $data['speed'] = $line[8]; // speed |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 597 | 597 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 598 | 598 | $data['departure_airport_icao'] = $line[11]; |
| 599 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 599 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 600 | 600 | $data['arrival_airport_icao'] = $line[13]; |
| 601 | 601 | $data['frequency'] = $line[4]; |
| 602 | 602 | $data['type'] = $line[18]; |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | $data['id_source'] = $id_source; |
| 606 | 606 | //$data['arrival_airport_time'] = ; |
| 607 | 607 | if ($line[9] != '') { |
| 608 | - $aircraft_data = explode('/',$line[9]); |
|
| 608 | + $aircraft_data = explode('/', $line[9]); |
|
| 609 | 609 | if (isset($aircraft_data[1])) { |
| 610 | 610 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 611 | 611 | } |
@@ -619,9 +619,9 @@ discard block |
||
| 619 | 619 | if ($line[3] == 'PILOT') $SI->add($data); |
| 620 | 620 | elseif ($line[3] == 'ATC') { |
| 621 | 621 | //print_r($data); |
| 622 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 623 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 624 | - $typec = substr($data['ident'],-3); |
|
| 622 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 623 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 624 | + $typec = substr($data['ident'], -3); |
|
| 625 | 625 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 626 | 626 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 627 | 627 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 633 | 633 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 634 | 634 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 635 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 635 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
| 636 | 636 | } |
| 637 | 637 | unset($data); |
| 638 | 638 | } |
@@ -643,9 +643,9 @@ discard block |
||
| 643 | 643 | $last_exec[$id]['last'] = time(); |
| 644 | 644 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 645 | 645 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 646 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 646 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 647 | 647 | if ($buffer != '') { |
| 648 | - $all_data = json_decode($buffer,true); |
|
| 648 | + $all_data = json_decode($buffer, true); |
|
| 649 | 649 | if (isset($all_data['acList'])) { |
| 650 | 650 | $reset = 0; |
| 651 | 651 | foreach ($all_data['acList'] as $line) { |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 702 | 702 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 703 | 703 | $buffer = $Common->getData($value['host']); |
| 704 | - $all_data = json_decode($buffer,true); |
|
| 704 | + $all_data = json_decode($buffer, true); |
|
| 705 | 705 | if (isset($all_data['planes'])) { |
| 706 | 706 | $reset = 0; |
| 707 | 707 | foreach ($all_data['planes'] as $key => $line) { |
@@ -718,12 +718,12 @@ discard block |
||
| 718 | 718 | $data['emergency'] = ''; // emergency |
| 719 | 719 | $data['registration'] = $line[2]; |
| 720 | 720 | $data['aircraft_icao'] = $line[0]; |
| 721 | - $deparr = explode('-',$line[1]); |
|
| 721 | + $deparr = explode('-', $line[1]); |
|
| 722 | 722 | if (count($deparr) == 2) { |
| 723 | 723 | $data['departure_airport_icao'] = $deparr[0]; |
| 724 | 724 | $data['arrival_airport_icao'] = $deparr[1]; |
| 725 | 725 | } |
| 726 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 726 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 727 | 727 | $data['format_source'] = 'planeupdatefaa'; |
| 728 | 728 | $data['id_source'] = $id_source; |
| 729 | 729 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | $last_exec[$id]['last'] = time(); |
| 736 | 736 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 737 | 737 | $buffer = $Common->getData($value['host']); |
| 738 | - $all_data = json_decode($buffer,true); |
|
| 738 | + $all_data = json_decode($buffer, true); |
|
| 739 | 739 | if (isset($all_data['states'])) { |
| 740 | 740 | $reset = 0; |
| 741 | 741 | foreach ($all_data['states'] as $key => $line) { |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | //$data['emergency'] = ''; // emergency |
| 753 | 753 | //$data['registration'] = $line[2]; |
| 754 | 754 | //$data['aircraft_icao'] = $line[0]; |
| 755 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 755 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 756 | 756 | $data['format_source'] = 'opensky'; |
| 757 | 757 | $data['id_source'] = $id_source; |
| 758 | 758 | $SI->add($data); |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 766 | 766 | //$buffer = $Common->getData($hosts[$id]); |
| 767 | 767 | $buffer = $Common->getData($value['host']); |
| 768 | - $all_data = json_decode($buffer,true); |
|
| 768 | + $all_data = json_decode($buffer, true); |
|
| 769 | 769 | if (!empty($all_data)) $reset = 0; |
| 770 | 770 | foreach ($all_data as $key => $line) { |
| 771 | 771 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -797,11 +797,11 @@ discard block |
||
| 797 | 797 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 798 | 798 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 799 | 799 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 800 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 800 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 801 | 801 | //echo $buffer; |
| 802 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 803 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 804 | - $all_data = json_decode($buffer,true); |
|
| 802 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 803 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 804 | + $all_data = json_decode($buffer, true); |
|
| 805 | 805 | if (json_last_error() != JSON_ERROR_NONE) { |
| 806 | 806 | die(json_last_error_msg()); |
| 807 | 807 | } |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | //$data['departure_airport_iata'] = $line[11]; |
| 825 | 825 | //$data['arrival_airport_iata'] = $line[12]; |
| 826 | 826 | //$data['emergency'] = ''; // emergency |
| 827 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 827 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 828 | 828 | $data['format_source'] = 'radarvirtueljson'; |
| 829 | 829 | $data['id_source'] = $id_source; |
| 830 | 830 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -839,14 +839,14 @@ discard block |
||
| 839 | 839 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 840 | 840 | //$buffer = $Common->getData($hosts[$id]); |
| 841 | 841 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 842 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 842 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 843 | 843 | |
| 844 | 844 | if (isset($all_data['pireps'])) { |
| 845 | 845 | $reset = 0; |
| 846 | 846 | foreach ($all_data['pireps'] as $line) { |
| 847 | 847 | $data = array(); |
| 848 | 848 | $data['id'] = $line['id']; |
| 849 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 849 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 850 | 850 | $data['ident'] = $line['callsign']; // ident |
| 851 | 851 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 852 | 852 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -875,9 +875,9 @@ discard block |
||
| 875 | 875 | $SI->add($data); |
| 876 | 876 | // print_r($data); |
| 877 | 877 | } elseif ($line['icon'] == 'ct') { |
| 878 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 879 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 880 | - $typec = substr($data['ident'],-3); |
|
| 878 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 879 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 880 | + $typec = substr($data['ident'], -3); |
|
| 881 | 881 | $data['type'] = ''; |
| 882 | 882 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 883 | 883 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 889 | 889 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 890 | 890 | else $data['type'] = 'Observer'; |
| 891 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 891 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
| 892 | 892 | } |
| 893 | 893 | unset($data); |
| 894 | 894 | } |
@@ -900,14 +900,14 @@ discard block |
||
| 900 | 900 | //$buffer = $Common->getData($hosts[$id]); |
| 901 | 901 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 902 | 902 | $buffer = $Common->getData($value['host']); |
| 903 | - $all_data = json_decode($buffer,true); |
|
| 903 | + $all_data = json_decode($buffer, true); |
|
| 904 | 904 | if ($buffer != '' && is_array($all_data)) { |
| 905 | 905 | $reset = 0; |
| 906 | 906 | foreach ($all_data as $line) { |
| 907 | 907 | $data = array(); |
| 908 | 908 | //$data['id'] = $line['id']; // id not usable |
| 909 | 909 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 910 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 910 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 911 | 911 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 912 | 912 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 913 | 913 | $data['ident'] = $line['flightnum']; // ident |
@@ -930,12 +930,12 @@ discard block |
||
| 930 | 930 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 931 | 931 | if (isset($line['aircraftname'])) { |
| 932 | 932 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 933 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 934 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 933 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 934 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 935 | 935 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 936 | 936 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 937 | 937 | else { |
| 938 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 938 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 939 | 939 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 940 | 940 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 941 | 941 | } |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | //$buffer = $Common->getData($hosts[$id]); |
| 958 | 958 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 959 | 959 | $buffer = $Common->getData($value['host']); |
| 960 | - $all_data = json_decode($buffer,true); |
|
| 960 | + $all_data = json_decode($buffer, true); |
|
| 961 | 961 | if ($buffer != '' && is_array($all_data)) { |
| 962 | 962 | $reset = 0; |
| 963 | 963 | foreach ($all_data as $line) { |
| 964 | 964 | $data = array(); |
| 965 | 965 | //$data['id'] = $line['id']; // id not usable |
| 966 | 966 | $data['id'] = trim($line['flight_id']); |
| 967 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 967 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 968 | 968 | $data['pilot_name'] = $line['pilot_name']; |
| 969 | 969 | $data['pilot_id'] = $line['pilot_id']; |
| 970 | 970 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1015,9 +1015,9 @@ discard block |
||
| 1015 | 1015 | //$value = $formats[$nb]; |
| 1016 | 1016 | $format = $globalSources[$nb]['format']; |
| 1017 | 1017 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 1018 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1018 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1019 | 1019 | } else { |
| 1020 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1020 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1021 | 1021 | } |
| 1022 | 1022 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1023 | 1023 | //echo $buffer."\n"; |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 1026 | 1026 | $error = false; |
| 1027 | 1027 | //$SI::del(); |
| 1028 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1028 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1029 | 1029 | // SBS format is CSV format |
| 1030 | 1030 | if ($buffer != '') { |
| 1031 | 1031 | $tt[$format] = 0; |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1058 | 1058 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1059 | 1059 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1060 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1060 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1061 | 1061 | |
| 1062 | 1062 | if (isset($ais_data['timestamp'])) { |
| 1063 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1063 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1064 | 1064 | } else { |
| 1065 | 1065 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1066 | 1066 | } |
@@ -1071,10 +1071,10 @@ discard block |
||
| 1071 | 1071 | } elseif ($format == 'flightgearsp') { |
| 1072 | 1072 | //echo $buffer."\n"; |
| 1073 | 1073 | if (strlen($buffer) > 5) { |
| 1074 | - $line = explode(',',$buffer); |
|
| 1074 | + $line = explode(',', $buffer); |
|
| 1075 | 1075 | $data = array(); |
| 1076 | 1076 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1077 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1077 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1078 | 1078 | $data['ident'] = $line[6]; |
| 1079 | 1079 | $data['aircraft_name'] = $line[7]; |
| 1080 | 1080 | $data['longitude'] = $line[1]; |
@@ -1085,21 +1085,21 @@ discard block |
||
| 1085 | 1085 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1086 | 1086 | $data['format_source'] = 'flightgearsp'; |
| 1087 | 1087 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1088 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1088 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | } elseif ($format == 'acars') { |
| 1091 | 1091 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1092 | 1092 | $ACARS->add(trim($buffer)); |
| 1093 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1093 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1094 | 1094 | $ACARS->deleteLiveAcarsData(); |
| 1095 | 1095 | } elseif ($format == 'flightgearmp') { |
| 1096 | - if (substr($buffer,0,1) != '#') { |
|
| 1096 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1097 | 1097 | $data = array(); |
| 1098 | 1098 | //echo $buffer."\n"; |
| 1099 | - $line = explode(' ',$buffer); |
|
| 1099 | + $line = explode(' ', $buffer); |
|
| 1100 | 1100 | if (count($line) == 11) { |
| 1101 | - $userserver = explode('@',$line[0]); |
|
| 1102 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1101 | + $userserver = explode('@', $line[0]); |
|
| 1102 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1103 | 1103 | $data['ident'] = $userserver[0]; |
| 1104 | 1104 | $data['registration'] = $userserver[0]; |
| 1105 | 1105 | $data['latitude'] = $line[4]; |
@@ -1107,24 +1107,24 @@ discard block |
||
| 1107 | 1107 | $data['altitude'] = $line[6]; |
| 1108 | 1108 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1109 | 1109 | $aircraft_type = $line[10]; |
| 1110 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1111 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1110 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1111 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1112 | 1112 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | } elseif ($format == 'beast') { |
| 1116 | 1116 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1117 | 1117 | die; |
| 1118 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 1118 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 1119 | 1119 | $line = explode("\t", $buffer); |
| 1120 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1120 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1121 | 1121 | $key = $line[$k]; |
| 1122 | - $lined[$key] = $line[$k+1]; |
|
| 1122 | + $lined[$key] = $line[$k + 1]; |
|
| 1123 | 1123 | } |
| 1124 | 1124 | if (count($lined) > 3) { |
| 1125 | 1125 | $data['hex'] = $lined['hexid']; |
| 1126 | 1126 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1127 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1127 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1128 | 1128 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1129 | 1129 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1130 | 1130 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1142,22 +1142,22 @@ discard block |
||
| 1142 | 1142 | } else $error = true; |
| 1143 | 1143 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1144 | 1144 | if ($aprs_connect == 0) { |
| 1145 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1145 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1146 | 1146 | $aprs_connect = 1; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1149 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1150 | 1150 | $aprs_last_tx = time(); |
| 1151 | 1151 | $data_aprs = "# Keep alive"; |
| 1152 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1152 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1156 | 1156 | //echo 'APRS data : '.$buffer."\n"; |
| 1157 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1158 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1157 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1158 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1159 | 1159 | //echo $buffer."\n"; |
| 1160 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1160 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1161 | 1161 | $line = $APRS->parse($buffer); |
| 1162 | 1162 | //print_r($line); |
| 1163 | 1163 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | $data = array(); |
| 1167 | 1167 | //print_r($line); |
| 1168 | 1168 | if (isset($line['address'])) $data['hex'] = $line['address']; |
| 1169 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1169 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1170 | 1170 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1171 | 1171 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1172 | 1172 | $data['ident'] = $line['ident']; |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $currentdate = date('Y-m-d H:i:s'); |
| 1191 | 1191 | $aprsdate = strtotime($data['datetime']); |
| 1192 | 1192 | // Accept data if time <= system time + 20s |
| 1193 | - if (isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1193 | + if (isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 1194 | 1194 | $send = $SI->add($data); |
| 1195 | 1195 | } elseif (isset($line['stealth'])) { |
| 1196 | 1196 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | connect_all($sourceee); |
| 1288 | 1288 | $sourceee = array(); |
| 1289 | 1289 | //connect_all($globalSources); |
| 1290 | - $tt[$format]=0; |
|
| 1290 | + $tt[$format] = 0; |
|
| 1291 | 1291 | break; |
| 1292 | 1292 | } |
| 1293 | 1293 | } |
@@ -1296,14 +1296,14 @@ discard block |
||
| 1296 | 1296 | } else { |
| 1297 | 1297 | $error = socket_strerror(socket_last_error()); |
| 1298 | 1298 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1299 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1299 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1300 | 1300 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1301 | 1301 | // Restart the script if possible |
| 1302 | 1302 | if (is_array($sockets)) { |
| 1303 | 1303 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1304 | 1304 | |
| 1305 | 1305 | foreach ($sockets as $sock) { |
| 1306 | - @socket_shutdown($sock,2); |
|
| 1306 | + @socket_shutdown($sock, 2); |
|
| 1307 | 1307 | @socket_close($sock); |
| 1308 | 1308 | } |
| 1309 | 1309 | |