@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function checkAll() { |
| 44 | 44 | global $globalDebug; |
| 45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 45 | + if ($globalDebug) { |
|
| 46 | + echo "Update last seen tracked data...\n"; |
|
| 47 | + } |
|
| 46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
| 47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
| 48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
| 55 | 57 | public function del() { |
| 56 | 58 | global $globalDebug; |
| 57 | 59 | // Delete old infos |
| 58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 60 | + if ($globalDebug) { |
|
| 61 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 62 | + } |
|
| 59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
| 60 | 64 | if (isset($flight['lastupdate'])) { |
| 61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
| 62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
| 63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 67 | + if ($globalDebug) { |
|
| 68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 69 | + } |
|
| 64 | 70 | /* |
| 65 | 71 | $TrackerLive = new TrackerLive(); |
| 66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
| 70 | 76 | $Tracker = new Tracker($this->db); |
| 71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
| 73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 79 | + if ($globalDebug && $result != 'success') { |
|
| 80 | + echo '!!! ERROR : '.$result."\n"; |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | // Put in archive |
| 76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
| 83 | 91 | |
| 84 | 92 | public function add($line) { |
| 85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
| 86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
| 94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
| 95 | + $globalCoordMinChangeTracker = '0.015'; |
|
| 96 | + } |
|
| 87 | 97 | date_default_timezone_set('UTC'); |
| 88 | 98 | $dataFound = false; |
| 89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
| 97 | 107 | // Increment message number |
| 98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 99 | 109 | $current_date = date('Y-m-d'); |
| 100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 101 | - else $source = ''; |
|
| 102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 110 | + if (isset($line['source_name'])) { |
|
| 111 | + $source = $line['source_name']; |
|
| 112 | + } else { |
|
| 113 | + $source = ''; |
|
| 114 | + } |
|
| 115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 116 | + $source = $line['format_source']; |
|
| 117 | + } |
|
| 103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 121 | + } else { |
|
| 122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 123 | + } |
|
| 107 | 124 | } |
| 108 | 125 | |
| 109 | 126 | |
| 110 | 127 | $Common = new Common(); |
| 111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
| 112 | - else $id = trim($line['id']); |
|
| 128 | + if (!isset($line['id'])) { |
|
| 129 | + $id = trim($line['ident']); |
|
| 130 | + } else { |
|
| 131 | + $id = trim($line['id']); |
|
| 132 | + } |
|
| 113 | 133 | |
| 114 | 134 | if (!isset($this->all_tracked[$id])) { |
| 115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
| 117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
| 118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 119 | 139 | if (!isset($line['id'])) { |
| 120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 140 | + if (!isset($globalDaemon)) { |
|
| 141 | + $globalDaemon = TRUE; |
|
| 142 | + } |
|
| 121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 144 | + } else { |
|
| 145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 146 | + } |
|
| 147 | + if ($globalAllTracked !== FALSE) { |
|
| 148 | + $dataFound = true; |
|
| 149 | + } |
|
| 124 | 150 | } |
| 125 | 151 | |
| 126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
| 128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 129 | 155 | } else { |
| 130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 131 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
| 160 | + } |
|
| 132 | 161 | return ''; |
| 133 | 162 | } |
| 134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 166 | + } |
|
| 136 | 167 | return ''; |
| 137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 169 | + if ($globalDebug) { |
|
| 170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 171 | + } |
|
| 139 | 172 | return ''; |
| 140 | 173 | } elseif (!isset($line['datetime'])) { |
| 141 | 174 | date_default_timezone_set('UTC'); |
| 142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 143 | 176 | } else { |
| 144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 177 | + if ($globalDebug) { |
|
| 178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
| 179 | + } |
|
| 145 | 180 | return ''; |
| 146 | 181 | } |
| 147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
| 153 | 188 | $Tracker = new Tracker($this->db); |
| 154 | 189 | $fromsource = NULL; |
| 155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 191 | + if ($globalDebug && $result != 'success') { |
|
| 192 | + echo '!!! ERROR : '.$result."\n"; |
|
| 193 | + } |
|
| 157 | 194 | $Tracker->db = null; |
| 158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 195 | + if ($globalDebugTimeElapsed) { |
|
| 196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 159 | 201 | } |
| 160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 161 | 202 | } |
| 162 | 203 | |
| 163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
| 168 | 209 | if ($distance > 100 && $distance < 10000) { |
| 169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 170 | 211 | $speed = $speed*3.6; |
| 171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 212 | + if ($speed < 1000) { |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 214 | + } |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
| 217 | + } |
|
| 173 | 218 | } |
| 174 | 219 | } |
| 175 | 220 | |
| 176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 178 | - else unset($timediff); |
|
| 222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 224 | + } else { |
|
| 225 | + unset($timediff); |
|
| 226 | + } |
|
| 179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 180 | 228 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 181 | 229 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) { |
@@ -183,20 +231,30 @@ discard block |
||
| 183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
| 185 | 233 | |
| 186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 234 | + if ($globalDebug) { |
|
| 235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 236 | + } |
|
| 187 | 237 | $timeelapsed = microtime(true); |
| 188 | 238 | $Tracker = new Tracker($this->db); |
| 189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 240 | + if (!empty($all_country)) { |
|
| 241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 242 | + } |
|
| 191 | 243 | $Tracker->db = null; |
| 192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 244 | + if ($globalDebugTimeElapsed) { |
|
| 245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 246 | + } |
|
| 193 | 247 | $this->tmd = 0; |
| 194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 248 | + if ($globalDebug) { |
|
| 249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 250 | + } |
|
| 195 | 251 | } |
| 196 | 252 | } |
| 197 | 253 | |
| 198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 257 | + } |
|
| 200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
| 205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 206 | 264 | } |
| 207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 266 | + if ($line['longitude'] > 180) { |
|
| 267 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 268 | + } |
|
| 269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 271 | + } |
|
| 210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
| 226 | 288 | } |
| 227 | 289 | } |
| 228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 292 | + $dataFound = true; |
|
| 293 | + } |
|
| 230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 231 | 295 | } |
| 232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
| 246 | 310 | |
| 247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
| 314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 315 | + } |
|
| 250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
| 251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
| 252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
| 258 | 324 | } |
| 259 | 325 | |
| 260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
| 261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 329 | + } |
|
| 262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 264 | 332 | //$dataFound = true; |
| 265 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 266 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + } |
|
| 339 | + if ($globalDebug) { |
|
| 340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 341 | + } |
|
| 270 | 342 | } |
| 271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
| 275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
| 276 | 348 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 350 | + if ($globalDebug) { |
|
| 351 | + echo "Check if aircraft is already in DB..."; |
|
| 352 | + } |
|
| 279 | 353 | $timeelapsed = microtime(true); |
| 280 | 354 | $TrackerLive = new TrackerLive($this->db); |
| 281 | 355 | if (isset($line['id'])) { |
| 282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 357 | + if ($globalDebugTimeElapsed) { |
|
| 358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 359 | + } |
|
| 284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 287 | - } else $recent_ident = ''; |
|
| 362 | + if ($globalDebugTimeElapsed) { |
|
| 363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 364 | + } |
|
| 365 | + } else { |
|
| 366 | + $recent_ident = ''; |
|
| 367 | + } |
|
| 288 | 368 | $TrackerLive->db=null; |
| 289 | 369 | |
| 290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 370 | + if ($globalDebug && $recent_ident == '') { |
|
| 371 | + echo " Not in DB.\n"; |
|
| 372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 373 | + echo " Already in DB.\n"; |
|
| 374 | + } |
|
| 292 | 375 | } else { |
| 293 | 376 | $recent_ident = ''; |
| 294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
| 296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 297 | 380 | if($recent_ident == "") |
| 298 | 381 | { |
| 299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 382 | + if ($globalDebug) { |
|
| 383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 384 | + } |
|
| 300 | 385 | //adds the spotter data for the archive |
| 301 | 386 | $highlight = ''; |
| 302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
| 389 | + } |
|
| 303 | 390 | $timeelapsed = microtime(true); |
| 304 | 391 | $Tracker = new Tracker($this->db); |
| 305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 306 | 393 | $Tracker->db = null; |
| 307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 394 | + if ($globalDebug && isset($result)) { |
|
| 395 | + echo $result."\n"; |
|
| 396 | + } |
|
| 397 | + if ($globalDebugTimeElapsed) { |
|
| 398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 399 | + } |
|
| 309 | 400 | |
| 310 | 401 | |
| 311 | 402 | // Add source stat in DB |
| 312 | 403 | $Stats = new Stats($this->db); |
| 313 | 404 | if (!empty($this->stats)) { |
| 314 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 405 | + if ($globalDebug) { |
|
| 406 | + echo 'Add source stats : '; |
|
| 407 | + } |
|
| 315 | 408 | foreach($this->stats as $date => $data) { |
| 316 | 409 | foreach($data as $source => $sourced) { |
| 317 | 410 | //print_r($sourced); |
| 318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 411 | + if (isset($sourced['polar'])) { |
|
| 412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
| 413 | + } |
|
| 414 | + if (isset($sourced['hist'])) { |
|
| 415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
| 416 | + } |
|
| 320 | 417 | if (isset($sourced['msg'])) { |
| 321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
| 322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
| 329 | 426 | unset($this->stats[$date]); |
| 330 | 427 | } |
| 331 | 428 | } |
| 332 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 429 | + if ($globalDebug) { |
|
| 430 | + echo 'Done'."\n"; |
|
| 431 | + } |
|
| 333 | 432 | |
| 334 | 433 | } |
| 335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
| 339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
| 340 | 439 | //print_r($this->all_tracked[$id]); |
| 341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 441 | + if ($globalDebug) { |
|
| 442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
| 443 | + } |
|
| 343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 344 | 445 | $TrackerLive = new TrackerLive($this->db); |
| 345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
| 346 | 447 | $TrackerLive->db=null; |
| 347 | - if ($globalDebug) echo " Done\n"; |
|
| 448 | + if ($globalDebug) { |
|
| 449 | + echo " Done\n"; |
|
| 450 | + } |
|
| 348 | 451 | $this->last_delete = time(); |
| 349 | 452 | } |
| 350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
| 367 | 470 | |
| 368 | 471 | if (!$ignoreImport) { |
| 369 | 472 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 473 | + if ($globalDebug) { |
|
| 474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 475 | + } |
|
| 371 | 476 | $timeelapsed = microtime(true); |
| 372 | 477 | $TrackerLive = new TrackerLive($this->db); |
| 373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 374 | 479 | $TrackerLive->db = null; |
| 375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
| 376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 481 | + if ($globalDebugTimeElapsed) { |
|
| 482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 483 | + } |
|
| 377 | 484 | |
| 378 | 485 | // Put statistics in $this->stats variable |
| 379 | 486 | |
| 380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
| 382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 489 | + if ($source == '') { |
|
| 490 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 491 | + } |
|
| 383 | 492 | if (!isset($this->source_location[$source])) { |
| 384 | 493 | $Location = new Source($this->db); |
| 385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
| 400 | 509 | $stats_heading = round($stats_heading/22.5); |
| 401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 402 | 511 | $current_date = date('Y-m-d'); |
| 403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 512 | + if ($stats_heading == 16) { |
|
| 513 | + $stats_heading = 0; |
|
| 514 | + } |
|
| 404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 405 | 516 | for ($i=0;$i<=15;$i++) { |
| 406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
| 418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 419 | 530 | end($this->stats[$current_date][$source]['hist']); |
| 420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 421 | - } else $mini = 0; |
|
| 532 | + } else { |
|
| 533 | + $mini = 0; |
|
| 534 | + } |
|
| 422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
| 429 | 542 | } |
| 430 | 543 | |
| 431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 433 | - if ($globalDebug) echo $result."\n"; |
|
| 434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 546 | + $send = true; |
|
| 547 | + } |
|
| 548 | + if ($globalDebug) { |
|
| 549 | + echo $result."\n"; |
|
| 550 | + } |
|
| 551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 553 | + } |
|
| 435 | 554 | //$this->del(); |
| 436 | 555 | |
| 437 | 556 | |
| 438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 558 | + if ($globalDebug) { |
|
| 559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
| 560 | + } |
|
| 440 | 561 | $TrackerLive = new TrackerLive($this->db); |
| 441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
| 442 | 563 | $TrackerLive->db = null; |
| 443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
| 444 | - if ($globalDebug) echo " Done\n"; |
|
| 565 | + if ($globalDebug) { |
|
| 566 | + echo " Done\n"; |
|
| 567 | + } |
|
| 445 | 568 | $this->last_delete_hourly = time(); |
| 446 | 569 | } |
| 447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
| 449 | 572 | //$ignoreImport = false; |
| 450 | 573 | } |
| 451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 452 | - if ($send) return $this->all_tracked[$id]; |
|
| 575 | + if ($send) { |
|
| 576 | + return $this->all_tracked[$id]; |
|
| 577 | + } |
|
| 453 | 578 | } |
| 454 | 579 | } |
| 455 | 580 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $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"; |
|
| 39 | + $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 | 40 | } else { |
| 41 | - $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"; |
|
| 41 | + $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 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 74 | 74 | if ($filter_query_where != '') { |
| 75 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 75 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 76 | 76 | } |
| 77 | 77 | $filter_query = $filter_query_join.$filter_query_where; |
| 78 | 78 | return $filter_query; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return Array the spotter information |
| 88 | 88 | * |
| 89 | 89 | */ |
| 90 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 90 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 91 | 91 | { |
| 92 | 92 | date_default_timezone_set('UTC'); |
| 93 | 93 | if (!is_string($query)) |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | $sth = $this->db->prepare($query.$limitQuery); |
| 108 | 108 | $sth->execute($params); |
| 109 | 109 | } catch (PDOException $e) { |
| 110 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 110 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 111 | 111 | exit(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $num_rows = 0; |
| 115 | 115 | $spotter_array = array(); |
| 116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 117 | 117 | { |
| 118 | 118 | $num_rows++; |
| 119 | 119 | $temp_array = array(); |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 147 | 147 | |
| 148 | - if($temp_array['mmsi'] != "") |
|
| 148 | + if ($temp_array['mmsi'] != "") |
|
| 149 | 149 | { |
| 150 | 150 | $Image = new Image($this->db); |
| 151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 151 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 152 | 152 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 153 | 153 | unset($Image); |
| 154 | 154 | if (count($image_array) > 0) { |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 186 | 186 | } else { |
| 187 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 187 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 188 | 188 | } |
| 189 | 189 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 190 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 191 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 191 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 192 | 192 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 193 | 193 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 194 | 194 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 195 | 195 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 196 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 197 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 197 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 198 | 198 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | if ($limit != "") |
| 228 | 228 | { |
| 229 | 229 | $limit_array = explode(",", $limit); |
| 230 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 232 | 232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 233 | 233 | { |
| 234 | 234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | } else { |
| 243 | 243 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 244 | 244 | } |
| 245 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 246 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 245 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 246 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 247 | 247 | return $spotter_array; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | if ($id == '') return array(); |
| 262 | 262 | $additional_query = "marine_output.fammarine_id = :id"; |
| 263 | 263 | $query_values = array(':id' => $id); |
| 264 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 265 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 264 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 265 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 266 | 266 | return $spotter_array; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $query_values = array(); |
| 282 | 282 | $limit_query = ''; |
| 283 | 283 | $additional_query = ''; |
| 284 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 284 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 285 | 285 | if ($ident != "") |
| 286 | 286 | { |
| 287 | 287 | if (!is_string($ident)) |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $limit_array = explode(",", $limit); |
| 299 | 299 | |
| 300 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 302 | 302 | |
| 303 | 303 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 304 | 304 | { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | return $spotter_array; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 325 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 326 | 326 | { |
| 327 | 327 | global $global_query, $globalTimezone, $globalDBdriver; |
| 328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $limit_query = ''; |
| 331 | 331 | $additional_query = ''; |
| 332 | 332 | |
| 333 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 333 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 334 | 334 | |
| 335 | 335 | if ($date != "") |
| 336 | 336 | { |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | { |
| 357 | 357 | $limit_array = explode(",", $limit); |
| 358 | 358 | |
| 359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 361 | 361 | |
| 362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 363 | 363 | { |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | * @return Array list of source name |
| 389 | 389 | * |
| 390 | 390 | */ |
| 391 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 391 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 392 | 392 | { |
| 393 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 393 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 394 | 394 | $query_values = array(); |
| 395 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 395 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 396 | 396 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 397 | 397 | if ($type != '') { |
| 398 | 398 | $query_values = array(':type' => $type); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $source_array = array(); |
| 408 | 408 | $temp_array = array(); |
| 409 | 409 | |
| 410 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 410 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 411 | 411 | { |
| 412 | 412 | $temp_array['source_name'] = $row['source_name']; |
| 413 | 413 | $source_array[] = $temp_array; |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function getAllIdents($filters = array()) |
| 426 | 426 | { |
| 427 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 428 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 427 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 428 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 429 | 429 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 430 | 430 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $ident_array = array(); |
| 436 | 436 | $temp_array = array(); |
| 437 | 437 | |
| 438 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 438 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 439 | 439 | { |
| 440 | 440 | $temp_array['ident'] = $row['ident']; |
| 441 | 441 | $ident_array[] = $temp_array; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function getIdentity($mmsi) |
| 454 | 454 | { |
| 455 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 455 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 456 | 456 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 457 | 457 | $sth = $this->db->prepare($query); |
| 458 | 458 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | } else $offset = '+00:00'; |
| 478 | 478 | |
| 479 | 479 | if ($globalDBdriver == 'mysql') { |
| 480 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 480 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 481 | 481 | FROM marine_output |
| 482 | 482 | WHERE marine_output.date <> '' |
| 483 | 483 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 484 | 484 | } else { |
| 485 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 485 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 486 | 486 | FROM marine_output |
| 487 | 487 | WHERE marine_output.date <> '' |
| 488 | 488 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | $date_array = array(); |
| 495 | 495 | $temp_array = array(); |
| 496 | 496 | |
| 497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 498 | 498 | { |
| 499 | 499 | $temp_array['date'] = $row['date']; |
| 500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | * @return String success or false |
| 514 | 514 | * |
| 515 | 515 | */ |
| 516 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 516 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 517 | 517 | { |
| 518 | 518 | |
| 519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 520 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 521 | 521 | |
| 522 | 522 | try { |
| 523 | 523 | $sth = $this->db->prepare($query); |
@@ -539,11 +539,11 @@ discard block |
||
| 539 | 539 | * @return String success or false |
| 540 | 540 | * |
| 541 | 541 | */ |
| 542 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 542 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 543 | 543 | { |
| 544 | 544 | |
| 545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 547 | 547 | |
| 548 | 548 | try { |
| 549 | 549 | $sth = $this->db->prepare($query); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 567 | 567 | { |
| 568 | 568 | $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'; |
| 569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 569 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 570 | 570 | |
| 571 | 571 | try { |
| 572 | 572 | $sth = $this->db->prepare($query); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param String $verticalrate vertival rate of flight |
| 605 | 605 | * @return String success or false |
| 606 | 606 | */ |
| 607 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
| 607 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
| 608 | 608 | { |
| 609 | 609 | global $globalURL, $globalMarineImageFetch; |
| 610 | 610 | |
@@ -671,31 +671,31 @@ discard block |
||
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
| 674 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 674 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 675 | 675 | { |
| 676 | 676 | $date = date("Y-m-d H:i:s", time()); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 680 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 683 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 684 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 685 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 686 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 687 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 688 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 689 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 690 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 691 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 692 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 679 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 680 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 683 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 684 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 685 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 686 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 687 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 688 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 689 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 690 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 691 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 692 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | |
| 694 | 694 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 695 | 695 | $Image = new Image($this->db); |
| 696 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 696 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 697 | 697 | if (!isset($image_array[0]['mmsi'])) { |
| 698 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 698 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 699 | 699 | } |
| 700 | 700 | unset($Image); |
| 701 | 701 | } |
@@ -707,10 +707,10 @@ discard block |
||
| 707 | 707 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 708 | 708 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 709 | 709 | if ($arrival_date == '') $arrival_date = NULL; |
| 710 | - $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) |
|
| 710 | + $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) |
|
| 711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 712 | 712 | |
| 713 | - $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); |
|
| 713 | + $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); |
|
| 714 | 714 | try { |
| 715 | 715 | |
| 716 | 716 | $sth = $this->db->prepare($query); |
@@ -735,13 +735,13 @@ discard block |
||
| 735 | 735 | { |
| 736 | 736 | global $globalDBdriver, $globalTimezone; |
| 737 | 737 | if ($globalDBdriver == 'mysql') { |
| 738 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 738 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 739 | 739 | WHERE marine_output.ident = :ident |
| 740 | 740 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 741 | 741 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 742 | 742 | $query_data = array(':ident' => $ident); |
| 743 | 743 | } else { |
| 744 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 744 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 745 | 745 | WHERE marine_output.ident = :ident |
| 746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -750,8 +750,8 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | $sth = $this->db->prepare($query); |
| 752 | 752 | $sth->execute($query_data); |
| 753 | - $ident_result=''; |
|
| 754 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 753 | + $ident_result = ''; |
|
| 754 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 755 | 755 | { |
| 756 | 756 | $ident_result = $row['ident']; |
| 757 | 757 | } |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | return false; |
| 778 | 778 | } else { |
| 779 | 779 | $q_array = explode(" ", $q); |
| 780 | - foreach ($q_array as $q_item){ |
|
| 781 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 780 | + foreach ($q_array as $q_item) { |
|
| 781 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 782 | 782 | $additional_query .= " AND ("; |
| 783 | 783 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 784 | 784 | $additional_query .= ")"; |
@@ -786,11 +786,11 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | if ($globalDBdriver == 'mysql') { |
| 789 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 789 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 790 | 790 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 791 | 791 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 792 | 792 | } else { |
| 793 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 793 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 794 | 794 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 795 | 795 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 796 | 796 | } |
@@ -809,16 +809,16 @@ discard block |
||
| 809 | 809 | * |
| 810 | 810 | */ |
| 811 | 811 | |
| 812 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 812 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 813 | 813 | { |
| 814 | 814 | global $globalDBdriver, $globalArchive; |
| 815 | 815 | //$filter_query = $this->getFilter($filters,true,true); |
| 816 | - $Connection= new Connection($this->db); |
|
| 816 | + $Connection = new Connection($this->db); |
|
| 817 | 817 | if (!$Connection->tableExists('countries')) return array(); |
| 818 | 818 | require_once('class.SpotterLive.php'); |
| 819 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 820 | 820 | $MarineLive = new MarineLive($this->db); |
| 821 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 821 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 822 | 822 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 823 | 823 | if ($olderthanmonths > 0) { |
| 824 | 824 | if ($globalDBdriver == 'mysql') { |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | } else { |
| 839 | 839 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 840 | 840 | $MarineArchive = new MarineArchive($this->db); |
| 841 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 841 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 842 | 842 | $filter_query .= " over_country <> ''"; |
| 843 | 843 | if ($olderthanmonths > 0) { |
| 844 | 844 | if ($globalDBdriver == 'mysql') { |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | $flight_array = array(); |
| 867 | 867 | $temp_array = array(); |
| 868 | 868 | |
| 869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 870 | 870 | { |
| 871 | 871 | $temp_array['marine_count'] = $row['nb']; |
| 872 | 872 | $temp_array['marine_country'] = $row['name']; |
@@ -885,11 +885,11 @@ discard block |
||
| 885 | 885 | * @return Array the callsign list |
| 886 | 886 | * |
| 887 | 887 | */ |
| 888 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 888 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 889 | 889 | { |
| 890 | 890 | global $globalDBdriver; |
| 891 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 892 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 891 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 892 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 893 | 893 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 894 | 894 | if ($olderthanmonths > 0) { |
| 895 | 895 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -903,28 +903,28 @@ discard block |
||
| 903 | 903 | if ($year != '') { |
| 904 | 904 | if ($globalDBdriver == 'mysql') { |
| 905 | 905 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 906 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 906 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 907 | 907 | } else { |
| 908 | 908 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 909 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 909 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | 912 | if ($month != '') { |
| 913 | 913 | if ($globalDBdriver == 'mysql') { |
| 914 | 914 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 915 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 915 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 916 | 916 | } else { |
| 917 | 917 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 918 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 918 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | if ($day != '') { |
| 922 | 922 | if ($globalDBdriver == 'mysql') { |
| 923 | 923 | $query .= " AND DAY(marine_output.date) = :day"; |
| 924 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 924 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 925 | 925 | } else { |
| 926 | 926 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 927 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 927 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $callsign_array = array(); |
| 937 | 937 | $temp_array = array(); |
| 938 | 938 | |
| 939 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 939 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 940 | 940 | { |
| 941 | 941 | $temp_array['callsign_icao'] = $row['ident']; |
| 942 | 942 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | $date_array = array(); |
| 989 | 989 | $temp_array = array(); |
| 990 | 990 | |
| 991 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 991 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 992 | 992 | { |
| 993 | 993 | $temp_array['date_name'] = $row['date_name']; |
| 994 | 994 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $datetime = new DateTime(); |
| 1015 | 1015 | $offset = $datetime->format('P'); |
| 1016 | 1016 | } else $offset = '+00:00'; |
| 1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1018 | 1018 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1020 | 1020 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | $date_array = array(); |
| 1036 | 1036 | $temp_array = array(); |
| 1037 | 1037 | |
| 1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
| 1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | $datetime = new DateTime(); |
| 1061 | 1061 | $offset = $datetime->format('P'); |
| 1062 | 1062 | } else $offset = '+00:00'; |
| 1063 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1063 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1064 | 1064 | if ($globalDBdriver == 'mysql') { |
| 1065 | 1065 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1066 | 1066 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | $date_array = array(); |
| 1082 | 1082 | $temp_array = array(); |
| 1083 | 1083 | |
| 1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1085 | 1085 | { |
| 1086 | 1086 | $temp_array['date_name'] = $row['date_name']; |
| 1087 | 1087 | $temp_array['date_count'] = $row['date_count']; |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | $date_array = array(); |
| 1129 | 1129 | $temp_array = array(); |
| 1130 | 1130 | |
| 1131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1132 | 1132 | { |
| 1133 | 1133 | $temp_array['month_name'] = $row['month_name']; |
| 1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | $datetime = new DateTime(); |
| 1158 | 1158 | $offset = $datetime->format('P'); |
| 1159 | 1159 | } else $offset = '+00:00'; |
| 1160 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1160 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1161 | 1161 | if ($globalDBdriver == 'mysql') { |
| 1162 | 1162 | $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 |
| 1163 | 1163 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | $date_array = array(); |
| 1179 | 1179 | $temp_array = array(); |
| 1180 | 1180 | |
| 1181 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1182 | 1182 | { |
| 1183 | 1183 | $temp_array['year_name'] = $row['year_name']; |
| 1184 | 1184 | $temp_array['month_name'] = $row['month_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | * @return Array the hour list |
| 1199 | 1199 | * |
| 1200 | 1200 | */ |
| 1201 | - public function countAllHours($orderby,$filters = array()) |
|
| 1201 | + public function countAllHours($orderby, $filters = array()) |
|
| 1202 | 1202 | { |
| 1203 | 1203 | global $globalTimezone, $globalDBdriver; |
| 1204 | 1204 | if ($globalTimezone != '') { |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | $hour_array = array(); |
| 1247 | 1247 | $temp_array = array(); |
| 1248 | 1248 | |
| 1249 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1249 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1250 | 1250 | { |
| 1251 | 1251 | $temp_array['hour_name'] = $row['hour_name']; |
| 1252 | 1252 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
| 1269 | 1269 | { |
| 1270 | 1270 | global $globalTimezone, $globalDBdriver; |
| 1271 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1272 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1271 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1272 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1273 | 1273 | if ($globalTimezone != '') { |
| 1274 | 1274 | date_default_timezone_set($globalTimezone); |
| 1275 | 1275 | $datetime = new DateTime($date); |
@@ -1277,12 +1277,12 @@ discard block |
||
| 1277 | 1277 | } else $offset = '+00:00'; |
| 1278 | 1278 | |
| 1279 | 1279 | if ($globalDBdriver == 'mysql') { |
| 1280 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1280 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1281 | 1281 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1282 | 1282 | GROUP BY hour_name |
| 1283 | 1283 | ORDER BY hour_name ASC"; |
| 1284 | 1284 | } else { |
| 1285 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1285 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1286 | 1286 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1287 | 1287 | GROUP BY hour_name |
| 1288 | 1288 | ORDER BY hour_name ASC"; |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | $hour_array = array(); |
| 1295 | 1295 | $temp_array = array(); |
| 1296 | 1296 | |
| 1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
| 1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1316,8 +1316,8 @@ discard block |
||
| 1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1317 | 1317 | { |
| 1318 | 1318 | global $globalTimezone, $globalDBdriver; |
| 1319 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1320 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1319 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1321 | 1321 | if ($globalTimezone != '') { |
| 1322 | 1322 | date_default_timezone_set($globalTimezone); |
| 1323 | 1323 | $datetime = new DateTime(); |
@@ -1325,12 +1325,12 @@ discard block |
||
| 1325 | 1325 | } else $offset = '+00:00'; |
| 1326 | 1326 | |
| 1327 | 1327 | if ($globalDBdriver == 'mysql') { |
| 1328 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1328 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1329 | 1329 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1330 | 1330 | GROUP BY hour_name |
| 1331 | 1331 | ORDER BY hour_name ASC"; |
| 1332 | 1332 | } else { |
| 1333 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1333 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1334 | 1334 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1335 | 1335 | GROUP BY hour_name |
| 1336 | 1336 | ORDER BY hour_name ASC"; |
@@ -1338,12 +1338,12 @@ discard block |
||
| 1338 | 1338 | |
| 1339 | 1339 | |
| 1340 | 1340 | $sth = $this->db->prepare($query); |
| 1341 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1341 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1342 | 1342 | |
| 1343 | 1343 | $hour_array = array(); |
| 1344 | 1344 | $temp_array = array(); |
| 1345 | 1345 | |
| 1346 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1346 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1347 | 1347 | { |
| 1348 | 1348 | $temp_array['hour_name'] = $row['hour_name']; |
| 1349 | 1349 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1362,33 +1362,33 @@ discard block |
||
| 1362 | 1362 | * @return Integer the number of vessels |
| 1363 | 1363 | * |
| 1364 | 1364 | */ |
| 1365 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1365 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1366 | 1366 | { |
| 1367 | 1367 | global $globalDBdriver; |
| 1368 | 1368 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1369 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1369 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1370 | 1370 | $query_values = array(); |
| 1371 | 1371 | $query = ''; |
| 1372 | 1372 | if ($year != '') { |
| 1373 | 1373 | if ($globalDBdriver == 'mysql') { |
| 1374 | 1374 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1375 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1375 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1376 | 1376 | } else { |
| 1377 | 1377 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1378 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1378 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | } |
| 1381 | 1381 | if ($month != '') { |
| 1382 | 1382 | if ($globalDBdriver == 'mysql') { |
| 1383 | 1383 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1384 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1384 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1385 | 1385 | } else { |
| 1386 | 1386 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1387 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1387 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1388 | 1388 | } |
| 1389 | 1389 | } |
| 1390 | 1390 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1391 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1392 | 1392 | |
| 1393 | 1393 | $sth = $this->db->prepare($queryi); |
| 1394 | 1394 | $sth->execute($query_values); |
@@ -1401,32 +1401,32 @@ discard block |
||
| 1401 | 1401 | * @return Integer the number of vessels |
| 1402 | 1402 | * |
| 1403 | 1403 | */ |
| 1404 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1404 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1405 | 1405 | { |
| 1406 | 1406 | global $globalDBdriver; |
| 1407 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1407 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1408 | 1408 | $query_values = array(); |
| 1409 | 1409 | $query = ''; |
| 1410 | 1410 | if ($year != '') { |
| 1411 | 1411 | if ($globalDBdriver == 'mysql') { |
| 1412 | 1412 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1413 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1413 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1414 | 1414 | } else { |
| 1415 | 1415 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | } |
| 1419 | 1419 | if ($month != '') { |
| 1420 | 1420 | if ($globalDBdriver == 'mysql') { |
| 1421 | 1421 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1422 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1422 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1423 | 1423 | } else { |
| 1424 | 1424 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1429 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1430 | 1430 | |
| 1431 | 1431 | $sth = $this->db->prepare($queryi); |
| 1432 | 1432 | $sth->execute($query_values); |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
| 1444 | 1444 | { |
| 1445 | 1445 | global $globalTimezone, $globalDBdriver; |
| 1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1447 | 1447 | if ($globalTimezone != '') { |
| 1448 | 1448 | date_default_timezone_set($globalTimezone); |
| 1449 | 1449 | $datetime = new DateTime(); |
@@ -1451,12 +1451,12 @@ discard block |
||
| 1451 | 1451 | } else $offset = '+00:00'; |
| 1452 | 1452 | |
| 1453 | 1453 | if ($globalDBdriver == 'mysql') { |
| 1454 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1454 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1455 | 1455 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1456 | 1456 | GROUP BY hour_name |
| 1457 | 1457 | ORDER BY hour_name ASC"; |
| 1458 | 1458 | } else { |
| 1459 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1459 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1460 | 1460 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1461 | 1461 | GROUP BY hour_name |
| 1462 | 1462 | ORDER BY hour_name ASC"; |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | $hour_array = array(); |
| 1469 | 1469 | $temp_array = array(); |
| 1470 | 1470 | |
| 1471 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1471 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1472 | 1472 | { |
| 1473 | 1473 | $temp_array['hour_name'] = $row['hour_name']; |
| 1474 | 1474 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1487,9 +1487,9 @@ discard block |
||
| 1487 | 1487 | */ |
| 1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1489 | 1489 | { |
| 1490 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1490 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1491 | 1491 | |
| 1492 | - $query = "SELECT marine_output.marine_id |
|
| 1492 | + $query = "SELECT marine_output.marine_id |
|
| 1493 | 1493 | FROM marine_output |
| 1494 | 1494 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1495 | 1495 | |
@@ -1497,7 +1497,7 @@ discard block |
||
| 1497 | 1497 | $sth = $this->db->prepare($query); |
| 1498 | 1498 | $sth->execute(); |
| 1499 | 1499 | |
| 1500 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1500 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1501 | 1501 | { |
| 1502 | 1502 | return $row['marine_id']; |
| 1503 | 1503 | } |
@@ -1522,23 +1522,23 @@ discard block |
||
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | $current_date = date("Y-m-d H:i:s"); |
| 1525 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1525 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1526 | 1526 | |
| 1527 | 1527 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1528 | 1528 | |
| 1529 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1529 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1530 | 1530 | $years = $time_array['years']; |
| 1531 | 1531 | |
| 1532 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1532 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1533 | 1533 | $months = $time_array['months']; |
| 1534 | 1534 | |
| 1535 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1535 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1536 | 1536 | $days = $time_array['days']; |
| 1537 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1537 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1538 | 1538 | $hours = $time_array['hours']; |
| 1539 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1539 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1540 | 1540 | $minutes = $time_array['minutes']; |
| 1541 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1541 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1542 | 1542 | |
| 1543 | 1543 | return $time_array; |
| 1544 | 1544 | } |
@@ -1561,63 +1561,63 @@ discard block |
||
| 1561 | 1561 | $temp_array['direction_degree'] = $direction; |
| 1562 | 1562 | $temp_array['direction_shortname'] = "N"; |
| 1563 | 1563 | $temp_array['direction_fullname'] = "North"; |
| 1564 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1564 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1565 | 1565 | $temp_array['direction_degree'] = $direction; |
| 1566 | 1566 | $temp_array['direction_shortname'] = "NNE"; |
| 1567 | 1567 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1568 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1568 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1569 | 1569 | $temp_array['direction_degree'] = $direction; |
| 1570 | 1570 | $temp_array['direction_shortname'] = "NE"; |
| 1571 | 1571 | $temp_array['direction_fullname'] = "Northeast"; |
| 1572 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1572 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1573 | 1573 | $temp_array['direction_degree'] = $direction; |
| 1574 | 1574 | $temp_array['direction_shortname'] = "ENE"; |
| 1575 | 1575 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1576 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1576 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1577 | 1577 | $temp_array['direction_degree'] = $direction; |
| 1578 | 1578 | $temp_array['direction_shortname'] = "E"; |
| 1579 | 1579 | $temp_array['direction_fullname'] = "East"; |
| 1580 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1580 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1581 | 1581 | $temp_array['direction_degree'] = $direction; |
| 1582 | 1582 | $temp_array['direction_shortname'] = "ESE"; |
| 1583 | 1583 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1584 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1584 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1585 | 1585 | $temp_array['direction_degree'] = $direction; |
| 1586 | 1586 | $temp_array['direction_shortname'] = "SE"; |
| 1587 | 1587 | $temp_array['direction_fullname'] = "Southeast"; |
| 1588 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1588 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1589 | 1589 | $temp_array['direction_degree'] = $direction; |
| 1590 | 1590 | $temp_array['direction_shortname'] = "SSE"; |
| 1591 | 1591 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1592 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1592 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1593 | 1593 | $temp_array['direction_degree'] = $direction; |
| 1594 | 1594 | $temp_array['direction_shortname'] = "S"; |
| 1595 | 1595 | $temp_array['direction_fullname'] = "South"; |
| 1596 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1596 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1597 | 1597 | $temp_array['direction_degree'] = $direction; |
| 1598 | 1598 | $temp_array['direction_shortname'] = "SSW"; |
| 1599 | 1599 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1600 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1600 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1601 | 1601 | $temp_array['direction_degree'] = $direction; |
| 1602 | 1602 | $temp_array['direction_shortname'] = "SW"; |
| 1603 | 1603 | $temp_array['direction_fullname'] = "Southwest"; |
| 1604 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1604 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1605 | 1605 | $temp_array['direction_degree'] = $direction; |
| 1606 | 1606 | $temp_array['direction_shortname'] = "WSW"; |
| 1607 | 1607 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1608 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1608 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1609 | 1609 | $temp_array['direction_degree'] = $direction; |
| 1610 | 1610 | $temp_array['direction_shortname'] = "W"; |
| 1611 | 1611 | $temp_array['direction_fullname'] = "West"; |
| 1612 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1612 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1613 | 1613 | $temp_array['direction_degree'] = $direction; |
| 1614 | 1614 | $temp_array['direction_shortname'] = "WNW"; |
| 1615 | 1615 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1616 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1616 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1617 | 1617 | $temp_array['direction_degree'] = $direction; |
| 1618 | 1618 | $temp_array['direction_shortname'] = "NW"; |
| 1619 | 1619 | $temp_array['direction_fullname'] = "Northwest"; |
| 1620 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1620 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1621 | 1621 | $temp_array['direction_degree'] = $direction; |
| 1622 | 1622 | $temp_array['direction_shortname'] = "NNW"; |
| 1623 | 1623 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1634,11 +1634,11 @@ discard block |
||
| 1634 | 1634 | * @param Float $longitude longitute of the flight |
| 1635 | 1635 | * @return String the countrie |
| 1636 | 1636 | */ |
| 1637 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1637 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1638 | 1638 | { |
| 1639 | 1639 | global $globalDBdriver, $globalDebug; |
| 1640 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1641 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1640 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1641 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1642 | 1642 | |
| 1643 | 1643 | $Connection = new Connection($this->db); |
| 1644 | 1644 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1678,7 +1678,7 @@ discard block |
||
| 1678 | 1678 | public function getCountryFromISO2($iso2) |
| 1679 | 1679 | { |
| 1680 | 1680 | global $globalDBdriver, $globalDebug; |
| 1681 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1681 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1682 | 1682 | |
| 1683 | 1683 | $Connection = new Connection($this->db); |
| 1684 | 1684 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1726,7 +1726,7 @@ discard block |
||
| 1726 | 1726 | |
| 1727 | 1727 | $bitly_data = json_decode($bitly_data); |
| 1728 | 1728 | $bitly_url = ''; |
| 1729 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1729 | + if ($bitly_data->status_txt = "OK") { |
|
| 1730 | 1730 | $bitly_url = $bitly_data->data->url; |
| 1731 | 1731 | } |
| 1732 | 1732 | |
@@ -1740,11 +1740,11 @@ discard block |
||
| 1740 | 1740 | * @return Array the vessel type list |
| 1741 | 1741 | * |
| 1742 | 1742 | */ |
| 1743 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1743 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1744 | 1744 | { |
| 1745 | 1745 | global $globalDBdriver; |
| 1746 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1747 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1746 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1747 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1748 | 1748 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
| 1749 | 1749 | if ($olderthanmonths > 0) { |
| 1750 | 1750 | if ($globalDBdriver == 'mysql') { |
@@ -1764,28 +1764,28 @@ discard block |
||
| 1764 | 1764 | if ($year != '') { |
| 1765 | 1765 | if ($globalDBdriver == 'mysql') { |
| 1766 | 1766 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1767 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1767 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1768 | 1768 | } else { |
| 1769 | 1769 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1770 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1770 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1771 | 1771 | } |
| 1772 | 1772 | } |
| 1773 | 1773 | if ($month != '') { |
| 1774 | 1774 | if ($globalDBdriver == 'mysql') { |
| 1775 | 1775 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1776 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1776 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1777 | 1777 | } else { |
| 1778 | 1778 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1779 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1779 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1780 | 1780 | } |
| 1781 | 1781 | } |
| 1782 | 1782 | if ($day != '') { |
| 1783 | 1783 | if ($globalDBdriver == 'mysql') { |
| 1784 | 1784 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1785 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1785 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1786 | 1786 | } else { |
| 1787 | 1787 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1788 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1788 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1789 | 1789 | } |
| 1790 | 1790 | } |
| 1791 | 1791 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | $sth->execute($query_values); |
| 1795 | 1795 | $marine_array = array(); |
| 1796 | 1796 | $temp_array = array(); |
| 1797 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1797 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1798 | 1798 | { |
| 1799 | 1799 | $temp_array['marine_type'] = $row['marine_type']; |
| 1800 | 1800 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | |
| 1806 | 1806 | public function getOrderBy() |
| 1807 | 1807 | { |
| 1808 | - $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")); |
|
| 1808 | + $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")); |
|
| 1809 | 1809 | |
| 1810 | 1810 | return $orderby; |
| 1811 | 1811 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -69,8 +73,11 @@ discard block |
||
| 69 | 73 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 70 | 74 | } |
| 71 | 75 | } |
| 72 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 73 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 76 | + if ($filter_query_where == '' && $where) { |
|
| 77 | + $filter_query_where = ' WHERE'; |
|
| 78 | + } elseif ($filter_query_where != '' && $and) { |
|
| 79 | + $filter_query_where .= ' AND'; |
|
| 80 | + } |
|
| 74 | 81 | if ($filter_query_where != '') { |
| 75 | 82 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 76 | 83 | } |
@@ -124,32 +131,54 @@ discard block |
||
| 124 | 131 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 125 | 132 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 127 | - */} |
|
| 128 | - elseif (isset($row['marineid'])) { |
|
| 134 | + */} elseif (isset($row['marineid'])) { |
|
| 129 | 135 | $temp_array['marine_id'] = $row['marineid']; |
| 130 | 136 | } else { |
| 131 | 137 | $temp_array['marine_id'] = ''; |
| 132 | 138 | } |
| 133 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 134 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 136 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 137 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 139 | + if (isset($row['fammarine_id'])) { |
|
| 140 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 141 | + } |
|
| 142 | + if (isset($row['mmsi'])) { |
|
| 143 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['type'])) { |
|
| 146 | + $temp_array['type'] = $row['type']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['type_id'])) { |
|
| 149 | + $temp_array['type_id'] = $row['type_id']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['ident'])) { |
|
| 152 | + $temp_array['ident'] = $row['ident']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['latitude'])) { |
|
| 155 | + $temp_array['latitude'] = $row['latitude']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['longitude'])) { |
|
| 158 | + $temp_array['longitude'] = $row['longitude']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['format_source'])) { |
|
| 161 | + $temp_array['format_source'] = $row['format_source']; |
|
| 162 | + } |
|
| 141 | 163 | if (isset($row['heading'])) { |
| 142 | 164 | $temp_array['heading'] = $row['heading']; |
| 143 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
| 144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + if (isset($row['ground_speed'])) { |
|
| 171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 145 | 172 | } |
| 146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 147 | 173 | |
| 148 | 174 | if($temp_array['mmsi'] != "") |
| 149 | 175 | { |
| 150 | 176 | $Image = new Image($this->db); |
| 151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 152 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 177 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 178 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 179 | + } else { |
|
| 180 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 181 | + } |
|
| 153 | 182 | unset($Image); |
| 154 | 183 | if (count($image_array) > 0) { |
| 155 | 184 | $temp_array['image'] = $image_array[0]['image']; |
@@ -201,13 +230,21 @@ discard block |
||
| 201 | 230 | } |
| 202 | 231 | |
| 203 | 232 | $fromsource = NULL; |
| 204 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 205 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 206 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 233 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 234 | + $temp_array['source_name'] = $row['source_name']; |
|
| 235 | + } |
|
| 236 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 237 | + $temp_array['over_country'] = $row['over_country']; |
|
| 238 | + } |
|
| 239 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 240 | + $temp_array['distance'] = $row['distance']; |
|
| 241 | + } |
|
| 207 | 242 | $temp_array['query_number_rows'] = $num_rows; |
| 208 | 243 | $spotter_array[] = $temp_array; |
| 209 | 244 | } |
| 210 | - if ($num_rows == 0) return array(); |
|
| 245 | + if ($num_rows == 0) { |
|
| 246 | + return array(); |
|
| 247 | + } |
|
| 211 | 248 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 212 | 249 | return $spotter_array; |
| 213 | 250 | } |
@@ -233,8 +270,12 @@ discard block |
||
| 233 | 270 | { |
| 234 | 271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 235 | 272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 236 | - } else $limit_query = ""; |
|
| 237 | - } else $limit_query = ""; |
|
| 273 | + } else { |
|
| 274 | + $limit_query = ""; |
|
| 275 | + } |
|
| 276 | + } else { |
|
| 277 | + $limit_query = ""; |
|
| 278 | + } |
|
| 238 | 279 | if ($sort != "") |
| 239 | 280 | { |
| 240 | 281 | $search_orderby_array = $this->getOrderBy(); |
@@ -258,7 +299,9 @@ discard block |
||
| 258 | 299 | global $global_query; |
| 259 | 300 | |
| 260 | 301 | date_default_timezone_set('UTC'); |
| 261 | - if ($id == '') return array(); |
|
| 302 | + if ($id == '') { |
|
| 303 | + return array(); |
|
| 304 | + } |
|
| 262 | 305 | $additional_query = "marine_output.fammarine_id = :id"; |
| 263 | 306 | $query_values = array(':id' => $id); |
| 264 | 307 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -401,8 +444,11 @@ discard block |
||
| 401 | 444 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 402 | 445 | |
| 403 | 446 | $sth = $this->db->prepare($query); |
| 404 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 405 | - else $sth->execute(); |
|
| 447 | + if (!empty($query_values)) { |
|
| 448 | + $sth->execute($query_values); |
|
| 449 | + } else { |
|
| 450 | + $sth->execute(); |
|
| 451 | + } |
|
| 406 | 452 | |
| 407 | 453 | $source_array = array(); |
| 408 | 454 | $temp_array = array(); |
@@ -457,8 +503,11 @@ discard block |
||
| 457 | 503 | $sth = $this->db->prepare($query); |
| 458 | 504 | $sth->execute(array(':mmsi' => $mmsi)); |
| 459 | 505 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 460 | - if (isset($result[0])) return $result[0]; |
|
| 461 | - else return array(); |
|
| 506 | + if (isset($result[0])) { |
|
| 507 | + return $result[0]; |
|
| 508 | + } else { |
|
| 509 | + return array(); |
|
| 510 | + } |
|
| 462 | 511 | } |
| 463 | 512 | |
| 464 | 513 | /* |
@@ -474,7 +523,9 @@ discard block |
||
| 474 | 523 | date_default_timezone_set($globalTimezone); |
| 475 | 524 | $datetime = new DateTime(); |
| 476 | 525 | $offset = $datetime->format('P'); |
| 477 | - } else $offset = '+00:00'; |
|
| 526 | + } else { |
|
| 527 | + $offset = '+00:00'; |
|
| 528 | + } |
|
| 478 | 529 | |
| 479 | 530 | if ($globalDBdriver == 'mysql') { |
| 480 | 531 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -704,9 +755,15 @@ discard block |
||
| 704 | 755 | $latitude = 0; |
| 705 | 756 | $longitude = 0; |
| 706 | 757 | } |
| 707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 758 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 759 | + $heading = 0; |
|
| 760 | + } |
|
| 761 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 762 | + $groundspeed = 0; |
|
| 763 | + } |
|
| 764 | + if ($arrival_date == '') { |
|
| 765 | + $arrival_date = NULL; |
|
| 766 | + } |
|
| 710 | 767 | $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) |
| 711 | 768 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 712 | 769 | |
@@ -814,7 +871,9 @@ discard block |
||
| 814 | 871 | global $globalDBdriver, $globalArchive; |
| 815 | 872 | //$filter_query = $this->getFilter($filters,true,true); |
| 816 | 873 | $Connection= new Connection($this->db); |
| 817 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 874 | + if (!$Connection->tableExists('countries')) { |
|
| 875 | + return array(); |
|
| 876 | + } |
|
| 818 | 877 | require_once('class.SpotterLive.php'); |
| 819 | 878 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 820 | 879 | $MarineLive = new MarineLive($this->db); |
@@ -858,7 +917,9 @@ discard block |
||
| 858 | 917 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 859 | 918 | } |
| 860 | 919 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 861 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 920 | + if ($limit) { |
|
| 921 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 922 | + } |
|
| 862 | 923 | |
| 863 | 924 | $sth = $this->db->prepare($query); |
| 864 | 925 | $sth->execute(); |
@@ -892,12 +953,18 @@ discard block |
||
| 892 | 953 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 893 | 954 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 894 | 955 | if ($olderthanmonths > 0) { |
| 895 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 896 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 956 | + if ($globalDBdriver == 'mysql') { |
|
| 957 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 958 | + } else { |
|
| 959 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 960 | + } |
|
| 897 | 961 | } |
| 898 | 962 | if ($sincedate != '') { |
| 899 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 900 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 963 | + if ($globalDBdriver == 'mysql') { |
|
| 964 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 965 | + } else { |
|
| 966 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 967 | + } |
|
| 901 | 968 | } |
| 902 | 969 | $query_values = array(); |
| 903 | 970 | if ($year != '') { |
@@ -928,7 +995,9 @@ discard block |
||
| 928 | 995 | } |
| 929 | 996 | } |
| 930 | 997 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 931 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 998 | + if ($limit) { |
|
| 999 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1000 | + } |
|
| 932 | 1001 | |
| 933 | 1002 | $sth = $this->db->prepare($query); |
| 934 | 1003 | $sth->execute($query_values); |
@@ -963,7 +1032,9 @@ discard block |
||
| 963 | 1032 | date_default_timezone_set($globalTimezone); |
| 964 | 1033 | $datetime = new DateTime(); |
| 965 | 1034 | $offset = $datetime->format('P'); |
| 966 | - } else $offset = '+00:00'; |
|
| 1035 | + } else { |
|
| 1036 | + $offset = '+00:00'; |
|
| 1037 | + } |
|
| 967 | 1038 | |
| 968 | 1039 | if ($globalDBdriver == 'mysql') { |
| 969 | 1040 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1084,9 @@ discard block |
||
| 1013 | 1084 | date_default_timezone_set($globalTimezone); |
| 1014 | 1085 | $datetime = new DateTime(); |
| 1015 | 1086 | $offset = $datetime->format('P'); |
| 1016 | - } else $offset = '+00:00'; |
|
| 1087 | + } else { |
|
| 1088 | + $offset = '+00:00'; |
|
| 1089 | + } |
|
| 1017 | 1090 | $filter_query = $this->getFilter($filters,true,true); |
| 1018 | 1091 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1092 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1059,7 +1132,9 @@ discard block |
||
| 1059 | 1132 | date_default_timezone_set($globalTimezone); |
| 1060 | 1133 | $datetime = new DateTime(); |
| 1061 | 1134 | $offset = $datetime->format('P'); |
| 1062 | - } else $offset = '+00:00'; |
|
| 1135 | + } else { |
|
| 1136 | + $offset = '+00:00'; |
|
| 1137 | + } |
|
| 1063 | 1138 | $filter_query = $this->getFilter($filters,true,true); |
| 1064 | 1139 | if ($globalDBdriver == 'mysql') { |
| 1065 | 1140 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1107,7 +1182,9 @@ discard block |
||
| 1107 | 1182 | date_default_timezone_set($globalTimezone); |
| 1108 | 1183 | $datetime = new DateTime(); |
| 1109 | 1184 | $offset = $datetime->format('P'); |
| 1110 | - } else $offset = '+00:00'; |
|
| 1185 | + } else { |
|
| 1186 | + $offset = '+00:00'; |
|
| 1187 | + } |
|
| 1111 | 1188 | |
| 1112 | 1189 | if ($globalDBdriver == 'mysql') { |
| 1113 | 1190 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1156,7 +1233,9 @@ discard block |
||
| 1156 | 1233 | date_default_timezone_set($globalTimezone); |
| 1157 | 1234 | $datetime = new DateTime(); |
| 1158 | 1235 | $offset = $datetime->format('P'); |
| 1159 | - } else $offset = '+00:00'; |
|
| 1236 | + } else { |
|
| 1237 | + $offset = '+00:00'; |
|
| 1238 | + } |
|
| 1160 | 1239 | $filter_query = $this->getFilter($filters,true,true); |
| 1161 | 1240 | if ($globalDBdriver == 'mysql') { |
| 1162 | 1241 | $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 |
@@ -1205,7 +1284,9 @@ discard block |
||
| 1205 | 1284 | date_default_timezone_set($globalTimezone); |
| 1206 | 1285 | $datetime = new DateTime(); |
| 1207 | 1286 | $offset = $datetime->format('P'); |
| 1208 | - } else $offset = '+00:00'; |
|
| 1287 | + } else { |
|
| 1288 | + $offset = '+00:00'; |
|
| 1289 | + } |
|
| 1209 | 1290 | |
| 1210 | 1291 | $orderby_sql = ''; |
| 1211 | 1292 | if ($orderby == "hour") |
@@ -1274,7 +1355,9 @@ discard block |
||
| 1274 | 1355 | date_default_timezone_set($globalTimezone); |
| 1275 | 1356 | $datetime = new DateTime($date); |
| 1276 | 1357 | $offset = $datetime->format('P'); |
| 1277 | - } else $offset = '+00:00'; |
|
| 1358 | + } else { |
|
| 1359 | + $offset = '+00:00'; |
|
| 1360 | + } |
|
| 1278 | 1361 | |
| 1279 | 1362 | if ($globalDBdriver == 'mysql') { |
| 1280 | 1363 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1322,7 +1405,9 @@ discard block |
||
| 1322 | 1405 | date_default_timezone_set($globalTimezone); |
| 1323 | 1406 | $datetime = new DateTime(); |
| 1324 | 1407 | $offset = $datetime->format('P'); |
| 1325 | - } else $offset = '+00:00'; |
|
| 1408 | + } else { |
|
| 1409 | + $offset = '+00:00'; |
|
| 1410 | + } |
|
| 1326 | 1411 | |
| 1327 | 1412 | if ($globalDBdriver == 'mysql') { |
| 1328 | 1413 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1387,8 +1472,11 @@ discard block |
||
| 1387 | 1472 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1388 | 1473 | } |
| 1389 | 1474 | } |
| 1390 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1475 | + if (empty($query_values)) { |
|
| 1476 | + $queryi .= $this->getFilter($filters); |
|
| 1477 | + } else { |
|
| 1478 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1479 | + } |
|
| 1392 | 1480 | |
| 1393 | 1481 | $sth = $this->db->prepare($queryi); |
| 1394 | 1482 | $sth->execute($query_values); |
@@ -1425,8 +1513,11 @@ discard block |
||
| 1425 | 1513 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1426 | 1514 | } |
| 1427 | 1515 | } |
| 1428 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1516 | + if (empty($query_values)) { |
|
| 1517 | + $queryi .= $this->getFilter($filters); |
|
| 1518 | + } else { |
|
| 1519 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1520 | + } |
|
| 1430 | 1521 | |
| 1431 | 1522 | $sth = $this->db->prepare($queryi); |
| 1432 | 1523 | $sth->execute($query_values); |
@@ -1448,7 +1539,9 @@ discard block |
||
| 1448 | 1539 | date_default_timezone_set($globalTimezone); |
| 1449 | 1540 | $datetime = new DateTime(); |
| 1450 | 1541 | $offset = $datetime->format('P'); |
| 1451 | - } else $offset = '+00:00'; |
|
| 1542 | + } else { |
|
| 1543 | + $offset = '+00:00'; |
|
| 1544 | + } |
|
| 1452 | 1545 | |
| 1453 | 1546 | if ($globalDBdriver == 'mysql') { |
| 1454 | 1547 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1552,7 +1645,9 @@ discard block |
||
| 1552 | 1645 | */ |
| 1553 | 1646 | public function parseDirection($direction = 0) |
| 1554 | 1647 | { |
| 1555 | - if ($direction == '') $direction = 0; |
|
| 1648 | + if ($direction == '') { |
|
| 1649 | + $direction = 0; |
|
| 1650 | + } |
|
| 1556 | 1651 | $direction_array = array(); |
| 1557 | 1652 | $temp_array = array(); |
| 1558 | 1653 | |
@@ -1641,7 +1736,9 @@ discard block |
||
| 1641 | 1736 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1642 | 1737 | |
| 1643 | 1738 | $Connection = new Connection($this->db); |
| 1644 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1739 | + if (!$Connection->tableExists('countries')) { |
|
| 1740 | + return ''; |
|
| 1741 | + } |
|
| 1645 | 1742 | |
| 1646 | 1743 | try { |
| 1647 | 1744 | /* |
@@ -1661,9 +1758,13 @@ discard block |
||
| 1661 | 1758 | $sth->closeCursor(); |
| 1662 | 1759 | if (count($row) > 0) { |
| 1663 | 1760 | return $row; |
| 1664 | - } else return ''; |
|
| 1761 | + } else { |
|
| 1762 | + return ''; |
|
| 1763 | + } |
|
| 1665 | 1764 | } catch (PDOException $e) { |
| 1666 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1765 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1766 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1767 | + } |
|
| 1667 | 1768 | return ''; |
| 1668 | 1769 | } |
| 1669 | 1770 | |
@@ -1681,7 +1782,9 @@ discard block |
||
| 1681 | 1782 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1682 | 1783 | |
| 1683 | 1784 | $Connection = new Connection($this->db); |
| 1684 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1785 | + if (!$Connection->tableExists('countries')) { |
|
| 1786 | + return ''; |
|
| 1787 | + } |
|
| 1685 | 1788 | |
| 1686 | 1789 | try { |
| 1687 | 1790 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1693,9 +1796,13 @@ discard block |
||
| 1693 | 1796 | $sth->closeCursor(); |
| 1694 | 1797 | if (count($row) > 0) { |
| 1695 | 1798 | return $row; |
| 1696 | - } else return ''; |
|
| 1799 | + } else { |
|
| 1800 | + return ''; |
|
| 1801 | + } |
|
| 1697 | 1802 | } catch (PDOException $e) { |
| 1698 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1803 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1804 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1805 | + } |
|
| 1699 | 1806 | return ''; |
| 1700 | 1807 | } |
| 1701 | 1808 | |
@@ -1713,7 +1820,9 @@ discard block |
||
| 1713 | 1820 | { |
| 1714 | 1821 | global $globalBitlyAccessToken; |
| 1715 | 1822 | |
| 1716 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1823 | + if ($globalBitlyAccessToken == '') { |
|
| 1824 | + return $url; |
|
| 1825 | + } |
|
| 1717 | 1826 | |
| 1718 | 1827 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1719 | 1828 | |
@@ -1789,7 +1898,9 @@ discard block |
||
| 1789 | 1898 | } |
| 1790 | 1899 | } |
| 1791 | 1900 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
| 1792 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1901 | + if ($limit) { |
|
| 1902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1903 | + } |
|
| 1793 | 1904 | $sth = $this->db->prepare($query); |
| 1794 | 1905 | $sth->execute($query_values); |
| 1795 | 1906 | $marine_array = array(); |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Gets all the spotter information based on a particular callsign |
|
| 115 | - * |
|
| 116 | - * @return Array the spotter information |
|
| 117 | - * |
|
| 118 | - */ |
|
| 119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
| 120 | - { |
|
| 113 | + /** |
|
| 114 | + * Gets all the spotter information based on a particular callsign |
|
| 115 | + * |
|
| 116 | + * @return Array the spotter information |
|
| 117 | + * |
|
| 118 | + */ |
|
| 119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
| 120 | + { |
|
| 121 | 121 | $Marine = new Marine($this->db); |
| 122 | - date_default_timezone_set('UTC'); |
|
| 122 | + date_default_timezone_set('UTC'); |
|
| 123 | 123 | |
| 124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 127 | 127 | |
| 128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 129 | 129 | |
| 130 | - return $spotter_array; |
|
| 131 | - } |
|
| 130 | + return $spotter_array; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Gets last the spotter information based on a particular id |
|
| 136 | - * |
|
| 137 | - * @return Array the spotter information |
|
| 138 | - * |
|
| 139 | - */ |
|
| 140 | - public function getLastArchiveMarineDataById($id) |
|
| 141 | - { |
|
| 142 | - $Marine = new Marine($this->db); |
|
| 143 | - date_default_timezone_set('UTC'); |
|
| 144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 134 | + /** |
|
| 135 | + * Gets last the spotter information based on a particular id |
|
| 136 | + * |
|
| 137 | + * @return Array the spotter information |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | + public function getLastArchiveMarineDataById($id) |
|
| 141 | + { |
|
| 142 | + $Marine = new Marine($this->db); |
|
| 143 | + date_default_timezone_set('UTC'); |
|
| 144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 148 | 148 | |
| 149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 150 | - /* |
|
| 150 | + /* |
|
| 151 | 151 | try { |
| 152 | 152 | $Connection = new Connection(); |
| 153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,232 +157,232 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 159 | 159 | */ |
| 160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 161 | - |
|
| 162 | - return $spotter_array; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Gets all the spotter information based on a particular id |
|
| 167 | - * |
|
| 168 | - * @return Array the spotter information |
|
| 169 | - * |
|
| 170 | - */ |
|
| 171 | - public function getAllArchiveMarineDataById($id) |
|
| 160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 161 | + |
|
| 162 | + return $spotter_array; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Gets all the spotter information based on a particular id |
|
| 167 | + * |
|
| 168 | + * @return Array the spotter information |
|
| 169 | + * |
|
| 170 | + */ |
|
| 171 | + public function getAllArchiveMarineDataById($id) |
|
| 172 | 172 | { |
| 173 | - date_default_timezone_set('UTC'); |
|
| 174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 173 | + date_default_timezone_set('UTC'); |
|
| 174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 176 | 176 | |
| 177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 178 | 178 | |
| 179 | - try { |
|
| 180 | - $sth = $this->db->prepare($query); |
|
| 181 | - $sth->execute(array(':id' => $id)); |
|
| 182 | - } catch(PDOException $e) { |
|
| 183 | - echo $e->getMessage(); |
|
| 184 | - die; |
|
| 185 | - } |
|
| 186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 187 | - |
|
| 188 | - return $spotter_array; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Gets coordinate & time spotter information based on a particular id |
|
| 193 | - * |
|
| 194 | - * @return Array the spotter information |
|
| 195 | - * |
|
| 196 | - */ |
|
| 197 | - public function getCoordArchiveMarineDataById($id) |
|
| 198 | - { |
|
| 199 | - date_default_timezone_set('UTC'); |
|
| 200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 179 | + try { |
|
| 180 | + $sth = $this->db->prepare($query); |
|
| 181 | + $sth->execute(array(':id' => $id)); |
|
| 182 | + } catch(PDOException $e) { |
|
| 183 | + echo $e->getMessage(); |
|
| 184 | + die; |
|
| 185 | + } |
|
| 186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 187 | + |
|
| 188 | + return $spotter_array; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Gets coordinate & time spotter information based on a particular id |
|
| 193 | + * |
|
| 194 | + * @return Array the spotter information |
|
| 195 | + * |
|
| 196 | + */ |
|
| 197 | + public function getCoordArchiveMarineDataById($id) |
|
| 198 | + { |
|
| 199 | + date_default_timezone_set('UTC'); |
|
| 200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 202 | 202 | |
| 203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 204 | 204 | |
| 205 | - try { |
|
| 206 | - $sth = $this->db->prepare($query); |
|
| 207 | - $sth->execute(array(':id' => $id)); |
|
| 208 | - } catch(PDOException $e) { |
|
| 209 | - echo $e->getMessage(); |
|
| 210 | - die; |
|
| 211 | - } |
|
| 212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 205 | + try { |
|
| 206 | + $sth = $this->db->prepare($query); |
|
| 207 | + $sth->execute(array(':id' => $id)); |
|
| 208 | + } catch(PDOException $e) { |
|
| 209 | + echo $e->getMessage(); |
|
| 210 | + die; |
|
| 211 | + } |
|
| 212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 213 | 213 | |
| 214 | - return $spotter_array; |
|
| 215 | - } |
|
| 214 | + return $spotter_array; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * Gets altitude information based on a particular callsign |
|
| 220 | - * |
|
| 221 | - * @return Array the spotter information |
|
| 222 | - * |
|
| 223 | - */ |
|
| 224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 225 | - { |
|
| 218 | + /** |
|
| 219 | + * Gets altitude information based on a particular callsign |
|
| 220 | + * |
|
| 221 | + * @return Array the spotter information |
|
| 222 | + * |
|
| 223 | + */ |
|
| 224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 225 | + { |
|
| 226 | 226 | |
| 227 | - date_default_timezone_set('UTC'); |
|
| 227 | + date_default_timezone_set('UTC'); |
|
| 228 | 228 | |
| 229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 231 | 231 | |
| 232 | - try { |
|
| 233 | - $sth = $this->db->prepare($query); |
|
| 234 | - $sth->execute(array(':ident' => $ident)); |
|
| 235 | - } catch(PDOException $e) { |
|
| 236 | - echo $e->getMessage(); |
|
| 237 | - die; |
|
| 238 | - } |
|
| 239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 232 | + try { |
|
| 233 | + $sth = $this->db->prepare($query); |
|
| 234 | + $sth->execute(array(':ident' => $ident)); |
|
| 235 | + } catch(PDOException $e) { |
|
| 236 | + echo $e->getMessage(); |
|
| 237 | + die; |
|
| 238 | + } |
|
| 239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 240 | 240 | |
| 241 | - return $spotter_array; |
|
| 242 | - } |
|
| 241 | + return $spotter_array; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * Gets altitude information based on a particular id |
|
| 246 | - * |
|
| 247 | - * @return Array the spotter information |
|
| 248 | - * |
|
| 249 | - */ |
|
| 250 | - public function getAltitudeArchiveMarineDataById($id) |
|
| 251 | - { |
|
| 244 | + /** |
|
| 245 | + * Gets altitude information based on a particular id |
|
| 246 | + * |
|
| 247 | + * @return Array the spotter information |
|
| 248 | + * |
|
| 249 | + */ |
|
| 250 | + public function getAltitudeArchiveMarineDataById($id) |
|
| 251 | + { |
|
| 252 | 252 | |
| 253 | - date_default_timezone_set('UTC'); |
|
| 253 | + date_default_timezone_set('UTC'); |
|
| 254 | 254 | |
| 255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 257 | 257 | |
| 258 | - try { |
|
| 259 | - $sth = $this->db->prepare($query); |
|
| 260 | - $sth->execute(array(':id' => $id)); |
|
| 261 | - } catch(PDOException $e) { |
|
| 262 | - echo $e->getMessage(); |
|
| 263 | - die; |
|
| 264 | - } |
|
| 265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 258 | + try { |
|
| 259 | + $sth = $this->db->prepare($query); |
|
| 260 | + $sth->execute(array(':id' => $id)); |
|
| 261 | + } catch(PDOException $e) { |
|
| 262 | + echo $e->getMessage(); |
|
| 263 | + die; |
|
| 264 | + } |
|
| 265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 266 | 266 | |
| 267 | - return $spotter_array; |
|
| 268 | - } |
|
| 267 | + return $spotter_array; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Gets altitude & speed information based on a particular id |
|
| 272 | - * |
|
| 273 | - * @return Array the spotter information |
|
| 274 | - * |
|
| 275 | - */ |
|
| 276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 277 | - { |
|
| 270 | + /** |
|
| 271 | + * Gets altitude & speed information based on a particular id |
|
| 272 | + * |
|
| 273 | + * @return Array the spotter information |
|
| 274 | + * |
|
| 275 | + */ |
|
| 276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 277 | + { |
|
| 278 | 278 | |
| 279 | - date_default_timezone_set('UTC'); |
|
| 279 | + date_default_timezone_set('UTC'); |
|
| 280 | 280 | |
| 281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 283 | 283 | |
| 284 | - try { |
|
| 285 | - $sth = $this->db->prepare($query); |
|
| 286 | - $sth->execute(array(':id' => $id)); |
|
| 287 | - } catch(PDOException $e) { |
|
| 288 | - echo $e->getMessage(); |
|
| 289 | - die; |
|
| 290 | - } |
|
| 291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 284 | + try { |
|
| 285 | + $sth = $this->db->prepare($query); |
|
| 286 | + $sth->execute(array(':id' => $id)); |
|
| 287 | + } catch(PDOException $e) { |
|
| 288 | + echo $e->getMessage(); |
|
| 289 | + die; |
|
| 290 | + } |
|
| 291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 292 | 292 | |
| 293 | - return $spotter_array; |
|
| 294 | - } |
|
| 293 | + return $spotter_array; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Gets altitude information based on a particular callsign |
|
| 299 | - * |
|
| 300 | - * @return Array the spotter information |
|
| 301 | - * |
|
| 302 | - */ |
|
| 303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 304 | - { |
|
| 297 | + /** |
|
| 298 | + * Gets altitude information based on a particular callsign |
|
| 299 | + * |
|
| 300 | + * @return Array the spotter information |
|
| 301 | + * |
|
| 302 | + */ |
|
| 303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 304 | + { |
|
| 305 | 305 | |
| 306 | - date_default_timezone_set('UTC'); |
|
| 306 | + date_default_timezone_set('UTC'); |
|
| 307 | 307 | |
| 308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 311 | 311 | |
| 312 | - try { |
|
| 313 | - $sth = $this->db->prepare($query); |
|
| 314 | - $sth->execute(array(':ident' => $ident)); |
|
| 315 | - } catch(PDOException $e) { |
|
| 316 | - echo $e->getMessage(); |
|
| 317 | - die; |
|
| 318 | - } |
|
| 319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 312 | + try { |
|
| 313 | + $sth = $this->db->prepare($query); |
|
| 314 | + $sth->execute(array(':ident' => $ident)); |
|
| 315 | + } catch(PDOException $e) { |
|
| 316 | + echo $e->getMessage(); |
|
| 317 | + die; |
|
| 318 | + } |
|
| 319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 320 | 320 | |
| 321 | - return $spotter_array; |
|
| 322 | - } |
|
| 321 | + return $spotter_array; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | 324 | |
| 325 | 325 | |
| 326 | - /** |
|
| 327 | - * Gets all the archive spotter information |
|
| 328 | - * |
|
| 329 | - * @return Array the spotter information |
|
| 330 | - * |
|
| 331 | - */ |
|
| 332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 333 | - { |
|
| 334 | - $Marine = new Marine($this->db); |
|
| 335 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 326 | + /** |
|
| 327 | + * Gets all the archive spotter information |
|
| 328 | + * |
|
| 329 | + * @return Array the spotter information |
|
| 330 | + * |
|
| 331 | + */ |
|
| 332 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 333 | + { |
|
| 334 | + $Marine = new Marine($this->db); |
|
| 335 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 337 | 337 | |
| 338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 338 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 339 | 339 | |
| 340 | - return $spotter_array; |
|
| 341 | - } |
|
| 340 | + return $spotter_array; |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - public function deleteMarineArchiveTrackData() |
|
| 344 | - { |
|
| 343 | + public function deleteMarineArchiveTrackData() |
|
| 344 | + { |
|
| 345 | 345 | global $globalArchiveKeepTrackMonths; |
| 346 | - date_default_timezone_set('UTC'); |
|
| 346 | + date_default_timezone_set('UTC'); |
|
| 347 | 347 | $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 348 | - try { |
|
| 349 | - $sth = $this->db->prepare($query); |
|
| 350 | - $sth->execute(); |
|
| 351 | - } catch(PDOException $e) { |
|
| 352 | - echo $e->getMessage(); |
|
| 353 | - die; |
|
| 354 | - } |
|
| 348 | + try { |
|
| 349 | + $sth = $this->db->prepare($query); |
|
| 350 | + $sth->execute(); |
|
| 351 | + } catch(PDOException $e) { |
|
| 352 | + echo $e->getMessage(); |
|
| 353 | + die; |
|
| 354 | + } |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
| 358 | - * Gets Minimal Live Marine data |
|
| 359 | - * |
|
| 360 | - * @return Array the spotter information |
|
| 361 | - * |
|
| 362 | - */ |
|
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 364 | - { |
|
| 365 | - global $globalDBdriver, $globalLiveInterval; |
|
| 366 | - date_default_timezone_set('UTC'); |
|
| 367 | - |
|
| 368 | - $filter_query = ''; |
|
| 369 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 371 | - } |
|
| 372 | - // Use spotter_output also ? |
|
| 373 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 375 | - } |
|
| 376 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 377 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 378 | - } |
|
| 379 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 381 | - } |
|
| 358 | + * Gets Minimal Live Marine data |
|
| 359 | + * |
|
| 360 | + * @return Array the spotter information |
|
| 361 | + * |
|
| 362 | + */ |
|
| 363 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 364 | + { |
|
| 365 | + global $globalDBdriver, $globalLiveInterval; |
|
| 366 | + date_default_timezone_set('UTC'); |
|
| 367 | + |
|
| 368 | + $filter_query = ''; |
|
| 369 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 370 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 371 | + } |
|
| 372 | + // Use spotter_output also ? |
|
| 373 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 375 | + } |
|
| 376 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 377 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 378 | + } |
|
| 379 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 384 | - if ($globalDBdriver == 'mysql') { |
|
| 385 | - /* |
|
| 383 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 384 | + if ($globalDBdriver == 'mysql') { |
|
| 385 | + /* |
|
| 386 | 386 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 387 | 387 | FROM marine_archive |
| 388 | 388 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -401,56 +401,56 @@ discard block |
||
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
| 404 | - } else { |
|
| 405 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 404 | + } else { |
|
| 405 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 407 | 407 | FROM marine_archive |
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
| 410 | 410 | '.$filter_query.' ORDER BY fammarine_id'; |
| 411 | - } |
|
| 412 | - //echo $query; |
|
| 413 | - try { |
|
| 414 | - $sth = $this->db->prepare($query); |
|
| 415 | - $sth->execute(); |
|
| 416 | - } catch(PDOException $e) { |
|
| 417 | - echo $e->getMessage(); |
|
| 418 | - die; |
|
| 419 | - } |
|
| 420 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 411 | + } |
|
| 412 | + //echo $query; |
|
| 413 | + try { |
|
| 414 | + $sth = $this->db->prepare($query); |
|
| 415 | + $sth->execute(); |
|
| 416 | + } catch(PDOException $e) { |
|
| 417 | + echo $e->getMessage(); |
|
| 418 | + die; |
|
| 419 | + } |
|
| 420 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 421 | 421 | |
| 422 | - return $spotter_array; |
|
| 423 | - } |
|
| 422 | + return $spotter_array; |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | - * Gets Minimal Live Marine data |
|
| 427 | - * |
|
| 428 | - * @return Array the spotter information |
|
| 429 | - * |
|
| 430 | - */ |
|
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 432 | - { |
|
| 433 | - global $globalDBdriver, $globalLiveInterval; |
|
| 434 | - date_default_timezone_set('UTC'); |
|
| 435 | - |
|
| 436 | - $filter_query = ''; |
|
| 437 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 439 | - } |
|
| 440 | - // Should use spotter_output also ? |
|
| 441 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 443 | - } |
|
| 444 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 445 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 446 | - } |
|
| 447 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 449 | - } |
|
| 426 | + * Gets Minimal Live Marine data |
|
| 427 | + * |
|
| 428 | + * @return Array the spotter information |
|
| 429 | + * |
|
| 430 | + */ |
|
| 431 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 432 | + { |
|
| 433 | + global $globalDBdriver, $globalLiveInterval; |
|
| 434 | + date_default_timezone_set('UTC'); |
|
| 435 | + |
|
| 436 | + $filter_query = ''; |
|
| 437 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 438 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 439 | + } |
|
| 440 | + // Should use spotter_output also ? |
|
| 441 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 443 | + } |
|
| 444 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 445 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 446 | + } |
|
| 447 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 452 | - if ($globalDBdriver == 'mysql') { |
|
| 453 | - /* |
|
| 451 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 452 | + if ($globalDBdriver == 'mysql') { |
|
| 453 | + /* |
|
| 454 | 454 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 455 | 455 | FROM marine_archive |
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -461,95 +461,95 @@ discard block |
||
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 462 | 462 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 463 | 463 | |
| 464 | - } else { |
|
| 465 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 466 | - /* |
|
| 464 | + } else { |
|
| 465 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 466 | + /* |
|
| 467 | 467 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
| 468 | 468 | FROM marine_archive_output |
| 469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 472 | 472 | */ |
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 474 | 474 | FROM marine_archive_output |
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 477 | 477 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 478 | 478 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 479 | 479 | |
| 480 | - } |
|
| 481 | - //echo $query; |
|
| 482 | - try { |
|
| 483 | - $sth = $this->db->prepare($query); |
|
| 484 | - $sth->execute(); |
|
| 485 | - } catch(PDOException $e) { |
|
| 486 | - echo $e->getMessage(); |
|
| 487 | - die; |
|
| 488 | - } |
|
| 489 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 480 | + } |
|
| 481 | + //echo $query; |
|
| 482 | + try { |
|
| 483 | + $sth = $this->db->prepare($query); |
|
| 484 | + $sth->execute(); |
|
| 485 | + } catch(PDOException $e) { |
|
| 486 | + echo $e->getMessage(); |
|
| 487 | + die; |
|
| 488 | + } |
|
| 489 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 490 | 490 | |
| 491 | - return $spotter_array; |
|
| 492 | - } |
|
| 491 | + return $spotter_array; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | - * Gets count Live Marine data |
|
| 496 | - * |
|
| 497 | - * @return Array the spotter information |
|
| 498 | - * |
|
| 499 | - */ |
|
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 501 | - { |
|
| 502 | - global $globalDBdriver, $globalLiveInterval; |
|
| 503 | - date_default_timezone_set('UTC'); |
|
| 504 | - |
|
| 505 | - $filter_query = ''; |
|
| 506 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 508 | - } |
|
| 509 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 511 | - } |
|
| 512 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 513 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 514 | - } |
|
| 515 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 517 | - } |
|
| 495 | + * Gets count Live Marine data |
|
| 496 | + * |
|
| 497 | + * @return Array the spotter information |
|
| 498 | + * |
|
| 499 | + */ |
|
| 500 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 501 | + { |
|
| 502 | + global $globalDBdriver, $globalLiveInterval; |
|
| 503 | + date_default_timezone_set('UTC'); |
|
| 518 | 504 | |
| 519 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 520 | - if ($globalDBdriver == 'mysql') { |
|
| 505 | + $filter_query = ''; |
|
| 506 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 507 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 508 | + } |
|
| 509 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 511 | + } |
|
| 512 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 513 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 514 | + } |
|
| 515 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 520 | + if ($globalDBdriver == 'mysql') { |
|
| 521 | 521 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
| 522 | 522 | FROM marine_archive l |
| 523 | 523 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 524 | - } else { |
|
| 524 | + } else { |
|
| 525 | 525 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 526 | - } |
|
| 527 | - //echo $query; |
|
| 528 | - try { |
|
| 529 | - $sth = $this->db->prepare($query); |
|
| 530 | - $sth->execute(); |
|
| 531 | - } catch(PDOException $e) { |
|
| 532 | - echo $e->getMessage(); |
|
| 533 | - die; |
|
| 534 | - } |
|
| 526 | + } |
|
| 527 | + //echo $query; |
|
| 528 | + try { |
|
| 529 | + $sth = $this->db->prepare($query); |
|
| 530 | + $sth->execute(); |
|
| 531 | + } catch(PDOException $e) { |
|
| 532 | + echo $e->getMessage(); |
|
| 533 | + die; |
|
| 534 | + } |
|
| 535 | 535 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 536 | 536 | $sth->closeCursor(); |
| 537 | - return $result['nb']; |
|
| 537 | + return $result['nb']; |
|
| 538 | 538 | |
| 539 | - } |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | 541 | |
| 542 | 542 | |
| 543 | 543 | // marine_archive_output |
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * Gets all the spotter information |
|
| 547 | - * |
|
| 548 | - * @return Array the spotter information |
|
| 549 | - * |
|
| 550 | - */ |
|
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 552 | - { |
|
| 545 | + /** |
|
| 546 | + * Gets all the spotter information |
|
| 547 | + * |
|
| 548 | + * @return Array the spotter information |
|
| 549 | + * |
|
| 550 | + */ |
|
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 552 | + { |
|
| 553 | 553 | global $globalTimezone, $globalDBdriver; |
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 555 | 555 | $Translation = new Translation($this->db); |
@@ -563,159 +563,159 @@ discard block |
||
| 563 | 563 | $filter_query = $this->getFilter($filters); |
| 564 | 564 | if ($q != "") |
| 565 | 565 | { |
| 566 | - if (!is_string($q)) |
|
| 567 | - { |
|
| 566 | + if (!is_string($q)) |
|
| 567 | + { |
|
| 568 | 568 | return false; |
| 569 | - } else { |
|
| 569 | + } else { |
|
| 570 | 570 | |
| 571 | 571 | $q_array = explode(" ", $q); |
| 572 | 572 | |
| 573 | 573 | foreach ($q_array as $q_item){ |
| 574 | - $additional_query .= " AND ("; |
|
| 575 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 576 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 577 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 578 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 579 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 580 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 581 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 582 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 583 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 584 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 585 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 586 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 587 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 588 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 589 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 590 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 591 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 592 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 593 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 594 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 595 | - $translate = $Translation->ident2icao($q_item); |
|
| 596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 597 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 598 | - $additional_query .= ")"; |
|
| 574 | + $additional_query .= " AND ("; |
|
| 575 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 576 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 577 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 578 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 579 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 580 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 581 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 582 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 583 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 584 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 585 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 586 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 587 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 588 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 589 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 590 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 591 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 592 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 593 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 594 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 595 | + $translate = $Translation->ident2icao($q_item); |
|
| 596 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 597 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 598 | + $additional_query .= ")"; |
|
| 599 | + } |
|
| 599 | 600 | } |
| 600 | - } |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | if ($registration != "") |
| 604 | 604 | { |
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 606 | - if (!is_string($registration)) |
|
| 607 | - { |
|
| 605 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 606 | + if (!is_string($registration)) |
|
| 607 | + { |
|
| 608 | 608 | return false; |
| 609 | - } else { |
|
| 609 | + } else { |
|
| 610 | 610 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
| 611 | - } |
|
| 611 | + } |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "") |
| 615 | 615 | { |
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 617 | - if (!is_string($aircraft_icao)) |
|
| 618 | - { |
|
| 616 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 617 | + if (!is_string($aircraft_icao)) |
|
| 618 | + { |
|
| 619 | 619 | return false; |
| 620 | - } else { |
|
| 620 | + } else { |
|
| 621 | 621 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 622 | - } |
|
| 622 | + } |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "") |
| 626 | 626 | { |
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 628 | - if (!is_string($aircraft_manufacturer)) |
|
| 629 | - { |
|
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 628 | + if (!is_string($aircraft_manufacturer)) |
|
| 629 | + { |
|
| 630 | 630 | return false; |
| 631 | - } else { |
|
| 631 | + } else { |
|
| 632 | 632 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 633 | - } |
|
| 633 | + } |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | if ($highlights == "true") |
| 637 | 637 | { |
| 638 | - if (!is_string($highlights)) |
|
| 639 | - { |
|
| 638 | + if (!is_string($highlights)) |
|
| 639 | + { |
|
| 640 | 640 | return false; |
| 641 | - } else { |
|
| 641 | + } else { |
|
| 642 | 642 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
| 643 | - } |
|
| 643 | + } |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "") |
| 647 | 647 | { |
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 649 | - if (!is_string($airline_icao)) |
|
| 650 | - { |
|
| 648 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 649 | + if (!is_string($airline_icao)) |
|
| 650 | + { |
|
| 651 | 651 | return false; |
| 652 | - } else { |
|
| 652 | + } else { |
|
| 653 | 653 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
| 654 | - } |
|
| 654 | + } |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "") |
| 658 | 658 | { |
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 660 | - if (!is_string($airline_country)) |
|
| 661 | - { |
|
| 659 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 660 | + if (!is_string($airline_country)) |
|
| 661 | + { |
|
| 662 | 662 | return false; |
| 663 | - } else { |
|
| 663 | + } else { |
|
| 664 | 664 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
| 665 | - } |
|
| 665 | + } |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "") |
| 669 | 669 | { |
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 671 | - if (!is_string($airline_type)) |
|
| 672 | - { |
|
| 670 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 671 | + if (!is_string($airline_type)) |
|
| 672 | + { |
|
| 673 | 673 | return false; |
| 674 | - } else { |
|
| 674 | + } else { |
|
| 675 | 675 | if ($airline_type == "passenger") |
| 676 | 676 | { |
| 677 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 677 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 678 | 678 | } |
| 679 | 679 | if ($airline_type == "cargo") |
| 680 | 680 | { |
| 681 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 681 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 682 | 682 | } |
| 683 | 683 | if ($airline_type == "military") |
| 684 | 684 | { |
| 685 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 685 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 686 | + } |
|
| 686 | 687 | } |
| 687 | - } |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | if ($airport != "") |
| 691 | 691 | { |
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 693 | - if (!is_string($airport)) |
|
| 694 | - { |
|
| 692 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 693 | + if (!is_string($airport)) |
|
| 694 | + { |
|
| 695 | 695 | return false; |
| 696 | - } else { |
|
| 696 | + } else { |
|
| 697 | 697 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 698 | - } |
|
| 698 | + } |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "") |
| 702 | 702 | { |
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 704 | - if (!is_string($airport_country)) |
|
| 705 | - { |
|
| 703 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 704 | + if (!is_string($airport_country)) |
|
| 705 | + { |
|
| 706 | 706 | return false; |
| 707 | - } else { |
|
| 707 | + } else { |
|
| 708 | 708 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 709 | - } |
|
| 709 | + } |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | if ($callsign != "") |
| 713 | 713 | { |
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 715 | - if (!is_string($callsign)) |
|
| 716 | - { |
|
| 714 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 715 | + if (!is_string($callsign)) |
|
| 716 | + { |
|
| 717 | 717 | return false; |
| 718 | - } else { |
|
| 718 | + } else { |
|
| 719 | 719 | $translate = $Translation->ident2icao($callsign); |
| 720 | 720 | if ($translate != $callsign) { |
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -723,99 +723,99 @@ discard block |
||
| 723 | 723 | } else { |
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 725 | 725 | } |
| 726 | - } |
|
| 726 | + } |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | if ($owner != "") |
| 730 | 730 | { |
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 732 | - if (!is_string($owner)) |
|
| 733 | - { |
|
| 731 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 732 | + if (!is_string($owner)) |
|
| 733 | + { |
|
| 734 | 734 | return false; |
| 735 | - } else { |
|
| 735 | + } else { |
|
| 736 | 736 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
| 737 | - } |
|
| 737 | + } |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "") |
| 741 | 741 | { |
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 743 | - if (!is_string($pilot_name)) |
|
| 744 | - { |
|
| 742 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 743 | + if (!is_string($pilot_name)) |
|
| 744 | + { |
|
| 745 | 745 | return false; |
| 746 | - } else { |
|
| 746 | + } else { |
|
| 747 | 747 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
| 748 | - } |
|
| 748 | + } |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "") |
| 752 | 752 | { |
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 754 | - if (!is_string($pilot_id)) |
|
| 755 | - { |
|
| 753 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 754 | + if (!is_string($pilot_id)) |
|
| 755 | + { |
|
| 756 | 756 | return false; |
| 757 | - } else { |
|
| 757 | + } else { |
|
| 758 | 758 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
| 759 | - } |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "") |
| 763 | 763 | { |
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 765 | - if (!is_string($departure_airport_route)) |
|
| 766 | - { |
|
| 764 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 765 | + if (!is_string($departure_airport_route)) |
|
| 766 | + { |
|
| 767 | 767 | return false; |
| 768 | - } else { |
|
| 768 | + } else { |
|
| 769 | 769 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 770 | - } |
|
| 770 | + } |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "") |
| 774 | 774 | { |
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 776 | - if (!is_string($arrival_airport_route)) |
|
| 777 | - { |
|
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 776 | + if (!is_string($arrival_airport_route)) |
|
| 777 | + { |
|
| 778 | 778 | return false; |
| 779 | - } else { |
|
| 779 | + } else { |
|
| 780 | 780 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 781 | - } |
|
| 781 | + } |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | if ($altitude != "") |
| 785 | 785 | { |
| 786 | - $altitude_array = explode(",", $altitude); |
|
| 786 | + $altitude_array = explode(",", $altitude); |
|
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 788 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 790 | 790 | |
| 791 | 791 | |
| 792 | - if ($altitude_array[1] != "") |
|
| 793 | - { |
|
| 792 | + if ($altitude_array[1] != "") |
|
| 793 | + { |
|
| 794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 795 | 795 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 796 | 796 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 797 | - } else { |
|
| 797 | + } else { |
|
| 798 | 798 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 799 | 799 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 800 | - } |
|
| 800 | + } |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | if ($date_posted != "") |
| 804 | 804 | { |
| 805 | - $date_array = explode(",", $date_posted); |
|
| 805 | + $date_array = explode(",", $date_posted); |
|
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 807 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 808 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 809 | 809 | |
| 810 | - if ($globalTimezone != '') { |
|
| 810 | + if ($globalTimezone != '') { |
|
| 811 | 811 | date_default_timezone_set($globalTimezone); |
| 812 | 812 | $datetime = new DateTime(); |
| 813 | 813 | $offset = $datetime->format('P'); |
| 814 | - } else $offset = '+00:00'; |
|
| 814 | + } else $offset = '+00:00'; |
|
| 815 | 815 | |
| 816 | 816 | |
| 817 | - if ($date_array[1] != "") |
|
| 818 | - { |
|
| 817 | + if ($date_array[1] != "") |
|
| 818 | + { |
|
| 819 | 819 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 820 | 820 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 821 | 821 | if ($globalDBdriver == 'mysql') { |
@@ -823,28 +823,28 @@ discard block |
||
| 823 | 823 | } else { |
| 824 | 824 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 825 | 825 | } |
| 826 | - } else { |
|
| 826 | + } else { |
|
| 827 | 827 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 828 | - if ($globalDBdriver == 'mysql') { |
|
| 828 | + if ($globalDBdriver == 'mysql') { |
|
| 829 | 829 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 830 | 830 | } else { |
| 831 | 831 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 832 | 832 | } |
| 833 | - } |
|
| 833 | + } |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | if ($limit != "") |
| 837 | 837 | { |
| 838 | - $limit_array = explode(",", $limit); |
|
| 838 | + $limit_array = explode(",", $limit); |
|
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 840 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 842 | 842 | |
| 843 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 844 | - { |
|
| 843 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 844 | + { |
|
| 845 | 845 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 846 | 846 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 847 | - } |
|
| 847 | + } |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | |
@@ -875,33 +875,33 @@ discard block |
||
| 875 | 875 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
| 876 | 876 | |
| 877 | 877 | return $spotter_array; |
| 878 | - } |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | - public function deleteMarineArchiveData() |
|
| 881 | - { |
|
| 880 | + public function deleteMarineArchiveData() |
|
| 881 | + { |
|
| 882 | 882 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 883 | - date_default_timezone_set('UTC'); |
|
| 884 | - if ($globalDBdriver == 'mysql') { |
|
| 883 | + date_default_timezone_set('UTC'); |
|
| 884 | + if ($globalDBdriver == 'mysql') { |
|
| 885 | 885 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 886 | 886 | } else { |
| 887 | 887 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 888 | 888 | } |
| 889 | - try { |
|
| 890 | - $sth = $this->db->prepare($query); |
|
| 891 | - $sth->execute(); |
|
| 892 | - } catch(PDOException $e) { |
|
| 893 | - return "error"; |
|
| 894 | - } |
|
| 889 | + try { |
|
| 890 | + $sth = $this->db->prepare($query); |
|
| 891 | + $sth->execute(); |
|
| 892 | + } catch(PDOException $e) { |
|
| 893 | + return "error"; |
|
| 894 | + } |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - /** |
|
| 898 | - * Gets all the spotter information based on the callsign |
|
| 899 | - * |
|
| 900 | - * @return Array the spotter information |
|
| 901 | - * |
|
| 902 | - */ |
|
| 903 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 904 | - { |
|
| 897 | + /** |
|
| 898 | + * Gets all the spotter information based on the callsign |
|
| 899 | + * |
|
| 900 | + * @return Array the spotter information |
|
| 901 | + * |
|
| 902 | + */ |
|
| 903 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 904 | + { |
|
| 905 | 905 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 906 | 906 | |
| 907 | 907 | date_default_timezone_set('UTC'); |
@@ -913,35 +913,35 @@ discard block |
||
| 913 | 913 | |
| 914 | 914 | if ($ident != "") |
| 915 | 915 | { |
| 916 | - if (!is_string($ident)) |
|
| 917 | - { |
|
| 916 | + if (!is_string($ident)) |
|
| 917 | + { |
|
| 918 | 918 | return false; |
| 919 | - } else { |
|
| 919 | + } else { |
|
| 920 | 920 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
| 921 | 921 | $query_values = array(':ident' => $ident); |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | if ($limit != "") |
| 926 | 926 | { |
| 927 | - $limit_array = explode(",", $limit); |
|
| 927 | + $limit_array = explode(",", $limit); |
|
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 929 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 931 | 931 | |
| 932 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 933 | - { |
|
| 932 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 933 | + { |
|
| 934 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 935 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 936 | - } |
|
| 936 | + } |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | if ($sort != "") |
| 940 | 940 | { |
| 941 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 942 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 941 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 942 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 943 | 943 | } else { |
| 944 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 944 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -949,17 +949,17 @@ discard block |
||
| 949 | 949 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 950 | 950 | |
| 951 | 951 | return $spotter_array; |
| 952 | - } |
|
| 952 | + } |
|
| 953 | 953 | |
| 954 | 954 | |
| 955 | - /** |
|
| 956 | - * Gets all the spotter information based on the owner |
|
| 957 | - * |
|
| 958 | - * @return Array the spotter information |
|
| 959 | - * |
|
| 960 | - */ |
|
| 961 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 962 | - { |
|
| 955 | + /** |
|
| 956 | + * Gets all the spotter information based on the owner |
|
| 957 | + * |
|
| 958 | + * @return Array the spotter information |
|
| 959 | + * |
|
| 960 | + */ |
|
| 961 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 962 | + { |
|
| 963 | 963 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 964 | 964 | |
| 965 | 965 | date_default_timezone_set('UTC'); |
@@ -972,35 +972,35 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | if ($owner != "") |
| 974 | 974 | { |
| 975 | - if (!is_string($owner)) |
|
| 976 | - { |
|
| 975 | + if (!is_string($owner)) |
|
| 976 | + { |
|
| 977 | 977 | return false; |
| 978 | - } else { |
|
| 978 | + } else { |
|
| 979 | 979 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
| 980 | 980 | $query_values = array(':owner' => $owner); |
| 981 | - } |
|
| 981 | + } |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | if ($limit != "") |
| 985 | 985 | { |
| 986 | - $limit_array = explode(",", $limit); |
|
| 986 | + $limit_array = explode(",", $limit); |
|
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 992 | - { |
|
| 991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 992 | + { |
|
| 993 | 993 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 994 | 994 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 995 | - } |
|
| 995 | + } |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | if ($sort != "") |
| 999 | 999 | { |
| 1000 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1001 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1000 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1001 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1002 | 1002 | } else { |
| 1003 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1003 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1008,16 +1008,16 @@ discard block |
||
| 1008 | 1008 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1009 | 1009 | |
| 1010 | 1010 | return $spotter_array; |
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - /** |
|
| 1014 | - * Gets all the spotter information based on the pilot |
|
| 1015 | - * |
|
| 1016 | - * @return Array the spotter information |
|
| 1017 | - * |
|
| 1018 | - */ |
|
| 1019 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1020 | - { |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * Gets all the spotter information based on the pilot |
|
| 1015 | + * |
|
| 1016 | + * @return Array the spotter information |
|
| 1017 | + * |
|
| 1018 | + */ |
|
| 1019 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1020 | + { |
|
| 1021 | 1021 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1022 | 1022 | |
| 1023 | 1023 | date_default_timezone_set('UTC'); |
@@ -1036,24 +1036,24 @@ discard block |
||
| 1036 | 1036 | |
| 1037 | 1037 | if ($limit != "") |
| 1038 | 1038 | { |
| 1039 | - $limit_array = explode(",", $limit); |
|
| 1039 | + $limit_array = explode(",", $limit); |
|
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1041 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1043 | 1043 | |
| 1044 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1045 | - { |
|
| 1044 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1045 | + { |
|
| 1046 | 1046 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1047 | 1047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1048 | - } |
|
| 1048 | + } |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | if ($sort != "") |
| 1052 | 1052 | { |
| 1053 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1054 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1053 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1054 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1055 | 1055 | } else { |
| 1056 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1056 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1061,16 +1061,16 @@ discard block |
||
| 1061 | 1061 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1062 | 1062 | |
| 1063 | 1063 | return $spotter_array; |
| 1064 | - } |
|
| 1065 | - |
|
| 1066 | - /** |
|
| 1067 | - * Gets all number of flight over countries |
|
| 1068 | - * |
|
| 1069 | - * @return Array the airline country list |
|
| 1070 | - * |
|
| 1071 | - */ |
|
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1073 | - { |
|
| 1064 | + } |
|
| 1065 | + |
|
| 1066 | + /** |
|
| 1067 | + * Gets all number of flight over countries |
|
| 1068 | + * |
|
| 1069 | + * @return Array the airline country list |
|
| 1070 | + * |
|
| 1071 | + */ |
|
| 1072 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1073 | + { |
|
| 1074 | 1074 | global $globalDBdriver; |
| 1075 | 1075 | /* |
| 1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1080,14 +1080,14 @@ discard block |
||
| 1080 | 1080 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1081 | 1081 | FROM countries c, marine_archive s |
| 1082 | 1082 | WHERE c.iso2 = s.over_country "; |
| 1083 | - if ($olderthanmonths > 0) { |
|
| 1084 | - if ($globalDBdriver == 'mysql') { |
|
| 1083 | + if ($olderthanmonths > 0) { |
|
| 1084 | + if ($globalDBdriver == 'mysql') { |
|
| 1085 | 1085 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1086 | 1086 | } else { |
| 1087 | 1087 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1090 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1091 | 1091 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1092 | 1092 | if ($limit) $query .= " LIMIT 0,10"; |
| 1093 | 1093 | |
@@ -1100,23 +1100,23 @@ discard block |
||
| 1100 | 1100 | |
| 1101 | 1101 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1102 | 1102 | { |
| 1103 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1104 | - $temp_array['flight_country'] = $row['name']; |
|
| 1105 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1106 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1107 | - $flight_array[] = $temp_array; |
|
| 1103 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1104 | + $temp_array['flight_country'] = $row['name']; |
|
| 1105 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1106 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1107 | + $flight_array[] = $temp_array; |
|
| 1108 | 1108 | } |
| 1109 | 1109 | return $flight_array; |
| 1110 | - } |
|
| 1111 | - |
|
| 1112 | - /** |
|
| 1113 | - * Gets all number of flight over countries |
|
| 1114 | - * |
|
| 1115 | - * @return Array the airline country list |
|
| 1116 | - * |
|
| 1117 | - */ |
|
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | - { |
|
| 1110 | + } |
|
| 1111 | + |
|
| 1112 | + /** |
|
| 1113 | + * Gets all number of flight over countries |
|
| 1114 | + * |
|
| 1115 | + * @return Array the airline country list |
|
| 1116 | + * |
|
| 1117 | + */ |
|
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | + { |
|
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
| 1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
| 1126 | 1126 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1127 | 1127 | FROM countries c, marine_archive s, spotter_output o |
| 1128 | 1128 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
| 1129 | - if ($olderthanmonths > 0) { |
|
| 1130 | - if ($globalDBdriver == 'mysql') { |
|
| 1129 | + if ($olderthanmonths > 0) { |
|
| 1130 | + if ($globalDBdriver == 'mysql') { |
|
| 1131 | 1131 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1132 | 1132 | } else { |
| 1133 | 1133 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1136 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1137 | 1137 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
| 1139 | 1139 | |
@@ -1146,24 +1146,24 @@ discard block |
||
| 1146 | 1146 | |
| 1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1148 | 1148 | { |
| 1149 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1150 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1151 | - $temp_array['flight_country'] = $row['name']; |
|
| 1152 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1153 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1154 | - $flight_array[] = $temp_array; |
|
| 1149 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1150 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1151 | + $temp_array['flight_country'] = $row['name']; |
|
| 1152 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1153 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1154 | + $flight_array[] = $temp_array; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | return $flight_array; |
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - /** |
|
| 1160 | - * Gets last spotter information based on a particular callsign |
|
| 1161 | - * |
|
| 1162 | - * @return Array the spotter information |
|
| 1163 | - * |
|
| 1164 | - */ |
|
| 1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1166 | - { |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + /** |
|
| 1160 | + * Gets last spotter information based on a particular callsign |
|
| 1161 | + * |
|
| 1162 | + * @return Array the spotter information |
|
| 1163 | + * |
|
| 1164 | + */ |
|
| 1165 | + public function getDateArchiveMarineDataById($id,$date) |
|
| 1166 | + { |
|
| 1167 | 1167 | $Marine = new Marine($this->db); |
| 1168 | 1168 | date_default_timezone_set('UTC'); |
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1171,16 +1171,16 @@ discard block |
||
| 1171 | 1171 | $date = date('c',$date); |
| 1172 | 1172 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1173 | 1173 | return $spotter_array; |
| 1174 | - } |
|
| 1175 | - |
|
| 1176 | - /** |
|
| 1177 | - * Gets all the spotter information based on a particular callsign |
|
| 1178 | - * |
|
| 1179 | - * @return Array the spotter information |
|
| 1180 | - * |
|
| 1181 | - */ |
|
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1183 | - { |
|
| 1174 | + } |
|
| 1175 | + |
|
| 1176 | + /** |
|
| 1177 | + * Gets all the spotter information based on a particular callsign |
|
| 1178 | + * |
|
| 1179 | + * @return Array the spotter information |
|
| 1180 | + * |
|
| 1181 | + */ |
|
| 1182 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1183 | + { |
|
| 1184 | 1184 | $Marine = new Marine($this->db); |
| 1185 | 1185 | date_default_timezone_set('UTC'); |
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1188,16 +1188,16 @@ discard block |
||
| 1188 | 1188 | $date = date('c',$date); |
| 1189 | 1189 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1190 | 1190 | return $spotter_array; |
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - /** |
|
| 1194 | - * Gets all the spotter information based on the airport |
|
| 1195 | - * |
|
| 1196 | - * @return Array the spotter information |
|
| 1197 | - * |
|
| 1198 | - */ |
|
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1200 | - { |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + /** |
|
| 1194 | + * Gets all the spotter information based on the airport |
|
| 1195 | + * |
|
| 1196 | + * @return Array the spotter information |
|
| 1197 | + * |
|
| 1198 | + */ |
|
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1200 | + { |
|
| 1201 | 1201 | global $global_query; |
| 1202 | 1202 | $Marine = new Marine($this->db); |
| 1203 | 1203 | date_default_timezone_set('UTC'); |
@@ -1208,35 +1208,35 @@ discard block |
||
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "") |
| 1210 | 1210 | { |
| 1211 | - if (!is_string($airport)) |
|
| 1212 | - { |
|
| 1211 | + if (!is_string($airport)) |
|
| 1212 | + { |
|
| 1213 | 1213 | return false; |
| 1214 | - } else { |
|
| 1214 | + } else { |
|
| 1215 | 1215 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
| 1216 | 1216 | $query_values = array(':airport' => $airport); |
| 1217 | - } |
|
| 1217 | + } |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | if ($limit != "") |
| 1221 | 1221 | { |
| 1222 | - $limit_array = explode(",", $limit); |
|
| 1222 | + $limit_array = explode(",", $limit); |
|
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1224 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1226 | 1226 | |
| 1227 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1228 | - { |
|
| 1227 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1228 | + { |
|
| 1229 | 1229 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1230 | 1230 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1231 | - } |
|
| 1231 | + } |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | if ($sort != "") |
| 1235 | 1235 | { |
| 1236 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1237 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1236 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1237 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1238 | 1238 | } else { |
| 1239 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1239 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1244,6 +1244,6 @@ discard block |
||
| 1244 | 1244 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1245 | 1245 | |
| 1246 | 1246 | return $spotter_array; |
| 1247 | - } |
|
| 1247 | + } |
|
| 1248 | 1248 | } |
| 1249 | 1249 | ?> |
| 1250 | 1250 | \ No newline at end of file |
@@ -14,33 +14,33 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
| 23 | 23 | } else { |
| 24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if (isset($filter[0]['source'])) { |
| 28 | - $filters = array_merge($filters,$filter); |
|
| 28 | + $filters = array_merge($filters, $filter); |
|
| 29 | 29 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | - foreach($filters as $flt) { |
|
| 33 | + foreach ($filters as $flt) { |
|
| 34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 35 | 35 | if (isset($flt['source'])) { |
| 36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,42 +68,42 @@ discard block |
||
| 68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 75 | 75 | } |
| 76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 78 | 78 | if ($filter_query_where != '') { |
| 79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 80 | 80 | } |
| 81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
| 82 | 82 | return $filter_query; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // marine_archive |
| 86 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
| 86 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 88 | 88 | if ($over_country == '') { |
| 89 | 89 | $Marine = new Marine($this->db); |
| 90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 92 | 92 | else $country = ''; |
| 93 | 93 | } else $country = $over_country; |
| 94 | 94 | |
| 95 | 95 | //$country = $over_country; |
| 96 | 96 | // Route is not added in marine_archive |
| 97 | - $query = 'INSERT INTO marine_archive (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) |
|
| 97 | + $query = 'INSERT INTO marine_archive (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) |
|
| 98 | 98 | 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)'; |
| 99 | 99 | |
| 100 | - $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); |
|
| 100 | + $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); |
|
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | 103 | $sth = $this->db->prepare($query); |
| 104 | 104 | $sth->execute($query_values); |
| 105 | 105 | $sth->closeCursor(); |
| 106 | - } catch(PDOException $e) { |
|
| 106 | + } catch (PDOException $e) { |
|
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
| 109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 127 | 127 | |
| 128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 128 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 129 | 129 | |
| 130 | 130 | return $spotter_array; |
| 131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 148 | 148 | |
| 149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 150 | 150 | /* |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 159 | 159 | */ |
| 160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 161 | 161 | |
| 162 | 162 | return $spotter_array; |
| 163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | date_default_timezone_set('UTC'); |
| 174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 176 | 176 | |
| 177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 178 | 178 | |
| 179 | 179 | try { |
| 180 | 180 | $sth = $this->db->prepare($query); |
| 181 | 181 | $sth->execute(array(':id' => $id)); |
| 182 | - } catch(PDOException $e) { |
|
| 182 | + } catch (PDOException $e) { |
|
| 183 | 183 | echo $e->getMessage(); |
| 184 | 184 | die; |
| 185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | date_default_timezone_set('UTC'); |
| 200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 202 | 202 | |
| 203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 204 | 204 | |
| 205 | 205 | try { |
| 206 | 206 | $sth = $this->db->prepare($query); |
| 207 | 207 | $sth->execute(array(':id' => $id)); |
| 208 | - } catch(PDOException $e) { |
|
| 208 | + } catch (PDOException $e) { |
|
| 209 | 209 | echo $e->getMessage(); |
| 210 | 210 | die; |
| 211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | date_default_timezone_set('UTC'); |
| 228 | 228 | |
| 229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 231 | 231 | |
| 232 | 232 | try { |
| 233 | 233 | $sth = $this->db->prepare($query); |
| 234 | 234 | $sth->execute(array(':ident' => $ident)); |
| 235 | - } catch(PDOException $e) { |
|
| 235 | + } catch (PDOException $e) { |
|
| 236 | 236 | echo $e->getMessage(); |
| 237 | 237 | die; |
| 238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | date_default_timezone_set('UTC'); |
| 254 | 254 | |
| 255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 257 | 257 | |
| 258 | 258 | try { |
| 259 | 259 | $sth = $this->db->prepare($query); |
| 260 | 260 | $sth->execute(array(':id' => $id)); |
| 261 | - } catch(PDOException $e) { |
|
| 261 | + } catch (PDOException $e) { |
|
| 262 | 262 | echo $e->getMessage(); |
| 263 | 263 | die; |
| 264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | date_default_timezone_set('UTC'); |
| 280 | 280 | |
| 281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 283 | 283 | |
| 284 | 284 | try { |
| 285 | 285 | $sth = $this->db->prepare($query); |
| 286 | 286 | $sth->execute(array(':id' => $id)); |
| 287 | - } catch(PDOException $e) { |
|
| 287 | + } catch (PDOException $e) { |
|
| 288 | 288 | echo $e->getMessage(); |
| 289 | 289 | die; |
| 290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | date_default_timezone_set('UTC'); |
| 307 | 307 | |
| 308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 311 | 311 | |
| 312 | 312 | try { |
| 313 | 313 | $sth = $this->db->prepare($query); |
| 314 | 314 | $sth->execute(array(':ident' => $ident)); |
| 315 | - } catch(PDOException $e) { |
|
| 315 | + } catch (PDOException $e) { |
|
| 316 | 316 | echo $e->getMessage(); |
| 317 | 317 | die; |
| 318 | 318 | } |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | * @return Array the spotter information |
| 330 | 330 | * |
| 331 | 331 | */ |
| 332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 333 | 333 | { |
| 334 | 334 | $Marine = new Marine($this->db); |
| 335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 337 | 337 | |
| 338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 338 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 339 | 339 | |
| 340 | 340 | return $spotter_array; |
| 341 | 341 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | try { |
| 349 | 349 | $sth = $this->db->prepare($query); |
| 350 | 350 | $sth->execute(); |
| 351 | - } catch(PDOException $e) { |
|
| 351 | + } catch (PDOException $e) { |
|
| 352 | 352 | echo $e->getMessage(); |
| 353 | 353 | die; |
| 354 | 354 | } |
@@ -360,24 +360,24 @@ discard block |
||
| 360 | 360 | * @return Array the spotter information |
| 361 | 361 | * |
| 362 | 362 | */ |
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 363 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 364 | 364 | { |
| 365 | 365 | global $globalDBdriver, $globalLiveInterval; |
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $filter_query = ''; |
| 369 | 369 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 370 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 371 | 371 | } |
| 372 | 372 | // Use spotter_output also ? |
| 373 | 373 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 375 | 375 | } |
| 376 | 376 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 377 | 377 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 378 | 378 | } |
| 379 | 379 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -396,14 +396,14 @@ discard block |
||
| 396 | 396 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 397 | 397 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 398 | 398 | */ |
| 399 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 399 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 400 | 400 | FROM marine_archive |
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
| 404 | 404 | } else { |
| 405 | 405 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 407 | 407 | FROM marine_archive |
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $sth = $this->db->prepare($query); |
| 415 | 415 | $sth->execute(); |
| 416 | - } catch(PDOException $e) { |
|
| 416 | + } catch (PDOException $e) { |
|
| 417 | 417 | echo $e->getMessage(); |
| 418 | 418 | die; |
| 419 | 419 | } |
@@ -428,24 +428,24 @@ discard block |
||
| 428 | 428 | * @return Array the spotter information |
| 429 | 429 | * |
| 430 | 430 | */ |
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 431 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 432 | 432 | { |
| 433 | 433 | global $globalDBdriver, $globalLiveInterval; |
| 434 | 434 | date_default_timezone_set('UTC'); |
| 435 | 435 | |
| 436 | 436 | $filter_query = ''; |
| 437 | 437 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 438 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 439 | 439 | } |
| 440 | 440 | // Should use spotter_output also ? |
| 441 | 441 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 443 | 443 | } |
| 444 | 444 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 445 | 445 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | FROM marine_archive |
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 457 | 457 | */ |
| 458 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 458 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 459 | 459 | FROM marine_archive_output |
| 460 | 460 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 472 | 472 | */ |
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 474 | 474 | FROM marine_archive_output |
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | try { |
| 483 | 483 | $sth = $this->db->prepare($query); |
| 484 | 484 | $sth->execute(); |
| 485 | - } catch(PDOException $e) { |
|
| 485 | + } catch (PDOException $e) { |
|
| 486 | 486 | echo $e->getMessage(); |
| 487 | 487 | die; |
| 488 | 488 | } |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | * @return Array the spotter information |
| 498 | 498 | * |
| 499 | 499 | */ |
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 500 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 501 | 501 | { |
| 502 | 502 | global $globalDBdriver, $globalLiveInterval; |
| 503 | 503 | date_default_timezone_set('UTC'); |
| 504 | 504 | |
| 505 | 505 | $filter_query = ''; |
| 506 | 506 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 507 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 508 | 508 | } |
| 509 | 509 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 511 | 511 | } |
| 512 | 512 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 513 | 513 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 514 | 514 | } |
| 515 | 515 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | try { |
| 529 | 529 | $sth = $this->db->prepare($query); |
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | echo $e->getMessage(); |
| 533 | 533 | die; |
| 534 | 534 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return Array the spotter information |
| 549 | 549 | * |
| 550 | 550 | */ |
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 552 | 552 | { |
| 553 | 553 | global $globalTimezone, $globalDBdriver; |
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $q_array = explode(" ", $q); |
| 572 | 572 | |
| 573 | - foreach ($q_array as $q_item){ |
|
| 573 | + foreach ($q_array as $q_item) { |
|
| 574 | 574 | $additional_query .= " AND ("; |
| 575 | 575 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 576 | 576 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | if ($registration != "") |
| 604 | 604 | { |
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 605 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 606 | 606 | if (!is_string($registration)) |
| 607 | 607 | { |
| 608 | 608 | return false; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "") |
| 615 | 615 | { |
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 616 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 617 | 617 | if (!is_string($aircraft_icao)) |
| 618 | 618 | { |
| 619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "") |
| 626 | 626 | { |
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 628 | 628 | if (!is_string($aircraft_manufacturer)) |
| 629 | 629 | { |
| 630 | 630 | return false; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "") |
| 647 | 647 | { |
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 648 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 649 | 649 | if (!is_string($airline_icao)) |
| 650 | 650 | { |
| 651 | 651 | return false; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "") |
| 658 | 658 | { |
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 659 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 660 | 660 | if (!is_string($airline_country)) |
| 661 | 661 | { |
| 662 | 662 | return false; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "") |
| 669 | 669 | { |
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 670 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 671 | 671 | if (!is_string($airline_type)) |
| 672 | 672 | { |
| 673 | 673 | return false; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | if ($airport != "") |
| 691 | 691 | { |
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 692 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | if (!is_string($airport)) |
| 694 | 694 | { |
| 695 | 695 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "") |
| 702 | 702 | { |
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 703 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 704 | 704 | if (!is_string($airport_country)) |
| 705 | 705 | { |
| 706 | 706 | return false; |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | if ($callsign != "") |
| 713 | 713 | { |
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 714 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 715 | 715 | if (!is_string($callsign)) |
| 716 | 716 | { |
| 717 | 717 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $translate = $Translation->ident2icao($callsign); |
| 720 | 720 | if ($translate != $callsign) { |
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 722 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 722 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 723 | 723 | } else { |
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 725 | 725 | } |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | if ($owner != "") |
| 730 | 730 | { |
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 731 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 732 | 732 | if (!is_string($owner)) |
| 733 | 733 | { |
| 734 | 734 | return false; |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "") |
| 741 | 741 | { |
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 742 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 743 | 743 | if (!is_string($pilot_name)) |
| 744 | 744 | { |
| 745 | 745 | return false; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "") |
| 752 | 752 | { |
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 753 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 754 | 754 | if (!is_string($pilot_id)) |
| 755 | 755 | { |
| 756 | 756 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "") |
| 763 | 763 | { |
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 764 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 765 | 765 | if (!is_string($departure_airport_route)) |
| 766 | 766 | { |
| 767 | 767 | return false; |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "") |
| 774 | 774 | { |
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 776 | 776 | if (!is_string($arrival_airport_route)) |
| 777 | 777 | { |
| 778 | 778 | return false; |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | $altitude_array = explode(",", $altitude); |
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 788 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 790 | 790 | |
| 791 | 791 | |
| 792 | 792 | if ($altitude_array[1] != "") |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | { |
| 805 | 805 | $date_array = explode(",", $date_posted); |
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 807 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 808 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 809 | 809 | |
| 810 | 810 | if ($globalTimezone != '') { |
| 811 | 811 | date_default_timezone_set($globalTimezone); |
@@ -837,8 +837,8 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $limit_array = explode(",", $limit); |
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 840 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 842 | 842 | |
| 843 | 843 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 844 | 844 | { |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | |
| 851 | 851 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 852 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 853 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 852 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 853 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 854 | 854 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 855 | 855 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 856 | 856 | } else { |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 870 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 871 | 871 | WHERE marine_archive_output.ident <> '' |
| 872 | 872 | ".$additional_query." |
| 873 | 873 | ".$filter_query.$orderby_query; |
| 874 | 874 | } |
| 875 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 875 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 876 | 876 | |
| 877 | 877 | return $spotter_array; |
| 878 | 878 | } |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | try { |
| 890 | 890 | $sth = $this->db->prepare($query); |
| 891 | 891 | $sth->execute(); |
| 892 | - } catch(PDOException $e) { |
|
| 892 | + } catch (PDOException $e) { |
|
| 893 | 893 | return "error"; |
| 894 | 894 | } |
| 895 | 895 | } |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | { |
| 927 | 927 | $limit_array = explode(",", $limit); |
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 929 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 931 | 931 | |
| 932 | 932 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 933 | 933 | { |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $query_values = array(); |
| 969 | 969 | $limit_query = ''; |
| 970 | 970 | $additional_query = ''; |
| 971 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 971 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 972 | 972 | |
| 973 | 973 | if ($owner != "") |
| 974 | 974 | { |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | { |
| 986 | 986 | $limit_array = explode(",", $limit); |
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 992 | 992 | { |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | $query_values = array(); |
| 1027 | 1027 | $limit_query = ''; |
| 1028 | 1028 | $additional_query = ''; |
| 1029 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1029 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1030 | 1030 | |
| 1031 | 1031 | if ($pilot != "") |
| 1032 | 1032 | { |
@@ -1038,8 +1038,8 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | $limit_array = explode(",", $limit); |
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1043 | 1043 | |
| 1044 | 1044 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1045 | 1045 | { |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @return Array the airline country list |
| 1070 | 1070 | * |
| 1071 | 1071 | */ |
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1072 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1073 | 1073 | { |
| 1074 | 1074 | global $globalDBdriver; |
| 1075 | 1075 | /* |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | $flight_array = array(); |
| 1099 | 1099 | $temp_array = array(); |
| 1100 | 1100 | |
| 1101 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1101 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | $temp_array['flight_count'] = $row['nb']; |
| 1104 | 1104 | $temp_array['flight_country'] = $row['name']; |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return Array the airline country list |
| 1116 | 1116 | * |
| 1117 | 1117 | */ |
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | $flight_array = array(); |
| 1145 | 1145 | $temp_array = array(); |
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1150 | 1150 | $temp_array['flight_count'] = $row['nb']; |
@@ -1162,14 +1162,14 @@ discard block |
||
| 1162 | 1162 | * @return Array the spotter information |
| 1163 | 1163 | * |
| 1164 | 1164 | */ |
| 1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1165 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1166 | 1166 | { |
| 1167 | 1167 | $Marine = new Marine($this->db); |
| 1168 | 1168 | date_default_timezone_set('UTC'); |
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1170 | 1170 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1171 | - $date = date('c',$date); |
|
| 1172 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1171 | + $date = date('c', $date); |
|
| 1172 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1173 | 1173 | return $spotter_array; |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1179,14 +1179,14 @@ discard block |
||
| 1179 | 1179 | * @return Array the spotter information |
| 1180 | 1180 | * |
| 1181 | 1181 | */ |
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1182 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1183 | 1183 | { |
| 1184 | 1184 | $Marine = new Marine($this->db); |
| 1185 | 1185 | date_default_timezone_set('UTC'); |
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1187 | 1187 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1188 | - $date = date('c',$date); |
|
| 1189 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1188 | + $date = date('c', $date); |
|
| 1189 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1190 | 1190 | return $spotter_array; |
| 1191 | 1191 | } |
| 1192 | 1192 | |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @return Array the spotter information |
| 1197 | 1197 | * |
| 1198 | 1198 | */ |
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $global_query; |
| 1202 | 1202 | $Marine = new Marine($this->db); |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | $query_values = array(); |
| 1205 | 1205 | $limit_query = ''; |
| 1206 | 1206 | $additional_query = ''; |
| 1207 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1207 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "") |
| 1210 | 1210 | { |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | { |
| 1222 | 1222 | $limit_array = explode(",", $limit); |
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1226 | 1226 | |
| 1227 | 1227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1228 | 1228 | { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $Connection = new Connection($this->db); |
| 55 | 55 | $sth = $Connection->db->prepare($query); |
| 56 | 56 | $sth->execute(); |
| 57 | - } catch(PDOException $e) { |
|
| 57 | + } catch (PDOException $e) { |
|
| 58 | 58 | return "error : ".$e->getMessage(); |
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $Connection = new Connection($this->db); |
| 71 | 71 | $sth = $Connection->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | public function parse($data) { |
| 79 | 79 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
| 80 | 80 | $codes = implode('|', array_keys($this->texts)); |
| 81 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
| 81 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
| 82 | 82 | //$pieces = explode(' ',$data); |
| 83 | - $pieces = preg_split('/\s/',$data); |
|
| 83 | + $pieces = preg_split('/\s/', $data); |
|
| 84 | 84 | $pos = 0; |
| 85 | 85 | if ($pieces[0] == 'METAR') $pos++; |
| 86 | 86 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -88,25 +88,25 @@ discard block |
||
| 88 | 88 | $result = array(); |
| 89 | 89 | $result['location'] = $pieces[$pos]; |
| 90 | 90 | $pos++; |
| 91 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
| 92 | - $result['time'] = substr($pieces[$pos],2,4); |
|
| 91 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
| 92 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
| 93 | 93 | $c = count($pieces); |
| 94 | - for($pos++; $pos < $c; $pos++) { |
|
| 94 | + for ($pos++; $pos < $c; $pos++) { |
|
| 95 | 95 | $piece = $pieces[$pos]; |
| 96 | 96 | if ($piece == 'RMK') break; |
| 97 | 97 | if ($piece == 'AUTO') $result['auto'] = true; |
| 98 | 98 | if ($piece == 'COR') $result['correction'] = true; |
| 99 | 99 | // Wind Speed |
| 100 | 100 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 101 | - $result['wind']['direction'] = (float)$matches[1]; |
|
| 101 | + $result['wind']['direction'] = (float) $matches[1]; |
|
| 102 | 102 | $result['wind']['unit'] = $matches[4]; |
| 103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 106 | - $result['wind']['gust'] = (float)$matches[3]; |
|
| 103 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
| 104 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
| 105 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
| 106 | + $result['wind']['gust'] = (float) $matches[3]; |
|
| 107 | 107 | $result['wind']['unit'] = $matches[4]; |
| 108 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
| 109 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
| 108 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
| 109 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // Temperature |
| 129 | 129 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
| 130 | - $temp = (float)$matches[1]; |
|
| 130 | + $temp = (float) $matches[1]; |
|
| 131 | 131 | if ($matches[1]{0} == 'M') { |
| 132 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
| 132 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
| 133 | 133 | } |
| 134 | 134 | $result['temperature'] = $temp; |
| 135 | - $dew = (float)$matches[2]; |
|
| 135 | + $dew = (float) $matches[2]; |
|
| 136 | 136 | if ($matches[2]{0} == 'M') { |
| 137 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
| 137 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
| 138 | 138 | } |
| 139 | 139 | $result['dew'] = $dew; |
| 140 | 140 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $result['QNH'] = $matches[2]; |
| 147 | 147 | } else { |
| 148 | 148 | // inHg |
| 149 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
| 149 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
| 150 | 150 | } |
| 151 | 151 | /* |
| 152 | 152 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | // Visibility |
| 168 | 168 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 169 | 169 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 170 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
| 170 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
| 171 | 171 | } else { |
| 172 | 172 | if ($matches[1] == '9999') { |
| 173 | 173 | $result['visibility'] = '> 10000'; |
| 174 | 174 | } else { |
| 175 | - $result['visibility'] = (float)$matches[1]; |
|
| 175 | + $result['visibility'] = (float) $matches[1]; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
| 195 | 195 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
| 196 | 196 | $cloud['type_code'] = $type; |
| 197 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
| 197 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
| 198 | 198 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
| 199 | 199 | $result['cloud'][] = $cloud; |
| 200 | 200 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | $rvr['runway'] = $matches[1]; |
| 205 | 205 | $rvr['assessment'] = $matches[2]; |
| 206 | 206 | $rvr['rvr'] = $matches[3]; |
| 207 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
| 208 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
| 207 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
| 208 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
| 209 | 209 | $result['RVR'] = $rvr; |
| 210 | 210 | } |
| 211 | 211 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | $result['RVR']['friction'] = $matches[5]; |
| 219 | 219 | } |
| 220 | 220 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 221 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
| 223 | 223 | if (isset($matches[3])) { |
| 224 | 224 | $range = Array( |
| 225 | - 'from' => (float)$matches[2], |
|
| 226 | - 'to' => (float)$matches[4], |
|
| 225 | + 'from' => (float) $matches[2], |
|
| 226 | + 'to' => (float) $matches[4], |
|
| 227 | 227 | 'unit' => $matches[5] ? 'FT' : 'M' |
| 228 | 228 | ); |
| 229 | 229 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | try { |
| 272 | 272 | $sth = $this->db->prepare($query); |
| 273 | 273 | $sth->execute($query_values); |
| 274 | - } catch(PDOException $e) { |
|
| 274 | + } catch (PDOException $e) { |
|
| 275 | 275 | return "error : ".$e->getMessage(); |
| 276 | 276 | } |
| 277 | 277 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -281,19 +281,19 @@ discard block |
||
| 281 | 281 | return $all; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function addMETAR($location,$metar,$date) { |
|
| 284 | + public function addMETAR($location, $metar, $date) { |
|
| 285 | 285 | global $globalDBdriver; |
| 286 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
| 286 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 287 | 287 | if ($globalDBdriver == 'mysql') { |
| 288 | 288 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
| 289 | 289 | } else { |
| 290 | 290 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
| 291 | 291 | } |
| 292 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
| 292 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute($query_values); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | return "error : ".$e->getMessage(); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | try { |
| 305 | 305 | $sth = $this->db->prepare($query); |
| 306 | 306 | $sth->execute($query_values); |
| 307 | - } catch(PDOException $e) { |
|
| 307 | + } catch (PDOException $e) { |
|
| 308 | 308 | return "error : ".$e->getMessage(); |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | try { |
| 315 | 315 | $sth = $this->db->prepare($query); |
| 316 | 316 | $sth->execute(); |
| 317 | - } catch(PDOException $e) { |
|
| 317 | + } catch (PDOException $e) { |
|
| 318 | 318 | return "error : ".$e->getMessage(); |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -325,27 +325,27 @@ discard block |
||
| 325 | 325 | date_default_timezone_set("UTC"); |
| 326 | 326 | $Common = new Common(); |
| 327 | 327 | if (isset($globalIVAO) && $globalIVAO) { |
| 328 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
| 328 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
| 330 | 330 | } else { |
| 331 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
| 331 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
| 333 | 333 | } |
| 334 | 334 | if ($handle) { |
| 335 | 335 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
| 336 | 336 | $date = ''; |
| 337 | 337 | if ($globalTransaction) $this->db->beginTransaction(); |
| 338 | - while(($line = fgets($handle,4096)) !== false) { |
|
| 339 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 338 | + while (($line = fgets($handle, 4096)) !== false) { |
|
| 339 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 340 | 340 | $date = $line; |
| 341 | 341 | } elseif ($line != '') { |
| 342 | 342 | if ($date == '') $date = date('Y/m/d H:m'); |
| 343 | 343 | $pos = 0; |
| 344 | - $pieces = preg_split('/\s/',$line); |
|
| 344 | + $pieces = preg_split('/\s/', $line); |
|
| 345 | 345 | if ($pieces[0] == 'METAR') $pos++; |
| 346 | 346 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 347 | 347 | $location = $pieces[$pos]; |
| 348 | - echo $this->addMETAR($location,$line,$date); |
|
| 348 | + echo $this->addMETAR($location, $line, $date); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | fclose($handle); |
@@ -359,22 +359,22 @@ discard block |
||
| 359 | 359 | if ($globalMETARurl == '') return array(); |
| 360 | 360 | date_default_timezone_set("UTC"); |
| 361 | 361 | $Common = new Common(); |
| 362 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
| 362 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
| 363 | 363 | $cycle = $Common->getData($url); |
| 364 | 364 | $date = ''; |
| 365 | - foreach(explode("\n",$cycle) as $line) { |
|
| 366 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 365 | + foreach (explode("\n", $cycle) as $line) { |
|
| 366 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 367 | 367 | $date = $line; |
| 368 | 368 | } |
| 369 | 369 | if ($line != '') { |
| 370 | 370 | if ($date == '') $date = date('Y/m/d H:m'); |
| 371 | 371 | $pos = 0; |
| 372 | - $pieces = preg_split('/\s/',$line); |
|
| 372 | + $pieces = preg_split('/\s/', $line); |
|
| 373 | 373 | if ($pieces[0] == 'METAR') $pos++; |
| 374 | 374 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 375 | 375 | $location = $pieces[$pos]; |
| 376 | 376 | if (strlen($location == 4)) { |
| 377 | - $this->addMETAR($location,$line,$date); |
|
| 377 | + $this->addMETAR($location, $line, $date); |
|
| 378 | 378 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 379 | 379 | } else return array(); |
| 380 | 380 | } |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | if ($this->db === null) die('Error: No DB connection.'); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 12 | + /** |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -31,88 +31,88 @@ discard block |
||
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | 33 | foreach($filters as $flt) { |
| 34 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 34 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
| 35 | 35 | if ($flt['airlines'][0] != '') { |
| 36 | - if (isset($flt['source'])) { |
|
| 36 | + if (isset($flt['source'])) { |
|
| 37 | 37 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 38 | - } else { |
|
| 38 | + } else { |
|
| 39 | 39 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | + } |
|
| 41 | 42 | } |
| 42 | - } |
|
| 43 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 43 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | - } |
|
| 50 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 49 | + } |
|
| 50 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | + } |
|
| 55 | 56 | } |
| 56 | - } |
|
| 57 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 57 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | + } |
|
| 62 | 63 | } |
| 63 | - } |
|
| 64 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 64 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | + } |
|
| 67 | 68 | } |
| 68 | - } |
|
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | - if ($filter['airlines'][0] != '') { |
|
| 71 | + if ($filter['airlines'][0] != '') { |
|
| 72 | 72 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 77 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 77 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
| 78 | 78 | } |
| 79 | 79 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 83 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 86 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 86 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
| 87 | 87 | } |
| 88 | 88 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 89 | 89 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 90 | 90 | } |
| 91 | 91 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 92 | - $filter_query_date = ''; |
|
| 92 | + $filter_query_date = ''; |
|
| 93 | 93 | |
| 94 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
| 94 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
| 95 | 95 | if ($globalDBdriver == 'mysql') { |
| 96 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 96 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 97 | 97 | } else { |
| 98 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 98 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
| 99 | + } |
|
| 99 | 100 | } |
| 100 | - } |
|
| 101 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
| 101 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
| 102 | 102 | if ($globalDBdriver == 'mysql') { |
| 103 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 103 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 104 | 104 | } else { |
| 105 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 105 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
| 107 | + } |
|
| 108 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
| 109 | 109 | if ($globalDBdriver == 'mysql') { |
| 110 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 110 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 111 | 111 | } else { |
| 112 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 112 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
| 113 | + } |
|
| 113 | 114 | } |
| 114 | - } |
|
| 115 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 116 | 116 | } |
| 117 | 117 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 118 | 118 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | $filter_query = $filter_query_join.$filter_query_where; |
| 123 | 123 | return $filter_query; |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | // Spotter_archive |
| 127 | 127 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -153,44 +153,44 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Gets all the spotter information based on a particular callsign |
|
| 158 | - * |
|
| 159 | - * @return Array the spotter information |
|
| 160 | - * |
|
| 161 | - */ |
|
| 162 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
| 163 | - { |
|
| 156 | + /** |
|
| 157 | + * Gets all the spotter information based on a particular callsign |
|
| 158 | + * |
|
| 159 | + * @return Array the spotter information |
|
| 160 | + * |
|
| 161 | + */ |
|
| 162 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
| 163 | + { |
|
| 164 | 164 | $Spotter = new Spotter($this->db); |
| 165 | - date_default_timezone_set('UTC'); |
|
| 165 | + date_default_timezone_set('UTC'); |
|
| 166 | 166 | |
| 167 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 168 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 169 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 168 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 169 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 170 | 170 | |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 172 | 172 | |
| 173 | - return $spotter_array; |
|
| 174 | - } |
|
| 173 | + return $spotter_array; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Gets last the spotter information based on a particular id |
|
| 179 | - * |
|
| 180 | - * @return Array the spotter information |
|
| 181 | - * |
|
| 182 | - */ |
|
| 183 | - public function getLastArchiveSpotterDataById($id) |
|
| 184 | - { |
|
| 185 | - $Spotter = new Spotter($this->db); |
|
| 186 | - date_default_timezone_set('UTC'); |
|
| 187 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 188 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 189 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 190 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 177 | + /** |
|
| 178 | + * Gets last the spotter information based on a particular id |
|
| 179 | + * |
|
| 180 | + * @return Array the spotter information |
|
| 181 | + * |
|
| 182 | + */ |
|
| 183 | + public function getLastArchiveSpotterDataById($id) |
|
| 184 | + { |
|
| 185 | + $Spotter = new Spotter($this->db); |
|
| 186 | + date_default_timezone_set('UTC'); |
|
| 187 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 188 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
| 189 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 190 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 191 | 191 | |
| 192 | 192 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 193 | - /* |
|
| 193 | + /* |
|
| 194 | 194 | try { |
| 195 | 195 | $Connection = new Connection(); |
| 196 | 196 | $sth = Connection->$db->prepare($query); |
@@ -200,235 +200,235 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 202 | 202 | */ |
| 203 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 204 | - |
|
| 205 | - return $spotter_array; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Gets all the spotter information based on a particular id |
|
| 210 | - * |
|
| 211 | - * @return Array the spotter information |
|
| 212 | - * |
|
| 213 | - */ |
|
| 214 | - public function getAllArchiveSpotterDataById($id) |
|
| 203 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 204 | + |
|
| 205 | + return $spotter_array; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Gets all the spotter information based on a particular id |
|
| 210 | + * |
|
| 211 | + * @return Array the spotter information |
|
| 212 | + * |
|
| 213 | + */ |
|
| 214 | + public function getAllArchiveSpotterDataById($id) |
|
| 215 | 215 | { |
| 216 | - date_default_timezone_set('UTC'); |
|
| 217 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 218 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 216 | + date_default_timezone_set('UTC'); |
|
| 217 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 218 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 219 | 219 | |
| 220 | 220 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 221 | 221 | |
| 222 | - try { |
|
| 223 | - $sth = $this->db->prepare($query); |
|
| 224 | - $sth->execute(array(':id' => $id)); |
|
| 225 | - } catch(PDOException $e) { |
|
| 226 | - echo $e->getMessage(); |
|
| 227 | - die; |
|
| 228 | - } |
|
| 229 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 230 | - |
|
| 231 | - return $spotter_array; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Gets coordinate & time spotter information based on a particular id |
|
| 236 | - * |
|
| 237 | - * @return Array the spotter information |
|
| 238 | - * |
|
| 239 | - */ |
|
| 240 | - public function getCoordArchiveSpotterDataById($id) |
|
| 241 | - { |
|
| 242 | - date_default_timezone_set('UTC'); |
|
| 243 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 244 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 222 | + try { |
|
| 223 | + $sth = $this->db->prepare($query); |
|
| 224 | + $sth->execute(array(':id' => $id)); |
|
| 225 | + } catch(PDOException $e) { |
|
| 226 | + echo $e->getMessage(); |
|
| 227 | + die; |
|
| 228 | + } |
|
| 229 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 230 | + |
|
| 231 | + return $spotter_array; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Gets coordinate & time spotter information based on a particular id |
|
| 236 | + * |
|
| 237 | + * @return Array the spotter information |
|
| 238 | + * |
|
| 239 | + */ |
|
| 240 | + public function getCoordArchiveSpotterDataById($id) |
|
| 241 | + { |
|
| 242 | + date_default_timezone_set('UTC'); |
|
| 243 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 244 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 245 | 245 | |
| 246 | 246 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 247 | 247 | |
| 248 | - try { |
|
| 249 | - $sth = $this->db->prepare($query); |
|
| 250 | - $sth->execute(array(':id' => $id)); |
|
| 251 | - } catch(PDOException $e) { |
|
| 252 | - echo $e->getMessage(); |
|
| 253 | - die; |
|
| 254 | - } |
|
| 255 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | + try { |
|
| 249 | + $sth = $this->db->prepare($query); |
|
| 250 | + $sth->execute(array(':id' => $id)); |
|
| 251 | + } catch(PDOException $e) { |
|
| 252 | + echo $e->getMessage(); |
|
| 253 | + die; |
|
| 254 | + } |
|
| 255 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 256 | 256 | |
| 257 | - return $spotter_array; |
|
| 258 | - } |
|
| 257 | + return $spotter_array; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * Gets altitude information based on a particular callsign |
|
| 263 | - * |
|
| 264 | - * @return Array the spotter information |
|
| 265 | - * |
|
| 266 | - */ |
|
| 267 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 268 | - { |
|
| 261 | + /** |
|
| 262 | + * Gets altitude information based on a particular callsign |
|
| 263 | + * |
|
| 264 | + * @return Array the spotter information |
|
| 265 | + * |
|
| 266 | + */ |
|
| 267 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
| 268 | + { |
|
| 269 | 269 | |
| 270 | - date_default_timezone_set('UTC'); |
|
| 270 | + date_default_timezone_set('UTC'); |
|
| 271 | 271 | |
| 272 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 273 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 272 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 273 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 274 | 274 | |
| 275 | - try { |
|
| 276 | - $sth = $this->db->prepare($query); |
|
| 277 | - $sth->execute(array(':ident' => $ident)); |
|
| 278 | - } catch(PDOException $e) { |
|
| 279 | - echo $e->getMessage(); |
|
| 280 | - die; |
|
| 281 | - } |
|
| 282 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | + try { |
|
| 276 | + $sth = $this->db->prepare($query); |
|
| 277 | + $sth->execute(array(':ident' => $ident)); |
|
| 278 | + } catch(PDOException $e) { |
|
| 279 | + echo $e->getMessage(); |
|
| 280 | + die; |
|
| 281 | + } |
|
| 282 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 283 | 283 | |
| 284 | - return $spotter_array; |
|
| 285 | - } |
|
| 284 | + return $spotter_array; |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * Gets altitude information based on a particular id |
|
| 289 | - * |
|
| 290 | - * @return Array the spotter information |
|
| 291 | - * |
|
| 292 | - */ |
|
| 293 | - public function getAltitudeArchiveSpotterDataById($id) |
|
| 294 | - { |
|
| 287 | + /** |
|
| 288 | + * Gets altitude information based on a particular id |
|
| 289 | + * |
|
| 290 | + * @return Array the spotter information |
|
| 291 | + * |
|
| 292 | + */ |
|
| 293 | + public function getAltitudeArchiveSpotterDataById($id) |
|
| 294 | + { |
|
| 295 | 295 | |
| 296 | - date_default_timezone_set('UTC'); |
|
| 296 | + date_default_timezone_set('UTC'); |
|
| 297 | 297 | |
| 298 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 299 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 298 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 299 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 300 | 300 | |
| 301 | - try { |
|
| 302 | - $sth = $this->db->prepare($query); |
|
| 303 | - $sth->execute(array(':id' => $id)); |
|
| 304 | - } catch(PDOException $e) { |
|
| 305 | - echo $e->getMessage(); |
|
| 306 | - die; |
|
| 307 | - } |
|
| 308 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | + try { |
|
| 302 | + $sth = $this->db->prepare($query); |
|
| 303 | + $sth->execute(array(':id' => $id)); |
|
| 304 | + } catch(PDOException $e) { |
|
| 305 | + echo $e->getMessage(); |
|
| 306 | + die; |
|
| 307 | + } |
|
| 308 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 309 | 309 | |
| 310 | - return $spotter_array; |
|
| 311 | - } |
|
| 310 | + return $spotter_array; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - /** |
|
| 314 | - * Gets altitude & speed information based on a particular id |
|
| 315 | - * |
|
| 316 | - * @return Array the spotter information |
|
| 317 | - * |
|
| 318 | - */ |
|
| 319 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 320 | - { |
|
| 313 | + /** |
|
| 314 | + * Gets altitude & speed information based on a particular id |
|
| 315 | + * |
|
| 316 | + * @return Array the spotter information |
|
| 317 | + * |
|
| 318 | + */ |
|
| 319 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
| 320 | + { |
|
| 321 | 321 | |
| 322 | - date_default_timezone_set('UTC'); |
|
| 322 | + date_default_timezone_set('UTC'); |
|
| 323 | 323 | |
| 324 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 325 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 324 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 325 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 326 | 326 | |
| 327 | - try { |
|
| 328 | - $sth = $this->db->prepare($query); |
|
| 329 | - $sth->execute(array(':id' => $id)); |
|
| 330 | - } catch(PDOException $e) { |
|
| 331 | - echo $e->getMessage(); |
|
| 332 | - die; |
|
| 333 | - } |
|
| 334 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 327 | + try { |
|
| 328 | + $sth = $this->db->prepare($query); |
|
| 329 | + $sth->execute(array(':id' => $id)); |
|
| 330 | + } catch(PDOException $e) { |
|
| 331 | + echo $e->getMessage(); |
|
| 332 | + die; |
|
| 333 | + } |
|
| 334 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 335 | 335 | |
| 336 | - return $spotter_array; |
|
| 337 | - } |
|
| 336 | + return $spotter_array; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Gets altitude information based on a particular callsign |
|
| 342 | - * |
|
| 343 | - * @return Array the spotter information |
|
| 344 | - * |
|
| 345 | - */ |
|
| 346 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 347 | - { |
|
| 340 | + /** |
|
| 341 | + * Gets altitude information based on a particular callsign |
|
| 342 | + * |
|
| 343 | + * @return Array the spotter information |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
| 347 | + { |
|
| 348 | 348 | |
| 349 | - date_default_timezone_set('UTC'); |
|
| 349 | + date_default_timezone_set('UTC'); |
|
| 350 | 350 | |
| 351 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 352 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 351 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 352 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 353 | 353 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 354 | 354 | |
| 355 | - try { |
|
| 356 | - $sth = $this->db->prepare($query); |
|
| 357 | - $sth->execute(array(':ident' => $ident)); |
|
| 358 | - } catch(PDOException $e) { |
|
| 359 | - echo $e->getMessage(); |
|
| 360 | - die; |
|
| 361 | - } |
|
| 362 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 355 | + try { |
|
| 356 | + $sth = $this->db->prepare($query); |
|
| 357 | + $sth->execute(array(':ident' => $ident)); |
|
| 358 | + } catch(PDOException $e) { |
|
| 359 | + echo $e->getMessage(); |
|
| 360 | + die; |
|
| 361 | + } |
|
| 362 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 363 | 363 | |
| 364 | - return $spotter_array; |
|
| 365 | - } |
|
| 364 | + return $spotter_array; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | 367 | |
| 368 | 368 | |
| 369 | - /** |
|
| 370 | - * Gets all the archive spotter information |
|
| 371 | - * |
|
| 372 | - * @return Array the spotter information |
|
| 373 | - * |
|
| 374 | - */ |
|
| 375 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 376 | - { |
|
| 377 | - $Spotter = new Spotter($this->db); |
|
| 378 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 379 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 369 | + /** |
|
| 370 | + * Gets all the archive spotter information |
|
| 371 | + * |
|
| 372 | + * @return Array the spotter information |
|
| 373 | + * |
|
| 374 | + */ |
|
| 375 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 376 | + { |
|
| 377 | + $Spotter = new Spotter($this->db); |
|
| 378 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 379 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 380 | 380 | |
| 381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 381 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 382 | 382 | |
| 383 | - return $spotter_array; |
|
| 384 | - } |
|
| 383 | + return $spotter_array; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - public function deleteSpotterArchiveTrackData() |
|
| 387 | - { |
|
| 386 | + public function deleteSpotterArchiveTrackData() |
|
| 387 | + { |
|
| 388 | 388 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
| 389 | 389 | if ($globalDBdriver == 'mysql') { |
| 390 | 390 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 391 | 391 | } else { |
| 392 | 392 | $query = "DELETE FROM spotter_archive WHERE spotter_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH'"; |
| 393 | 393 | } |
| 394 | - try { |
|
| 395 | - $sth = $this->db->prepare($query); |
|
| 396 | - $sth->execute(); |
|
| 397 | - } catch(PDOException $e) { |
|
| 398 | - echo $e->getMessage(); |
|
| 399 | - die; |
|
| 400 | - } |
|
| 394 | + try { |
|
| 395 | + $sth = $this->db->prepare($query); |
|
| 396 | + $sth->execute(); |
|
| 397 | + } catch(PDOException $e) { |
|
| 398 | + echo $e->getMessage(); |
|
| 399 | + die; |
|
| 400 | + } |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | - * Gets Minimal Live Spotter data |
|
| 405 | - * |
|
| 406 | - * @return Array the spotter information |
|
| 407 | - * |
|
| 408 | - */ |
|
| 409 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 410 | - { |
|
| 411 | - global $globalDBdriver, $globalLiveInterval; |
|
| 412 | - date_default_timezone_set('UTC'); |
|
| 413 | - |
|
| 414 | - $filter_query = ''; |
|
| 415 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 416 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 417 | - } |
|
| 418 | - // Use spotter_output also ? |
|
| 419 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 420 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 421 | - } |
|
| 422 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 423 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 424 | - } |
|
| 425 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 426 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 430 | - if ($globalDBdriver == 'mysql') { |
|
| 431 | - /* |
|
| 404 | + * Gets Minimal Live Spotter data |
|
| 405 | + * |
|
| 406 | + * @return Array the spotter information |
|
| 407 | + * |
|
| 408 | + */ |
|
| 409 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 410 | + { |
|
| 411 | + global $globalDBdriver, $globalLiveInterval; |
|
| 412 | + date_default_timezone_set('UTC'); |
|
| 413 | + |
|
| 414 | + $filter_query = ''; |
|
| 415 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 416 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 417 | + } |
|
| 418 | + // Use spotter_output also ? |
|
| 419 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 420 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 421 | + } |
|
| 422 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 423 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 424 | + } |
|
| 425 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 426 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 430 | + if ($globalDBdriver == 'mysql') { |
|
| 431 | + /* |
|
| 432 | 432 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 433 | 433 | FROM spotter_archive |
| 434 | 434 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -447,56 +447,56 @@ discard block |
||
| 447 | 447 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 448 | 448 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 449 | 449 | '.$filter_query.' ORDER BY flightaware_id'; |
| 450 | - } else { |
|
| 451 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 452 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 450 | + } else { |
|
| 451 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
| 452 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 453 | 453 | FROM spotter_archive |
| 454 | 454 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 455 | 455 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
| 456 | 456 | '.$filter_query.' ORDER BY flightaware_id'; |
| 457 | - } |
|
| 458 | - //echo $query; |
|
| 459 | - try { |
|
| 460 | - $sth = $this->db->prepare($query); |
|
| 461 | - $sth->execute(); |
|
| 462 | - } catch(PDOException $e) { |
|
| 463 | - echo $e->getMessage(); |
|
| 464 | - die; |
|
| 465 | - } |
|
| 466 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 467 | - |
|
| 468 | - return $spotter_array; |
|
| 469 | - } |
|
| 457 | + } |
|
| 458 | + //echo $query; |
|
| 459 | + try { |
|
| 460 | + $sth = $this->db->prepare($query); |
|
| 461 | + $sth->execute(); |
|
| 462 | + } catch(PDOException $e) { |
|
| 463 | + echo $e->getMessage(); |
|
| 464 | + die; |
|
| 465 | + } |
|
| 466 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 467 | + |
|
| 468 | + return $spotter_array; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | 471 | /** |
| 472 | - * Gets Minimal Live Spotter data |
|
| 473 | - * |
|
| 474 | - * @return Array the spotter information |
|
| 475 | - * |
|
| 476 | - */ |
|
| 477 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 478 | - { |
|
| 479 | - global $globalDBdriver, $globalLiveInterval; |
|
| 480 | - date_default_timezone_set('UTC'); |
|
| 481 | - |
|
| 482 | - $filter_query = ''; |
|
| 483 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 484 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 485 | - } |
|
| 486 | - // Should use spotter_output also ? |
|
| 487 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 488 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 489 | - } |
|
| 490 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 491 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 492 | - } |
|
| 493 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 494 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 498 | - if ($globalDBdriver == 'mysql') { |
|
| 499 | - /* |
|
| 472 | + * Gets Minimal Live Spotter data |
|
| 473 | + * |
|
| 474 | + * @return Array the spotter information |
|
| 475 | + * |
|
| 476 | + */ |
|
| 477 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 478 | + { |
|
| 479 | + global $globalDBdriver, $globalLiveInterval; |
|
| 480 | + date_default_timezone_set('UTC'); |
|
| 481 | + |
|
| 482 | + $filter_query = ''; |
|
| 483 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 484 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 485 | + } |
|
| 486 | + // Should use spotter_output also ? |
|
| 487 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 488 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 489 | + } |
|
| 490 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 491 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 492 | + } |
|
| 493 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 494 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 498 | + if ($globalDBdriver == 'mysql') { |
|
| 499 | + /* |
|
| 500 | 500 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
| 501 | 501 | FROM spotter_archive |
| 502 | 502 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -507,95 +507,95 @@ discard block |
||
| 507 | 507 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 508 | 508 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 509 | 509 | |
| 510 | - } else { |
|
| 511 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 512 | - /* |
|
| 510 | + } else { |
|
| 511 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
| 512 | + /* |
|
| 513 | 513 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
| 514 | 514 | FROM spotter_archive_output |
| 515 | 515 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 516 | 516 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 517 | 517 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 518 | 518 | */ |
| 519 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 519 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 520 | 520 | FROM spotter_archive_output |
| 521 | 521 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 522 | 522 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 523 | 523 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 524 | 524 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 525 | 525 | |
| 526 | - } |
|
| 527 | - //echo $query; |
|
| 528 | - try { |
|
| 529 | - $sth = $this->db->prepare($query); |
|
| 530 | - $sth->execute(); |
|
| 531 | - } catch(PDOException $e) { |
|
| 532 | - echo $e->getMessage(); |
|
| 533 | - die; |
|
| 534 | - } |
|
| 535 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 536 | - |
|
| 537 | - return $spotter_array; |
|
| 538 | - } |
|
| 526 | + } |
|
| 527 | + //echo $query; |
|
| 528 | + try { |
|
| 529 | + $sth = $this->db->prepare($query); |
|
| 530 | + $sth->execute(); |
|
| 531 | + } catch(PDOException $e) { |
|
| 532 | + echo $e->getMessage(); |
|
| 533 | + die; |
|
| 534 | + } |
|
| 535 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 536 | + |
|
| 537 | + return $spotter_array; |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | - * Gets count Live Spotter data |
|
| 542 | - * |
|
| 543 | - * @return Array the spotter information |
|
| 544 | - * |
|
| 545 | - */ |
|
| 546 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 547 | - { |
|
| 548 | - global $globalDBdriver, $globalLiveInterval; |
|
| 549 | - date_default_timezone_set('UTC'); |
|
| 550 | - |
|
| 551 | - $filter_query = ''; |
|
| 552 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | - } |
|
| 555 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 557 | - } |
|
| 558 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 560 | - } |
|
| 561 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | - if ($globalDBdriver == 'mysql') { |
|
| 541 | + * Gets count Live Spotter data |
|
| 542 | + * |
|
| 543 | + * @return Array the spotter information |
|
| 544 | + * |
|
| 545 | + */ |
|
| 546 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 547 | + { |
|
| 548 | + global $globalDBdriver, $globalLiveInterval; |
|
| 549 | + date_default_timezone_set('UTC'); |
|
| 550 | + |
|
| 551 | + $filter_query = ''; |
|
| 552 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | + } |
|
| 555 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 557 | + } |
|
| 558 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
| 560 | + } |
|
| 561 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | + if ($globalDBdriver == 'mysql') { |
|
| 567 | 567 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
| 568 | 568 | FROM spotter_archive l |
| 569 | 569 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 570 | - } else { |
|
| 570 | + } else { |
|
| 571 | 571 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 572 | - } |
|
| 573 | - //echo $query; |
|
| 574 | - try { |
|
| 575 | - $sth = $this->db->prepare($query); |
|
| 576 | - $sth->execute(); |
|
| 577 | - } catch(PDOException $e) { |
|
| 578 | - echo $e->getMessage(); |
|
| 579 | - die; |
|
| 580 | - } |
|
| 572 | + } |
|
| 573 | + //echo $query; |
|
| 574 | + try { |
|
| 575 | + $sth = $this->db->prepare($query); |
|
| 576 | + $sth->execute(); |
|
| 577 | + } catch(PDOException $e) { |
|
| 578 | + echo $e->getMessage(); |
|
| 579 | + die; |
|
| 580 | + } |
|
| 581 | 581 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 582 | 582 | $sth->closeCursor(); |
| 583 | - return $result['nb']; |
|
| 583 | + return $result['nb']; |
|
| 584 | 584 | |
| 585 | - } |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | |
| 589 | 589 | // Spotter_Archive_output |
| 590 | 590 | |
| 591 | - /** |
|
| 592 | - * Gets all the spotter information |
|
| 593 | - * |
|
| 594 | - * @return Array the spotter information |
|
| 595 | - * |
|
| 596 | - */ |
|
| 597 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 598 | - { |
|
| 591 | + /** |
|
| 592 | + * Gets all the spotter information |
|
| 593 | + * |
|
| 594 | + * @return Array the spotter information |
|
| 595 | + * |
|
| 596 | + */ |
|
| 597 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 598 | + { |
|
| 599 | 599 | global $globalTimezone, $globalDBdriver; |
| 600 | 600 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 601 | 601 | $Translation = new Translation($this->db); |
@@ -609,159 +609,159 @@ discard block |
||
| 609 | 609 | $filter_query = $this->getFilter($filters); |
| 610 | 610 | if ($q != "") |
| 611 | 611 | { |
| 612 | - if (!is_string($q)) |
|
| 613 | - { |
|
| 612 | + if (!is_string($q)) |
|
| 613 | + { |
|
| 614 | 614 | return false; |
| 615 | - } else { |
|
| 615 | + } else { |
|
| 616 | 616 | |
| 617 | 617 | $q_array = explode(" ", $q); |
| 618 | 618 | |
| 619 | 619 | foreach ($q_array as $q_item){ |
| 620 | - $additional_query .= " AND ("; |
|
| 621 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 622 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 623 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 624 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 625 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 626 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 627 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 628 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 630 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 631 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 632 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 633 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 634 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 635 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 636 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 637 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 638 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 639 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 640 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 641 | - $translate = $Translation->ident2icao($q_item); |
|
| 642 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 644 | - $additional_query .= ")"; |
|
| 645 | - } |
|
| 646 | - } |
|
| 620 | + $additional_query .= " AND ("; |
|
| 621 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 622 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 623 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 624 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 625 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 626 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 627 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 628 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 629 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 630 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 631 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 632 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 633 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 634 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 635 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 636 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
| 637 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 638 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 639 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 640 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
| 641 | + $translate = $Translation->ident2icao($q_item); |
|
| 642 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 643 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
| 644 | + $additional_query .= ")"; |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | if ($registration != "") |
| 650 | 650 | { |
| 651 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 652 | - if (!is_string($registration)) |
|
| 653 | - { |
|
| 651 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 652 | + if (!is_string($registration)) |
|
| 653 | + { |
|
| 654 | 654 | return false; |
| 655 | - } else { |
|
| 655 | + } else { |
|
| 656 | 656 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
| 657 | - } |
|
| 657 | + } |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if ($aircraft_icao != "") |
| 661 | 661 | { |
| 662 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 663 | - if (!is_string($aircraft_icao)) |
|
| 664 | - { |
|
| 662 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 663 | + if (!is_string($aircraft_icao)) |
|
| 664 | + { |
|
| 665 | 665 | return false; |
| 666 | - } else { |
|
| 666 | + } else { |
|
| 667 | 667 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 668 | - } |
|
| 668 | + } |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | if ($aircraft_manufacturer != "") |
| 672 | 672 | { |
| 673 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 674 | - if (!is_string($aircraft_manufacturer)) |
|
| 675 | - { |
|
| 673 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 674 | + if (!is_string($aircraft_manufacturer)) |
|
| 675 | + { |
|
| 676 | 676 | return false; |
| 677 | - } else { |
|
| 677 | + } else { |
|
| 678 | 678 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 679 | - } |
|
| 679 | + } |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | if ($highlights == "true") |
| 683 | 683 | { |
| 684 | - if (!is_string($highlights)) |
|
| 685 | - { |
|
| 684 | + if (!is_string($highlights)) |
|
| 685 | + { |
|
| 686 | 686 | return false; |
| 687 | - } else { |
|
| 687 | + } else { |
|
| 688 | 688 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | if ($airline_icao != "") |
| 693 | 693 | { |
| 694 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 695 | - if (!is_string($airline_icao)) |
|
| 696 | - { |
|
| 694 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 695 | + if (!is_string($airline_icao)) |
|
| 696 | + { |
|
| 697 | 697 | return false; |
| 698 | - } else { |
|
| 698 | + } else { |
|
| 699 | 699 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
| 700 | - } |
|
| 700 | + } |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | if ($airline_country != "") |
| 704 | 704 | { |
| 705 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 706 | - if (!is_string($airline_country)) |
|
| 707 | - { |
|
| 705 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 706 | + if (!is_string($airline_country)) |
|
| 707 | + { |
|
| 708 | 708 | return false; |
| 709 | - } else { |
|
| 709 | + } else { |
|
| 710 | 710 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
| 711 | - } |
|
| 711 | + } |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | if ($airline_type != "") |
| 715 | 715 | { |
| 716 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airline_type)) |
|
| 718 | - { |
|
| 716 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airline_type)) |
|
| 718 | + { |
|
| 719 | 719 | return false; |
| 720 | - } else { |
|
| 720 | + } else { |
|
| 721 | 721 | if ($airline_type == "passenger") |
| 722 | 722 | { |
| 723 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 723 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
| 724 | 724 | } |
| 725 | 725 | if ($airline_type == "cargo") |
| 726 | 726 | { |
| 727 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 727 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
| 728 | 728 | } |
| 729 | 729 | if ($airline_type == "military") |
| 730 | 730 | { |
| 731 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 731 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
| 732 | + } |
|
| 732 | 733 | } |
| 733 | - } |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ($airport != "") |
| 737 | 737 | { |
| 738 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($airport)) |
|
| 740 | - { |
|
| 738 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($airport)) |
|
| 740 | + { |
|
| 741 | 741 | return false; |
| 742 | - } else { |
|
| 742 | + } else { |
|
| 743 | 743 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | if ($airport_country != "") |
| 748 | 748 | { |
| 749 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 750 | - if (!is_string($airport_country)) |
|
| 751 | - { |
|
| 749 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 750 | + if (!is_string($airport_country)) |
|
| 751 | + { |
|
| 752 | 752 | return false; |
| 753 | - } else { |
|
| 753 | + } else { |
|
| 754 | 754 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 755 | - } |
|
| 755 | + } |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if ($callsign != "") |
| 759 | 759 | { |
| 760 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($callsign)) |
|
| 762 | - { |
|
| 760 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($callsign)) |
|
| 762 | + { |
|
| 763 | 763 | return false; |
| 764 | - } else { |
|
| 764 | + } else { |
|
| 765 | 765 | $translate = $Translation->ident2icao($callsign); |
| 766 | 766 | if ($translate != $callsign) { |
| 767 | 767 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -769,99 +769,99 @@ discard block |
||
| 769 | 769 | } else { |
| 770 | 770 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 771 | 771 | } |
| 772 | - } |
|
| 772 | + } |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | if ($owner != "") |
| 776 | 776 | { |
| 777 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 778 | - if (!is_string($owner)) |
|
| 779 | - { |
|
| 777 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 778 | + if (!is_string($owner)) |
|
| 779 | + { |
|
| 780 | 780 | return false; |
| 781 | - } else { |
|
| 781 | + } else { |
|
| 782 | 782 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
| 783 | - } |
|
| 783 | + } |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | if ($pilot_name != "") |
| 787 | 787 | { |
| 788 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 789 | - if (!is_string($pilot_name)) |
|
| 790 | - { |
|
| 788 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 789 | + if (!is_string($pilot_name)) |
|
| 790 | + { |
|
| 791 | 791 | return false; |
| 792 | - } else { |
|
| 792 | + } else { |
|
| 793 | 793 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | if ($pilot_id != "") |
| 798 | 798 | { |
| 799 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | - if (!is_string($pilot_id)) |
|
| 801 | - { |
|
| 799 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | + if (!is_string($pilot_id)) |
|
| 801 | + { |
|
| 802 | 802 | return false; |
| 803 | - } else { |
|
| 803 | + } else { |
|
| 804 | 804 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
| 805 | - } |
|
| 805 | + } |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | if ($departure_airport_route != "") |
| 809 | 809 | { |
| 810 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 811 | - if (!is_string($departure_airport_route)) |
|
| 812 | - { |
|
| 810 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 811 | + if (!is_string($departure_airport_route)) |
|
| 812 | + { |
|
| 813 | 813 | return false; |
| 814 | - } else { |
|
| 814 | + } else { |
|
| 815 | 815 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | if ($arrival_airport_route != "") |
| 820 | 820 | { |
| 821 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 822 | - if (!is_string($arrival_airport_route)) |
|
| 823 | - { |
|
| 821 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 822 | + if (!is_string($arrival_airport_route)) |
|
| 823 | + { |
|
| 824 | 824 | return false; |
| 825 | - } else { |
|
| 825 | + } else { |
|
| 826 | 826 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 827 | - } |
|
| 827 | + } |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | if ($altitude != "") |
| 831 | 831 | { |
| 832 | - $altitude_array = explode(",", $altitude); |
|
| 832 | + $altitude_array = explode(",", $altitude); |
|
| 833 | 833 | |
| 834 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 834 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 836 | 836 | |
| 837 | 837 | |
| 838 | - if ($altitude_array[1] != "") |
|
| 839 | - { |
|
| 838 | + if ($altitude_array[1] != "") |
|
| 839 | + { |
|
| 840 | 840 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 841 | 841 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 842 | 842 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 843 | - } else { |
|
| 843 | + } else { |
|
| 844 | 844 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 845 | 845 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 846 | - } |
|
| 846 | + } |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | if ($date_posted != "") |
| 850 | 850 | { |
| 851 | - $date_array = explode(",", $date_posted); |
|
| 851 | + $date_array = explode(",", $date_posted); |
|
| 852 | 852 | |
| 853 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 853 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 855 | 855 | |
| 856 | - if ($globalTimezone != '') { |
|
| 856 | + if ($globalTimezone != '') { |
|
| 857 | 857 | date_default_timezone_set($globalTimezone); |
| 858 | 858 | $datetime = new DateTime(); |
| 859 | 859 | $offset = $datetime->format('P'); |
| 860 | - } else $offset = '+00:00'; |
|
| 860 | + } else $offset = '+00:00'; |
|
| 861 | 861 | |
| 862 | 862 | |
| 863 | - if ($date_array[1] != "") |
|
| 864 | - { |
|
| 863 | + if ($date_array[1] != "") |
|
| 864 | + { |
|
| 865 | 865 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 866 | 866 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 867 | 867 | if ($globalDBdriver == 'mysql') { |
@@ -869,28 +869,28 @@ discard block |
||
| 869 | 869 | } else { |
| 870 | 870 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 871 | 871 | } |
| 872 | - } else { |
|
| 872 | + } else { |
|
| 873 | 873 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 874 | - if ($globalDBdriver == 'mysql') { |
|
| 874 | + if ($globalDBdriver == 'mysql') { |
|
| 875 | 875 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 876 | 876 | } else { |
| 877 | 877 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 878 | 878 | } |
| 879 | - } |
|
| 879 | + } |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | if ($limit != "") |
| 883 | 883 | { |
| 884 | - $limit_array = explode(",", $limit); |
|
| 884 | + $limit_array = explode(",", $limit); |
|
| 885 | 885 | |
| 886 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 886 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 888 | 888 | |
| 889 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 890 | - { |
|
| 889 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 890 | + { |
|
| 891 | 891 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 892 | 892 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 893 | - } |
|
| 893 | + } |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -921,33 +921,33 @@ discard block |
||
| 921 | 921 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
| 922 | 922 | |
| 923 | 923 | return $spotter_array; |
| 924 | - } |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | - public function deleteSpotterArchiveData() |
|
| 927 | - { |
|
| 926 | + public function deleteSpotterArchiveData() |
|
| 927 | + { |
|
| 928 | 928 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 929 | - date_default_timezone_set('UTC'); |
|
| 930 | - if ($globalDBdriver == 'mysql') { |
|
| 929 | + date_default_timezone_set('UTC'); |
|
| 930 | + if ($globalDBdriver == 'mysql') { |
|
| 931 | 931 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 932 | 932 | } else { |
| 933 | 933 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 934 | 934 | } |
| 935 | - try { |
|
| 936 | - $sth = $this->db->prepare($query); |
|
| 937 | - $sth->execute(); |
|
| 938 | - } catch(PDOException $e) { |
|
| 939 | - return "error"; |
|
| 940 | - } |
|
| 935 | + try { |
|
| 936 | + $sth = $this->db->prepare($query); |
|
| 937 | + $sth->execute(); |
|
| 938 | + } catch(PDOException $e) { |
|
| 939 | + return "error"; |
|
| 940 | + } |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - /** |
|
| 944 | - * Gets all the spotter information based on the callsign |
|
| 945 | - * |
|
| 946 | - * @return Array the spotter information |
|
| 947 | - * |
|
| 948 | - */ |
|
| 949 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 950 | - { |
|
| 943 | + /** |
|
| 944 | + * Gets all the spotter information based on the callsign |
|
| 945 | + * |
|
| 946 | + * @return Array the spotter information |
|
| 947 | + * |
|
| 948 | + */ |
|
| 949 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 950 | + { |
|
| 951 | 951 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 952 | 952 | |
| 953 | 953 | date_default_timezone_set('UTC'); |
@@ -959,35 +959,35 @@ discard block |
||
| 959 | 959 | |
| 960 | 960 | if ($ident != "") |
| 961 | 961 | { |
| 962 | - if (!is_string($ident)) |
|
| 963 | - { |
|
| 962 | + if (!is_string($ident)) |
|
| 963 | + { |
|
| 964 | 964 | return false; |
| 965 | - } else { |
|
| 965 | + } else { |
|
| 966 | 966 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
| 967 | 967 | $query_values = array(':ident' => $ident); |
| 968 | - } |
|
| 968 | + } |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | if ($limit != "") |
| 972 | 972 | { |
| 973 | - $limit_array = explode(",", $limit); |
|
| 973 | + $limit_array = explode(",", $limit); |
|
| 974 | 974 | |
| 975 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 975 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 977 | 977 | |
| 978 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 979 | - { |
|
| 978 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 979 | + { |
|
| 980 | 980 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 981 | 981 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 982 | - } |
|
| 982 | + } |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | if ($sort != "") |
| 986 | 986 | { |
| 987 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 988 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 987 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 988 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 989 | 989 | } else { |
| 990 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 990 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -995,17 +995,17 @@ discard block |
||
| 995 | 995 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 996 | 996 | |
| 997 | 997 | return $spotter_array; |
| 998 | - } |
|
| 998 | + } |
|
| 999 | 999 | |
| 1000 | 1000 | |
| 1001 | - /** |
|
| 1002 | - * Gets all the spotter information based on the owner |
|
| 1003 | - * |
|
| 1004 | - * @return Array the spotter information |
|
| 1005 | - * |
|
| 1006 | - */ |
|
| 1007 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1008 | - { |
|
| 1001 | + /** |
|
| 1002 | + * Gets all the spotter information based on the owner |
|
| 1003 | + * |
|
| 1004 | + * @return Array the spotter information |
|
| 1005 | + * |
|
| 1006 | + */ |
|
| 1007 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1008 | + { |
|
| 1009 | 1009 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1010 | 1010 | |
| 1011 | 1011 | date_default_timezone_set('UTC'); |
@@ -1018,35 +1018,35 @@ discard block |
||
| 1018 | 1018 | |
| 1019 | 1019 | if ($owner != "") |
| 1020 | 1020 | { |
| 1021 | - if (!is_string($owner)) |
|
| 1022 | - { |
|
| 1021 | + if (!is_string($owner)) |
|
| 1022 | + { |
|
| 1023 | 1023 | return false; |
| 1024 | - } else { |
|
| 1024 | + } else { |
|
| 1025 | 1025 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
| 1026 | 1026 | $query_values = array(':owner' => $owner); |
| 1027 | - } |
|
| 1027 | + } |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | if ($limit != "") |
| 1031 | 1031 | { |
| 1032 | - $limit_array = explode(",", $limit); |
|
| 1032 | + $limit_array = explode(",", $limit); |
|
| 1033 | 1033 | |
| 1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1036 | 1036 | |
| 1037 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1038 | - { |
|
| 1037 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1038 | + { |
|
| 1039 | 1039 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1040 | 1040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1041 | - } |
|
| 1041 | + } |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | if ($sort != "") |
| 1045 | 1045 | { |
| 1046 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1047 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1046 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1047 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1048 | 1048 | } else { |
| 1049 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1049 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1054,16 +1054,16 @@ discard block |
||
| 1054 | 1054 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1055 | 1055 | |
| 1056 | 1056 | return $spotter_array; |
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - /** |
|
| 1060 | - * Gets all the spotter information based on the pilot |
|
| 1061 | - * |
|
| 1062 | - * @return Array the spotter information |
|
| 1063 | - * |
|
| 1064 | - */ |
|
| 1065 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1066 | - { |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + /** |
|
| 1060 | + * Gets all the spotter information based on the pilot |
|
| 1061 | + * |
|
| 1062 | + * @return Array the spotter information |
|
| 1063 | + * |
|
| 1064 | + */ |
|
| 1065 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1066 | + { |
|
| 1067 | 1067 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1068 | 1068 | |
| 1069 | 1069 | date_default_timezone_set('UTC'); |
@@ -1082,24 +1082,24 @@ discard block |
||
| 1082 | 1082 | |
| 1083 | 1083 | if ($limit != "") |
| 1084 | 1084 | { |
| 1085 | - $limit_array = explode(",", $limit); |
|
| 1085 | + $limit_array = explode(",", $limit); |
|
| 1086 | 1086 | |
| 1087 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1087 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1089 | 1089 | |
| 1090 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1091 | - { |
|
| 1090 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1091 | + { |
|
| 1092 | 1092 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1093 | 1093 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1094 | - } |
|
| 1094 | + } |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | if ($sort != "") |
| 1098 | 1098 | { |
| 1099 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1100 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1099 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1100 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1101 | 1101 | } else { |
| 1102 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1102 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1107,16 +1107,16 @@ discard block |
||
| 1107 | 1107 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1108 | 1108 | |
| 1109 | 1109 | return $spotter_array; |
| 1110 | - } |
|
| 1111 | - |
|
| 1112 | - /** |
|
| 1113 | - * Gets all number of flight over countries |
|
| 1114 | - * |
|
| 1115 | - * @return Array the airline country list |
|
| 1116 | - * |
|
| 1117 | - */ |
|
| 1118 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | - { |
|
| 1110 | + } |
|
| 1111 | + |
|
| 1112 | + /** |
|
| 1113 | + * Gets all number of flight over countries |
|
| 1114 | + * |
|
| 1115 | + * @return Array the airline country list |
|
| 1116 | + * |
|
| 1117 | + */ |
|
| 1118 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1119 | + { |
|
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
| 1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
| 1126 | 1126 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1127 | 1127 | FROM countries c, spotter_archive s |
| 1128 | 1128 | WHERE c.iso2 = s.over_country "; |
| 1129 | - if ($olderthanmonths > 0) { |
|
| 1130 | - if ($globalDBdriver == 'mysql') { |
|
| 1129 | + if ($olderthanmonths > 0) { |
|
| 1130 | + if ($globalDBdriver == 'mysql') { |
|
| 1131 | 1131 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1132 | 1132 | } else { |
| 1133 | 1133 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1136 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1137 | 1137 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
| 1139 | 1139 | |
@@ -1146,23 +1146,23 @@ discard block |
||
| 1146 | 1146 | |
| 1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1148 | 1148 | { |
| 1149 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1150 | - $temp_array['flight_country'] = $row['name']; |
|
| 1151 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1152 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1153 | - $flight_array[] = $temp_array; |
|
| 1149 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1150 | + $temp_array['flight_country'] = $row['name']; |
|
| 1151 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1152 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1153 | + $flight_array[] = $temp_array; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | return $flight_array; |
| 1156 | - } |
|
| 1157 | - |
|
| 1158 | - /** |
|
| 1159 | - * Gets all number of flight over countries |
|
| 1160 | - * |
|
| 1161 | - * @return Array the airline country list |
|
| 1162 | - * |
|
| 1163 | - */ |
|
| 1164 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1165 | - { |
|
| 1156 | + } |
|
| 1157 | + |
|
| 1158 | + /** |
|
| 1159 | + * Gets all number of flight over countries |
|
| 1160 | + * |
|
| 1161 | + * @return Array the airline country list |
|
| 1162 | + * |
|
| 1163 | + */ |
|
| 1164 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1165 | + { |
|
| 1166 | 1166 | global $globalDBdriver; |
| 1167 | 1167 | /* |
| 1168 | 1168 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1172,14 +1172,14 @@ discard block |
||
| 1172 | 1172 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1173 | 1173 | FROM countries c, spotter_archive s, spotter_output o |
| 1174 | 1174 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
| 1175 | - if ($olderthanmonths > 0) { |
|
| 1176 | - if ($globalDBdriver == 'mysql') { |
|
| 1175 | + if ($olderthanmonths > 0) { |
|
| 1176 | + if ($globalDBdriver == 'mysql') { |
|
| 1177 | 1177 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1178 | 1178 | } else { |
| 1179 | 1179 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
| 1182 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1182 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1183 | 1183 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1184 | 1184 | if ($limit) $query .= " LIMIT 0,10"; |
| 1185 | 1185 | |
@@ -1192,24 +1192,24 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1194 | 1194 | { |
| 1195 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1196 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1197 | - $temp_array['flight_country'] = $row['name']; |
|
| 1198 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1199 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1200 | - $flight_array[] = $temp_array; |
|
| 1195 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1196 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1197 | + $temp_array['flight_country'] = $row['name']; |
|
| 1198 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1199 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1200 | + $flight_array[] = $temp_array; |
|
| 1201 | 1201 | } |
| 1202 | 1202 | return $flight_array; |
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - /** |
|
| 1206 | - * Gets last spotter information based on a particular callsign |
|
| 1207 | - * |
|
| 1208 | - * @return Array the spotter information |
|
| 1209 | - * |
|
| 1210 | - */ |
|
| 1211 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1212 | - { |
|
| 1203 | + } |
|
| 1204 | + |
|
| 1205 | + /** |
|
| 1206 | + * Gets last spotter information based on a particular callsign |
|
| 1207 | + * |
|
| 1208 | + * @return Array the spotter information |
|
| 1209 | + * |
|
| 1210 | + */ |
|
| 1211 | + public function getDateArchiveSpotterDataById($id,$date) |
|
| 1212 | + { |
|
| 1213 | 1213 | $Spotter = new Spotter($this->db); |
| 1214 | 1214 | date_default_timezone_set('UTC'); |
| 1215 | 1215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1217,16 +1217,16 @@ discard block |
||
| 1217 | 1217 | $date = date('c',$date); |
| 1218 | 1218 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1219 | 1219 | return $spotter_array; |
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * Gets all the spotter information based on a particular callsign |
|
| 1224 | - * |
|
| 1225 | - * @return Array the spotter information |
|
| 1226 | - * |
|
| 1227 | - */ |
|
| 1228 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1229 | - { |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * Gets all the spotter information based on a particular callsign |
|
| 1224 | + * |
|
| 1225 | + * @return Array the spotter information |
|
| 1226 | + * |
|
| 1227 | + */ |
|
| 1228 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1229 | + { |
|
| 1230 | 1230 | $Spotter = new Spotter($this->db); |
| 1231 | 1231 | date_default_timezone_set('UTC'); |
| 1232 | 1232 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1234,16 +1234,16 @@ discard block |
||
| 1234 | 1234 | $date = date('c',$date); |
| 1235 | 1235 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1236 | 1236 | return $spotter_array; |
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - /** |
|
| 1240 | - * Gets all the spotter information based on the airport |
|
| 1241 | - * |
|
| 1242 | - * @return Array the spotter information |
|
| 1243 | - * |
|
| 1244 | - */ |
|
| 1245 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1246 | - { |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + /** |
|
| 1240 | + * Gets all the spotter information based on the airport |
|
| 1241 | + * |
|
| 1242 | + * @return Array the spotter information |
|
| 1243 | + * |
|
| 1244 | + */ |
|
| 1245 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1246 | + { |
|
| 1247 | 1247 | global $global_query; |
| 1248 | 1248 | $Spotter = new Spotter($this->db); |
| 1249 | 1249 | date_default_timezone_set('UTC'); |
@@ -1254,35 +1254,35 @@ discard block |
||
| 1254 | 1254 | |
| 1255 | 1255 | if ($airport != "") |
| 1256 | 1256 | { |
| 1257 | - if (!is_string($airport)) |
|
| 1258 | - { |
|
| 1257 | + if (!is_string($airport)) |
|
| 1258 | + { |
|
| 1259 | 1259 | return false; |
| 1260 | - } else { |
|
| 1260 | + } else { |
|
| 1261 | 1261 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
| 1262 | 1262 | $query_values = array(':airport' => $airport); |
| 1263 | - } |
|
| 1263 | + } |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | if ($limit != "") |
| 1267 | 1267 | { |
| 1268 | - $limit_array = explode(",", $limit); |
|
| 1268 | + $limit_array = explode(",", $limit); |
|
| 1269 | 1269 | |
| 1270 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1270 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1272 | 1272 | |
| 1273 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1274 | - { |
|
| 1273 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1274 | + { |
|
| 1275 | 1275 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1276 | 1276 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1277 | - } |
|
| 1277 | + } |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | if ($sort != "") |
| 1281 | 1281 | { |
| 1282 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1283 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1282 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
| 1283 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1284 | 1284 | } else { |
| 1285 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1285 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1290,6 +1290,6 @@ discard block |
||
| 1290 | 1290 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
| 1291 | 1291 | |
| 1292 | 1292 | return $spotter_array; |
| 1293 | - } |
|
| 1293 | + } |
|
| 1294 | 1294 | } |
| 1295 | 1295 | ?> |
| 1296 | 1296 | \ No newline at end of file |
@@ -14,62 +14,62 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
| 23 | 23 | } else { |
| 24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if (isset($filter[0]['source'])) { |
| 28 | - $filters = array_merge($filters,$filter); |
|
| 28 | + $filters = array_merge($filters, $filter); |
|
| 29 | 29 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | - foreach($filters as $flt) { |
|
| 33 | + foreach ($filters as $flt) { |
|
| 34 | 34 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 35 | 35 | if ($flt['airlines'][0] != '') { |
| 36 | 36 | if (isset($flt['source'])) { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | 38 | } else { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | 71 | if ($filter['airlines'][0] != '') { |
| 72 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 78 | 78 | } |
| 79 | 79 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 83 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 86 | 86 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 87 | 87 | } |
| 88 | 88 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 89 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 89 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 90 | 90 | } |
| 91 | 91 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 92 | 92 | $filter_query_date = ''; |
@@ -112,41 +112,41 @@ discard block |
||
| 112 | 112 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 116 | 116 | } |
| 117 | 117 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 118 | 118 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 119 | 119 | if ($filter_query_where != '') { |
| 120 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 120 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 121 | 121 | } |
| 122 | 122 | $filter_query = $filter_query_join.$filter_query_where; |
| 123 | 123 | return $filter_query; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Spotter_archive |
| 127 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 127 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 128 | 128 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Spotter = new Spotter($this->db); |
| 131 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | - if ($airline_type === NULL) $airline_type =''; |
|
| 135 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 136 | 136 | |
| 137 | 137 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 138 | 138 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 139 | 139 | |
| 140 | 140 | // Route is not added in spotter_archive |
| 141 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 141 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 142 | 142 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 143 | 143 | |
| 144 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 144 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 145 | 145 | try { |
| 146 | 146 | $sth = $this->db->prepare($query); |
| 147 | 147 | $sth->execute($query_values); |
| 148 | 148 | $sth->closeCursor(); |
| 149 | - } catch(PDOException $e) { |
|
| 149 | + } catch (PDOException $e) { |
|
| 150 | 150 | return "error : ".$e->getMessage(); |
| 151 | 151 | } |
| 152 | 152 | return "success"; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 168 | 168 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 169 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 169 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 170 | 170 | |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 172 | 172 | |
| 173 | 173 | return $spotter_array; |
| 174 | 174 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 188 | 188 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 189 | 189 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 190 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 190 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 191 | 191 | |
| 192 | 192 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 193 | 193 | /* |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 202 | 202 | */ |
| 203 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 203 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 204 | 204 | |
| 205 | 205 | return $spotter_array; |
| 206 | 206 | } |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | date_default_timezone_set('UTC'); |
| 217 | 217 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 218 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 218 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 219 | 219 | |
| 220 | 220 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 221 | 221 | |
| 222 | 222 | try { |
| 223 | 223 | $sth = $this->db->prepare($query); |
| 224 | 224 | $sth->execute(array(':id' => $id)); |
| 225 | - } catch(PDOException $e) { |
|
| 225 | + } catch (PDOException $e) { |
|
| 226 | 226 | echo $e->getMessage(); |
| 227 | 227 | die; |
| 228 | 228 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | date_default_timezone_set('UTC'); |
| 243 | 243 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 244 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 244 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 245 | 245 | |
| 246 | 246 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 247 | 247 | |
| 248 | 248 | try { |
| 249 | 249 | $sth = $this->db->prepare($query); |
| 250 | 250 | $sth->execute(array(':id' => $id)); |
| 251 | - } catch(PDOException $e) { |
|
| 251 | + } catch (PDOException $e) { |
|
| 252 | 252 | echo $e->getMessage(); |
| 253 | 253 | die; |
| 254 | 254 | } |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | date_default_timezone_set('UTC'); |
| 271 | 271 | |
| 272 | 272 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 273 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 273 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 274 | 274 | |
| 275 | 275 | try { |
| 276 | 276 | $sth = $this->db->prepare($query); |
| 277 | 277 | $sth->execute(array(':ident' => $ident)); |
| 278 | - } catch(PDOException $e) { |
|
| 278 | + } catch (PDOException $e) { |
|
| 279 | 279 | echo $e->getMessage(); |
| 280 | 280 | die; |
| 281 | 281 | } |
@@ -296,12 +296,12 @@ discard block |
||
| 296 | 296 | date_default_timezone_set('UTC'); |
| 297 | 297 | |
| 298 | 298 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 299 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 299 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 300 | 300 | |
| 301 | 301 | try { |
| 302 | 302 | $sth = $this->db->prepare($query); |
| 303 | 303 | $sth->execute(array(':id' => $id)); |
| 304 | - } catch(PDOException $e) { |
|
| 304 | + } catch (PDOException $e) { |
|
| 305 | 305 | echo $e->getMessage(); |
| 306 | 306 | die; |
| 307 | 307 | } |
@@ -322,12 +322,12 @@ discard block |
||
| 322 | 322 | date_default_timezone_set('UTC'); |
| 323 | 323 | |
| 324 | 324 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 325 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 325 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 326 | 326 | |
| 327 | 327 | try { |
| 328 | 328 | $sth = $this->db->prepare($query); |
| 329 | 329 | $sth->execute(array(':id' => $id)); |
| 330 | - } catch(PDOException $e) { |
|
| 330 | + } catch (PDOException $e) { |
|
| 331 | 331 | echo $e->getMessage(); |
| 332 | 332 | die; |
| 333 | 333 | } |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | date_default_timezone_set('UTC'); |
| 350 | 350 | |
| 351 | 351 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 352 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 352 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 353 | 353 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 354 | 354 | |
| 355 | 355 | try { |
| 356 | 356 | $sth = $this->db->prepare($query); |
| 357 | 357 | $sth->execute(array(':ident' => $ident)); |
| 358 | - } catch(PDOException $e) { |
|
| 358 | + } catch (PDOException $e) { |
|
| 359 | 359 | echo $e->getMessage(); |
| 360 | 360 | die; |
| 361 | 361 | } |
@@ -372,13 +372,13 @@ discard block |
||
| 372 | 372 | * @return Array the spotter information |
| 373 | 373 | * |
| 374 | 374 | */ |
| 375 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 375 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 376 | 376 | { |
| 377 | 377 | $Spotter = new Spotter($this->db); |
| 378 | 378 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 379 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 379 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 380 | 380 | |
| 381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 381 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 382 | 382 | |
| 383 | 383 | return $spotter_array; |
| 384 | 384 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | try { |
| 395 | 395 | $sth = $this->db->prepare($query); |
| 396 | 396 | $sth->execute(); |
| 397 | - } catch(PDOException $e) { |
|
| 397 | + } catch (PDOException $e) { |
|
| 398 | 398 | echo $e->getMessage(); |
| 399 | 399 | die; |
| 400 | 400 | } |
@@ -406,24 +406,24 @@ discard block |
||
| 406 | 406 | * @return Array the spotter information |
| 407 | 407 | * |
| 408 | 408 | */ |
| 409 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 409 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 410 | 410 | { |
| 411 | 411 | global $globalDBdriver, $globalLiveInterval; |
| 412 | 412 | date_default_timezone_set('UTC'); |
| 413 | 413 | |
| 414 | 414 | $filter_query = ''; |
| 415 | 415 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 416 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 416 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 417 | 417 | } |
| 418 | 418 | // Use spotter_output also ? |
| 419 | 419 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 420 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 421 | 421 | } |
| 422 | 422 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 423 | 423 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 424 | 424 | } |
| 425 | 425 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 426 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 426 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 443 | 443 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 444 | 444 | */ |
| 445 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 445 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | 446 | FROM spotter_archive |
| 447 | 447 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 448 | 448 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 449 | 449 | '.$filter_query.' ORDER BY flightaware_id'; |
| 450 | 450 | } else { |
| 451 | 451 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 452 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 452 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 453 | 453 | FROM spotter_archive |
| 454 | 454 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 455 | 455 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | try { |
| 460 | 460 | $sth = $this->db->prepare($query); |
| 461 | 461 | $sth->execute(); |
| 462 | - } catch(PDOException $e) { |
|
| 462 | + } catch (PDOException $e) { |
|
| 463 | 463 | echo $e->getMessage(); |
| 464 | 464 | die; |
| 465 | 465 | } |
@@ -474,24 +474,24 @@ discard block |
||
| 474 | 474 | * @return Array the spotter information |
| 475 | 475 | * |
| 476 | 476 | */ |
| 477 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 477 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 478 | 478 | { |
| 479 | 479 | global $globalDBdriver, $globalLiveInterval; |
| 480 | 480 | date_default_timezone_set('UTC'); |
| 481 | 481 | |
| 482 | 482 | $filter_query = ''; |
| 483 | 483 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 484 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 484 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 485 | 485 | } |
| 486 | 486 | // Should use spotter_output also ? |
| 487 | 487 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 488 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 488 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 489 | 489 | } |
| 490 | 490 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 491 | 491 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 492 | 492 | } |
| 493 | 493 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 494 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 494 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | FROM spotter_archive |
| 502 | 502 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 503 | 503 | */ |
| 504 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 504 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 505 | 505 | FROM spotter_archive_output |
| 506 | 506 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 507 | 507 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 517 | 517 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 518 | 518 | */ |
| 519 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 519 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 520 | 520 | FROM spotter_archive_output |
| 521 | 521 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 522 | 522 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | try { |
| 529 | 529 | $sth = $this->db->prepare($query); |
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | echo $e->getMessage(); |
| 533 | 533 | die; |
| 534 | 534 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @return Array the spotter information |
| 544 | 544 | * |
| 545 | 545 | */ |
| 546 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalDBdriver, $globalLiveInterval; |
| 549 | 549 | date_default_timezone_set('UTC'); |
| 550 | 550 | |
| 551 | 551 | $filter_query = ''; |
| 552 | 552 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 556 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 560 | 560 | } |
| 561 | 561 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | try { |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | echo $e->getMessage(); |
| 579 | 579 | die; |
| 580 | 580 | } |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | * @return Array the spotter information |
| 595 | 595 | * |
| 596 | 596 | */ |
| 597 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 597 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 598 | 598 | { |
| 599 | 599 | global $globalTimezone, $globalDBdriver; |
| 600 | 600 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $q_array = explode(" ", $q); |
| 618 | 618 | |
| 619 | - foreach ($q_array as $q_item){ |
|
| 619 | + foreach ($q_array as $q_item) { |
|
| 620 | 620 | $additional_query .= " AND ("; |
| 621 | 621 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 622 | 622 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | if ($registration != "") |
| 650 | 650 | { |
| 651 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 651 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 652 | 652 | if (!is_string($registration)) |
| 653 | 653 | { |
| 654 | 654 | return false; |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | if ($aircraft_icao != "") |
| 661 | 661 | { |
| 662 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 662 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 663 | 663 | if (!is_string($aircraft_icao)) |
| 664 | 664 | { |
| 665 | 665 | return false; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($aircraft_manufacturer != "") |
| 672 | 672 | { |
| 673 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 673 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($aircraft_manufacturer)) |
| 675 | 675 | { |
| 676 | 676 | return false; |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | if ($airline_icao != "") |
| 693 | 693 | { |
| 694 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 694 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 695 | 695 | if (!is_string($airline_icao)) |
| 696 | 696 | { |
| 697 | 697 | return false; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | if ($airline_country != "") |
| 704 | 704 | { |
| 705 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 705 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 706 | 706 | if (!is_string($airline_country)) |
| 707 | 707 | { |
| 708 | 708 | return false; |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_type != "") |
| 715 | 715 | { |
| 716 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_type)) |
| 718 | 718 | { |
| 719 | 719 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airport != "") |
| 737 | 737 | { |
| 738 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 738 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airport)) |
| 740 | 740 | { |
| 741 | 741 | return false; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ($airport_country != "") |
| 748 | 748 | { |
| 749 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 749 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 750 | 750 | if (!is_string($airport_country)) |
| 751 | 751 | { |
| 752 | 752 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($callsign != "") |
| 759 | 759 | { |
| 760 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 760 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($callsign)) |
| 762 | 762 | { |
| 763 | 763 | return false; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $translate = $Translation->ident2icao($callsign); |
| 766 | 766 | if ($translate != $callsign) { |
| 767 | 767 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 768 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 768 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 769 | 769 | } else { |
| 770 | 770 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 771 | 771 | } |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | if ($owner != "") |
| 776 | 776 | { |
| 777 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 777 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 778 | 778 | if (!is_string($owner)) |
| 779 | 779 | { |
| 780 | 780 | return false; |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | if ($pilot_name != "") |
| 787 | 787 | { |
| 788 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 788 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 789 | 789 | if (!is_string($pilot_name)) |
| 790 | 790 | { |
| 791 | 791 | return false; |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($pilot_id != "") |
| 798 | 798 | { |
| 799 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 799 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | 800 | if (!is_string($pilot_id)) |
| 801 | 801 | { |
| 802 | 802 | return false; |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($departure_airport_route != "") |
| 809 | 809 | { |
| 810 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 810 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($departure_airport_route)) |
| 812 | 812 | { |
| 813 | 813 | return false; |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($arrival_airport_route != "") |
| 820 | 820 | { |
| 821 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 821 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 822 | 822 | if (!is_string($arrival_airport_route)) |
| 823 | 823 | { |
| 824 | 824 | return false; |
@@ -831,8 +831,8 @@ discard block |
||
| 831 | 831 | { |
| 832 | 832 | $altitude_array = explode(",", $altitude); |
| 833 | 833 | |
| 834 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 834 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 836 | 836 | |
| 837 | 837 | |
| 838 | 838 | if ($altitude_array[1] != "") |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | { |
| 851 | 851 | $date_array = explode(",", $date_posted); |
| 852 | 852 | |
| 853 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 853 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 854 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 855 | 855 | |
| 856 | 856 | if ($globalTimezone != '') { |
| 857 | 857 | date_default_timezone_set($globalTimezone); |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | { |
| 884 | 884 | $limit_array = explode(",", $limit); |
| 885 | 885 | |
| 886 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 886 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 888 | 888 | |
| 889 | 889 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 890 | 890 | { |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | |
| 897 | 897 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 898 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 899 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 898 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 899 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 900 | 900 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 901 | 901 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 902 | 902 | } else { |
@@ -913,12 +913,12 @@ discard block |
||
| 913 | 913 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 916 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 917 | 917 | WHERE spotter_archive_output.ident <> '' |
| 918 | 918 | ".$additional_query." |
| 919 | 919 | ".$filter_query.$orderby_query; |
| 920 | 920 | } |
| 921 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 921 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 922 | 922 | |
| 923 | 923 | return $spotter_array; |
| 924 | 924 | } |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | try { |
| 936 | 936 | $sth = $this->db->prepare($query); |
| 937 | 937 | $sth->execute(); |
| 938 | - } catch(PDOException $e) { |
|
| 938 | + } catch (PDOException $e) { |
|
| 939 | 939 | return "error"; |
| 940 | 940 | } |
| 941 | 941 | } |
@@ -972,8 +972,8 @@ discard block |
||
| 972 | 972 | { |
| 973 | 973 | $limit_array = explode(",", $limit); |
| 974 | 974 | |
| 975 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 975 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 977 | 977 | |
| 978 | 978 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 979 | 979 | { |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $query_values = array(); |
| 1015 | 1015 | $limit_query = ''; |
| 1016 | 1016 | $additional_query = ''; |
| 1017 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ($owner != "") |
| 1020 | 1020 | { |
@@ -1031,8 +1031,8 @@ discard block |
||
| 1031 | 1031 | { |
| 1032 | 1032 | $limit_array = explode(",", $limit); |
| 1033 | 1033 | |
| 1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1036 | 1036 | |
| 1037 | 1037 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1038 | 1038 | { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | $query_values = array(); |
| 1073 | 1073 | $limit_query = ''; |
| 1074 | 1074 | $additional_query = ''; |
| 1075 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1075 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1076 | 1076 | |
| 1077 | 1077 | if ($pilot != "") |
| 1078 | 1078 | { |
@@ -1084,8 +1084,8 @@ discard block |
||
| 1084 | 1084 | { |
| 1085 | 1085 | $limit_array = explode(",", $limit); |
| 1086 | 1086 | |
| 1087 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1087 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1089 | 1089 | |
| 1090 | 1090 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1091 | 1091 | { |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return Array the airline country list |
| 1116 | 1116 | * |
| 1117 | 1117 | */ |
| 1118 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1118 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | $flight_array = array(); |
| 1145 | 1145 | $temp_array = array(); |
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | $temp_array['flight_count'] = $row['nb']; |
| 1150 | 1150 | $temp_array['flight_country'] = $row['name']; |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | * @return Array the airline country list |
| 1162 | 1162 | * |
| 1163 | 1163 | */ |
| 1164 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1164 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1165 | 1165 | { |
| 1166 | 1166 | global $globalDBdriver; |
| 1167 | 1167 | /* |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $flight_array = array(); |
| 1191 | 1191 | $temp_array = array(); |
| 1192 | 1192 | |
| 1193 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1193 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1196 | 1196 | $temp_array['flight_count'] = $row['nb']; |
@@ -1208,14 +1208,14 @@ discard block |
||
| 1208 | 1208 | * @return Array the spotter information |
| 1209 | 1209 | * |
| 1210 | 1210 | */ |
| 1211 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1211 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1212 | 1212 | { |
| 1213 | 1213 | $Spotter = new Spotter($this->db); |
| 1214 | 1214 | date_default_timezone_set('UTC'); |
| 1215 | 1215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1216 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1217 | - $date = date('c',$date); |
|
| 1218 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1216 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1217 | + $date = date('c', $date); |
|
| 1218 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1219 | 1219 | return $spotter_array; |
| 1220 | 1220 | } |
| 1221 | 1221 | |
@@ -1225,14 +1225,14 @@ discard block |
||
| 1225 | 1225 | * @return Array the spotter information |
| 1226 | 1226 | * |
| 1227 | 1227 | */ |
| 1228 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1228 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $Spotter = new Spotter($this->db); |
| 1231 | 1231 | date_default_timezone_set('UTC'); |
| 1232 | 1232 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1233 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1234 | - $date = date('c',$date); |
|
| 1235 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1233 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1234 | + $date = date('c', $date); |
|
| 1235 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1236 | 1236 | return $spotter_array; |
| 1237 | 1237 | } |
| 1238 | 1238 | |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | * @return Array the spotter information |
| 1243 | 1243 | * |
| 1244 | 1244 | */ |
| 1245 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1245 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1246 | 1246 | { |
| 1247 | 1247 | global $global_query; |
| 1248 | 1248 | $Spotter = new Spotter($this->db); |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | $query_values = array(); |
| 1251 | 1251 | $limit_query = ''; |
| 1252 | 1252 | $additional_query = ''; |
| 1253 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1253 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1254 | 1254 | |
| 1255 | 1255 | if ($airport != "") |
| 1256 | 1256 | { |
@@ -1267,8 +1267,8 @@ discard block |
||
| 1267 | 1267 | { |
| 1268 | 1268 | $limit_array = explode(",", $limit); |
| 1269 | 1269 | |
| 1270 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1270 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1272 | 1272 | |
| 1273 | 1273 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1274 | 1274 | { |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | try { |
| 983 | 983 | $sth = $this->db->prepare($query); |
| 984 | 984 | $sth->execute($query_values); |
| 985 | - } catch(PDOException $e) { |
|
| 985 | + } catch (PDOException $e) { |
|
| 986 | 986 | echo "error : ".$e->getMessage(); |
| 987 | 987 | } |
| 988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1000,19 +1000,19 @@ discard block |
||
| 1000 | 1000 | try { |
| 1001 | 1001 | $sth = $this->db->prepare($query); |
| 1002 | 1002 | $sth->execute($query_values); |
| 1003 | - } catch(PDOException $e) { |
|
| 1003 | + } catch (PDOException $e) { |
|
| 1004 | 1004 | echo "error : ".$e->getMessage(); |
| 1005 | 1005 | } |
| 1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1007 | 1007 | return $all; |
| 1008 | 1008 | } |
| 1009 | 1009 | public function getAllNOTAMtext() { |
| 1010 | - $query = 'SELECT full_notam FROM notam'; |
|
| 1010 | + $query = 'SELECT full_notam FROM notam'; |
|
| 1011 | 1011 | $query_values = array(); |
| 1012 | 1012 | try { |
| 1013 | 1013 | $sth = $this->db->prepare($query); |
| 1014 | 1014 | $sth->execute($query_values); |
| 1015 | - } catch(PDOException $e) { |
|
| 1015 | + } catch (PDOException $e) { |
|
| 1016 | 1016 | echo "error : ".$e->getMessage(); |
| 1017 | 1017 | } |
| 1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1021,13 +1021,13 @@ discard block |
||
| 1021 | 1021 | public function createNOTAMtextFile($filename) { |
| 1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); |
| 1023 | 1023 | $notamtext = ''; |
| 1024 | - foreach($allnotam_result as $notam) { |
|
| 1024 | + foreach ($allnotam_result as $notam) { |
|
| 1025 | 1025 | $notamtext .= '%%'."\n"; |
| 1026 | 1026 | $notamtext .= $notam['full_notam']; |
| 1027 | 1027 | $notamtext .= "\n".'%%'."\n"; |
| 1028 | 1028 | } |
| 1029 | 1029 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
| 1030 | - file_put_contents($filename,$notamtext); |
|
| 1030 | + file_put_contents($filename, $notamtext); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | public function parseNOTAMtextFile($filename) { |
| 1033 | 1033 | $data = file_get_contents($filename); |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | try { |
| 1049 | 1049 | $sth = $this->db->prepare($query); |
| 1050 | 1050 | $sth->execute($query_values); |
| 1051 | - } catch(PDOException $e) { |
|
| 1051 | + } catch (PDOException $e) { |
|
| 1052 | 1052 | echo "error : ".$e->getMessage(); |
| 1053 | 1053 | } |
| 1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | public function getAllNOTAMbyCoord($coord) { |
| 1058 | 1058 | global $globalDBdriver; |
| 1059 | 1059 | if (is_array($coord)) { |
| 1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | 1064 | if ($minlat > $maxlat) { |
| 1065 | 1065 | $tmplat = $minlat; |
| 1066 | 1066 | $minlat = $maxlat; |
@@ -1082,19 +1082,19 @@ discard block |
||
| 1082 | 1082 | try { |
| 1083 | 1083 | $sth = $this->db->prepare($query); |
| 1084 | 1084 | $sth->execute($query_values); |
| 1085 | - } catch(PDOException $e) { |
|
| 1085 | + } catch (PDOException $e) { |
|
| 1086 | 1086 | echo "error : ".$e->getMessage(); |
| 1087 | 1087 | } |
| 1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1089 | 1089 | return $all; |
| 1090 | 1090 | } |
| 1091 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
| 1091 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
| 1092 | 1092 | global $globalDBdriver; |
| 1093 | 1093 | if (is_array($coord)) { |
| 1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1098 | 1098 | } else return array(); |
| 1099 | 1099 | if ($globalDBdriver == 'mysql') { |
| 1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | try { |
| 1107 | 1107 | $sth = $this->db->prepare($query); |
| 1108 | 1108 | $sth->execute($query_values); |
| 1109 | - } catch(PDOException $e) { |
|
| 1109 | + } catch (PDOException $e) { |
|
| 1110 | 1110 | echo "error : ".$e->getMessage(); |
| 1111 | 1111 | } |
| 1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | try { |
| 1119 | 1119 | $sth = $this->db->prepare($query); |
| 1120 | 1120 | $sth->execute($query_values); |
| 1121 | - } catch(PDOException $e) { |
|
| 1121 | + } catch (PDOException $e) { |
|
| 1122 | 1122 | return "error : ".$e->getMessage(); |
| 1123 | 1123 | } |
| 1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
| 1126 | 1126 | else return array(); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
|
| 1129 | + public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { |
|
| 1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
| 1131 | - $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
|
| 1131 | + $query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); |
|
| 1132 | 1132 | try { |
| 1133 | 1133 | $sth = $this->db->prepare($query); |
| 1134 | 1134 | $sth->execute($query_values); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | try { |
| 1144 | 1144 | $sth = $this->db->prepare($query); |
| 1145 | 1145 | $sth->execute($query_values); |
| 1146 | - } catch(PDOException $e) { |
|
| 1146 | + } catch (PDOException $e) { |
|
| 1147 | 1147 | return "error : ".$e->getMessage(); |
| 1148 | 1148 | } |
| 1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $sth = $this->db->prepare($query); |
| 1160 | 1160 | $sth->execute($query_values); |
| 1161 | - } catch(PDOException $e) { |
|
| 1161 | + } catch (PDOException $e) { |
|
| 1162 | 1162 | return "error : ".$e->getMessage(); |
| 1163 | 1163 | } |
| 1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | try { |
| 1169 | 1169 | $sth = $this->db->prepare($query); |
| 1170 | 1170 | $sth->execute($query_values); |
| 1171 | - } catch(PDOException $e) { |
|
| 1171 | + } catch (PDOException $e) { |
|
| 1172 | 1172 | return "error : ".$e->getMessage(); |
| 1173 | 1173 | } |
| 1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | try { |
| 1178 | 1178 | $sth = $this->db->prepare($query); |
| 1179 | 1179 | $sth->execute(); |
| 1180 | - } catch(PDOException $e) { |
|
| 1180 | + } catch (PDOException $e) { |
|
| 1181 | 1181 | return "error : ".$e->getMessage(); |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | try { |
| 1187 | 1187 | $sth = $this->db->prepare($query); |
| 1188 | 1188 | $sth->execute(); |
| 1189 | - } catch(PDOException $e) { |
|
| 1189 | + } catch (PDOException $e) { |
|
| 1190 | 1190 | return "error : ".$e->getMessage(); |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | public function updateNOTAM() { |
| 1195 | 1195 | global $globalNOTAMAirports; |
| 1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
| 1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
| 1198 | - $airport_icao = implode(',',$airport); |
|
| 1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
| 1198 | + $airport_icao = implode(',', $airport); |
|
| 1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1200 | 1200 | if (count($alldata) > 0) { |
| 1201 | 1201 | foreach ($alldata as $initial_data) { |
| 1202 | 1202 | $data = $this->parse($initial_data); |
| 1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | foreach ($alldata as $initial_data) { |
| 1215 | 1215 | $data = $this->parse($initial_data); |
| 1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | } |
@@ -1223,12 +1223,12 @@ discard block |
||
| 1223 | 1223 | global $globalTransaction; |
| 1224 | 1224 | $Spotter = new Spotter($this->db); |
| 1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); |
| 1226 | - foreach (array_chunk($allairports,20) as $airport) { |
|
| 1226 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
| 1227 | 1227 | $airports_icao = array(); |
| 1228 | - foreach($airport as $icao) { |
|
| 1228 | + foreach ($airport as $icao) { |
|
| 1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
| 1230 | 1230 | } |
| 1231 | - $airport_icao = implode(',',$airports_icao); |
|
| 1231 | + $airport_icao = implode(',', $airports_icao); |
|
| 1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); |
| 1234 | 1234 | if (count($alldata) > 0) { |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | if (count($notamref) == 0) { |
| 1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
| 1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | date_default_timezone_set("UTC"); |
| 1256 | 1256 | $Common = new Common(); |
| 1257 | 1257 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
| 1258 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1258 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1259 | 1259 | $data = $Common->getData($url); |
| 1260 | 1260 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1261 | 1261 | //print_r($matches); |
@@ -1272,9 +1272,9 @@ discard block |
||
| 1272 | 1272 | $result['permanent'] = ''; |
| 1273 | 1273 | $result['date_begin'] = NULL; |
| 1274 | 1274 | $result['date_end'] = NULL; |
| 1275 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
| 1275 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
| 1276 | 1276 | //echo $data."\n"; |
| 1277 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
| 1277 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
| 1278 | 1278 | //print_r($data); |
| 1279 | 1279 | $q = false; |
| 1280 | 1280 | $a = false; |
@@ -1283,9 +1283,9 @@ discard block |
||
| 1283 | 1283 | $e = false; |
| 1284 | 1284 | foreach ($data as $line) { |
| 1285 | 1285 | $line = trim($line); |
| 1286 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
| 1287 | - $line = str_replace(' ','',$line); |
|
| 1288 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
| 1286 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
| 1287 | + $line = str_replace(' ', '', $line); |
|
| 1288 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
| 1289 | 1289 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
| 1290 | 1290 | //print_r($matches); |
| 1291 | 1291 | $result['fir'] = $matches[1]; |
@@ -1331,9 +1331,9 @@ discard block |
||
| 1331 | 1331 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
| 1332 | 1332 | $result['lower_limit'] = $matches[6]; |
| 1333 | 1333 | $result['upper_limit'] = $matches[7]; |
| 1334 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
| 1334 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
| 1335 | 1335 | if ($matches[9] == 'S') $latitude = -$latitude; |
| 1336 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
| 1336 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
| 1337 | 1337 | if ($matches[11] == 'W') $longitude = -$longitude; |
| 1338 | 1338 | $result['latitude'] = $latitude; |
| 1339 | 1339 | $result['longitude'] = $longitude; |
@@ -1345,24 +1345,24 @@ discard block |
||
| 1345 | 1345 | echo "Can't parse : ".$line."\n"; |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1348 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
| 1349 | 1349 | $result['icao'] = $matches[2]; |
| 1350 | 1350 | $a = true; |
| 1351 | 1351 | } |
| 1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1352 | + elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) { |
|
| 1353 | 1353 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
| 1354 | 1354 | else $year = '20'.$matches[2]; |
| 1355 | 1355 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1356 | 1356 | $b = true; |
| 1357 | 1357 | } |
| 1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1358 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) { |
|
| 1359 | 1359 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1360 | 1360 | else $year = '20'.$matches[2]; |
| 1361 | 1361 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1362 | 1362 | $result['permanent'] = 0; |
| 1363 | 1363 | $c = true; |
| 1364 | 1364 | } |
| 1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1365 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
| 1366 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1367 | 1367 | else $year = '20'.$matches[2]; |
| 1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | else $result['permanent'] = 0; |
| 1373 | 1373 | $c = true; |
| 1374 | 1374 | } |
| 1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1375 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
| 1376 | 1376 | $result['date_end'] = '2030/12/20 12:00'; |
| 1377 | 1377 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
| 1378 | 1378 | else $result['estimated'] = 0; |
@@ -1380,20 +1380,20 @@ discard block |
||
| 1380 | 1380 | else $result['permanent'] = 0; |
| 1381 | 1381 | $c = true; |
| 1382 | 1382 | } |
| 1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1383 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
| 1384 | 1384 | $rtext = array(); |
| 1385 | - $text = explode(' ',$matches[2]); |
|
| 1385 | + $text = explode(' ', $matches[2]); |
|
| 1386 | 1386 | foreach ($text as $word) { |
| 1387 | 1387 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
| 1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1388 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
| 1389 | 1389 | else $rtext[] = $word; |
| 1390 | 1390 | } |
| 1391 | - $result['text'] = implode(' ',$rtext); |
|
| 1391 | + $result['text'] = implode(' ', $rtext); |
|
| 1392 | 1392 | $e = true; |
| 1393 | 1393 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
| 1394 | 1394 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
| 1395 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
| 1396 | - $text = explode(' ',$line); |
|
| 1395 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
| 1396 | + $text = explode(' ', $line); |
|
| 1397 | 1397 | $result['ref'] = $text[0]; |
| 1398 | 1398 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
| 1399 | 1399 | if ($matches[1] == 'NOTAMC') { |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | * @param String $date get data for a date |
| 29 | 29 | * @return Array Return Accidents data in array |
| 30 | 30 | */ |
| 31 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
| 31 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
| 32 | 32 | global $globalURL, $globalDBdriver; |
| 33 | 33 | $Image = new Image($this->db); |
| 34 | 34 | $Spotter = new Spotter($this->db); |
| 35 | 35 | $Translation = new Translation($this->db); |
| 36 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 36 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 37 | 37 | date_default_timezone_set('UTC'); |
| 38 | 38 | $result = array(); |
| 39 | 39 | $limit_query = ''; |
| 40 | 40 | if ($limit != "") |
| 41 | 41 | { |
| 42 | 42 | $limit_array = explode(",", $limit); |
| 43 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 44 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 43 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 44 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 45 | 45 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 46 | 46 | { |
| 47 | 47 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -50,29 +50,29 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if ($type != '') { |
| 52 | 52 | if ($date != '') { |
| 53 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 53 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 54 | 54 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 55 | 55 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 56 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 57 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
| 56 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 57 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
| 58 | 58 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 59 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 60 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
| 59 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 60 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
| 61 | 61 | if ($globalDBdriver == 'mysql') { |
| 62 | 62 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 63 | 63 | } else { |
| 64 | 64 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 65 | 65 | } |
| 66 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 66 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 67 | 67 | } else { |
| 68 | 68 | $date = $date.'%'; |
| 69 | 69 | if ($globalDBdriver == 'mysql') { |
| 70 | 70 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 71 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 71 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 72 | 72 | } else { |
| 73 | 73 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 74 | 74 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 75 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 75 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } else { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | } else { |
| 84 | 84 | if ($date != '') { |
| 85 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 85 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 86 | 86 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 87 | 87 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 88 | 88 | } else { |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | $sth = $this->db->prepare($query); |
| 102 | 102 | $sth->execute($query_values); |
| 103 | - } catch(PDOException $e) { |
|
| 103 | + } catch (PDOException $e) { |
|
| 104 | 104 | echo "error : ".$e->getMessage(); |
| 105 | 105 | } |
| 106 | 106 | $i = 0; |
| 107 | 107 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 108 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
| 108 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
| 109 | 109 | $data = array(); |
| 110 | 110 | if ($row['registration'] != '') { |
| 111 | 111 | $image_array = $Image->getSpotterImage($row['registration']); |
| 112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 112 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 113 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 114 | 114 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 115 | 115 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 116 | 116 | if (!empty($aircraft_info)) { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
| 119 | 119 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
| 120 | 120 | } else { |
| 121 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
| 121 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
| 122 | 122 | } |
| 123 | 123 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
| 124 | 124 | if (!empty($owner_data)) { |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | $data['aircraft_base'] = $owner_data['base']; |
| 127 | 127 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 128 | 128 | } |
| 129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 129 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 130 | 130 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 131 | 131 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 132 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
| 132 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
| 133 | 133 | if (isset($identicao[0])) { |
| 134 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 138 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 134 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 135 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 136 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 137 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 138 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 139 | 139 | } else $icao = $row['ident']; |
| 140 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 140 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 141 | 141 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 142 | 142 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
| 143 | 143 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -146,16 +146,16 @@ discard block |
||
| 146 | 146 | if (!empty($airline_info)) { |
| 147 | 147 | //echo 'data found !'."\n"; |
| 148 | 148 | //print_r($airline_info); |
| 149 | - $data = array_merge($data,$airline_info); |
|
| 149 | + $data = array_merge($data, $airline_info); |
|
| 150 | 150 | } |
| 151 | 151 | //else echo 'No data...'."\n"; |
| 152 | 152 | } |
| 153 | - $data = array_merge($row,$data); |
|
| 153 | + $data = array_merge($row, $data); |
|
| 154 | 154 | if ($data['ident'] == null) $data['ident'] = $icao; |
| 155 | 155 | if ($data['title'] == null) { |
| 156 | 156 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 157 | 157 | } else $data['message'] = strtolower($data['title']); |
| 158 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
| 158 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
| 159 | 159 | $date = $data['date']; |
| 160 | 160 | if (isset($ids[$date])) { |
| 161 | 161 | $data['spotted'] = TRUE; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | try { |
| 188 | 188 | $sth = $this->db->prepare($query); |
| 189 | 189 | $sth->execute(); |
| 190 | - } catch(PDOException $e) { |
|
| 190 | + } catch (PDOException $e) { |
|
| 191 | 191 | echo "Error : ".$e->getMessage(); |
| 192 | 192 | } |
| 193 | 193 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | $sth = $this->db->prepare($query); |
| 209 | 209 | $sth->execute(); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | echo "Error : ".$e->getMessage(); |
| 212 | 212 | } |
| 213 | 213 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -222,15 +222,15 @@ discard block |
||
| 222 | 222 | if ($globalDebug) echo 'Import '.$file."\n"; |
| 223 | 223 | $result = array(); |
| 224 | 224 | if (file_exists($file)) { |
| 225 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
| 226 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
| 225 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
| 226 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
| 227 | 227 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
| 228 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
| 228 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | fclose($handle); |
| 232 | 232 | } |
| 233 | - if (!empty($result)) $this->add($result,true); |
|
| 233 | + if (!empty($result)) $this->add($result, true); |
|
| 234 | 234 | elseif ($globalDebug) echo 'Nothing to import'; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | $all_md5_new = array(); |
| 247 | 247 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 248 | 248 | if ($this->check_accidents_nb() > 0) { |
| 249 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 250 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 249 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 250 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 251 | 251 | if (isset($data[1])) { |
| 252 | 252 | $year = $data[0]; |
| 253 | 253 | $all_md5[$year] = $data[1]; |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 260 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 261 | 261 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 262 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 263 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 262 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 263 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 264 | 264 | if (isset($data[1])) { |
| 265 | 265 | $year = $data[0]; |
| 266 | 266 | $all_md5_new[$year] = $data[1]; |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | fclose($handle); |
| 270 | 270 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
| 271 | 271 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
| 272 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
| 272 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
| 273 | 273 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
| 274 | 274 | foreach ($result as $file => $md5) { |
| 275 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 275 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 276 | 276 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
| 277 | 277 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
| 278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * Add data to DB |
| 283 | 283 | * @param Array $crash An array with accidents/incidents data |
| 284 | 284 | */ |
| 285 | - public function add($crash,$new = false) { |
|
| 285 | + public function add($crash, $new = false) { |
|
| 286 | 286 | global $globalTransaction, $globalDebug; |
| 287 | 287 | require_once('class.Connection.php'); |
| 288 | 288 | require_once('class.Image.php'); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 299 | 299 | } |
| 300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 301 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
| 301 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
| 302 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 303 | 303 | $sth_check = $Connection->db->prepare($query_check); |
| 304 | 304 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -311,15 +311,15 @@ discard block |
||
| 311 | 311 | $cr = array_map(function($value) { |
| 312 | 312 | return $value === "" ? NULL : $value; |
| 313 | 313 | }, $cr); |
| 314 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
| 315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 316 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
| 314 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
| 315 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 316 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
| 317 | 317 | $sth_check->execute($query_check_values); |
| 318 | 318 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
| 319 | 319 | if ($result_check['nb'] == 0) { |
| 320 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
| 320 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
| 321 | 321 | $sth->execute($query_values); |
| 322 | - if ($cr['date'] > time()-(30*86400)) { |
|
| 322 | + if ($cr['date'] > time() - (30*86400)) { |
|
| 323 | 323 | if (empty($Image->getSpotterImage($cr['registration']))) { |
| 324 | 324 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
| 325 | 325 | $Image->addSpotterImage($cr['registration']); |
@@ -328,16 +328,16 @@ discard block |
||
| 328 | 328 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 329 | 329 | } |
| 330 | 330 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
| 331 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
| 331 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 334 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 335 | 335 | $Connection->db->commit(); |
| 336 | 336 | $Connection->db->beginTransaction(); |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | if ($globalTransaction) $Connection->db->commit(); |
| 340 | - } catch(PDOException $e) { |
|
| 340 | + } catch (PDOException $e) { |
|
| 341 | 341 | if ($globalTransaction) $Connection->db->rollBack(); |
| 342 | 342 | echo $e->getMessage(); |
| 343 | 343 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $Connection = new Connection($this->db); |
| 356 | 356 | $sth = $Connection->db->prepare($query); |
| 357 | 357 | $sth->execute(); |
| 358 | - } catch(PDOException $e) { |
|
| 358 | + } catch (PDOException $e) { |
|
| 359 | 359 | return "error : ".$e->getMessage(); |
| 360 | 360 | } |
| 361 | 361 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $Connection = new Connection($this->db); |
| 374 | 374 | $sth = $Connection->db->prepare($query); |
| 375 | 375 | $sth->execute(); |
| 376 | - } catch(PDOException $e) { |
|
| 376 | + } catch (PDOException $e) { |
|
| 377 | 377 | return "error : ".$e->getMessage(); |
| 378 | 378 | } |
| 379 | 379 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $Connection = new Connection($this->db); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | return "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | public function __construct($dbc = null) { |
| 11 | 11 | $Connection = new Connection($dbc); |
| 12 | 12 | $this->db = $Connection->db(); |
| 13 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 13 | + if ($this->db === null) { |
|
| 14 | + die('Error: No DB connection.'); |
|
| 15 | + } |
|
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | public function get() { |
@@ -109,8 +111,11 @@ discard block |
||
| 109 | 111 | $data = array(); |
| 110 | 112 | if ($row['registration'] != '') { |
| 111 | 113 | $image_array = $Image->getSpotterImage($row['registration']); |
| 112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 114 | + if (count($image_array) > 0) { |
|
| 115 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 116 | + } else { |
|
| 117 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 118 | + } |
|
| 114 | 119 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 115 | 120 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 116 | 121 | if (!empty($aircraft_info)) { |
@@ -126,17 +131,30 @@ discard block |
||
| 126 | 131 | $data['aircraft_base'] = $owner_data['base']; |
| 127 | 132 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 128 | 133 | } |
| 129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 130 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 131 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 134 | + } else { |
|
| 135 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 136 | + } |
|
| 137 | + if ($row['registration'] == '') { |
|
| 138 | + $row['registration'] = 'NA'; |
|
| 139 | + } |
|
| 140 | + if ($row['ident'] == '') { |
|
| 141 | + $row['ident'] = 'NA'; |
|
| 142 | + } |
|
| 132 | 143 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 133 | 144 | if (isset($identicao[0])) { |
| 134 | 145 | if (substr($row['ident'],0,2) == 'AF') { |
| 135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 146 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 147 | + $icao = $row['ident']; |
|
| 148 | + } else { |
|
| 149 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 153 | + } |
|
| 138 | 154 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 139 | - } else $icao = $row['ident']; |
|
| 155 | + } else { |
|
| 156 | + $icao = $row['ident']; |
|
| 157 | + } |
|
| 140 | 158 | $icao = $Translation->checkTranslation($icao,false); |
| 141 | 159 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 142 | 160 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -151,10 +169,14 @@ discard block |
||
| 151 | 169 | //else echo 'No data...'."\n"; |
| 152 | 170 | } |
| 153 | 171 | $data = array_merge($row,$data); |
| 154 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 172 | + if ($data['ident'] == null) { |
|
| 173 | + $data['ident'] = $icao; |
|
| 174 | + } |
|
| 155 | 175 | if ($data['title'] == null) { |
| 156 | 176 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 157 | - } else $data['message'] = strtolower($data['title']); |
|
| 177 | + } else { |
|
| 178 | + $data['message'] = strtolower($data['title']); |
|
| 179 | + } |
|
| 158 | 180 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 159 | 181 | $date = $data['date']; |
| 160 | 182 | if (isset($ids[$date])) { |
@@ -173,8 +195,9 @@ discard block |
||
| 173 | 195 | if (isset($result)) { |
| 174 | 196 | $result[0]['query_number_rows'] = $i; |
| 175 | 197 | return $result; |
| 198 | + } else { |
|
| 199 | + return array(); |
|
| 176 | 200 | } |
| 177 | - else return array(); |
|
| 178 | 201 | } |
| 179 | 202 | |
| 180 | 203 | /* |
@@ -219,7 +242,9 @@ discard block |
||
| 219 | 242 | */ |
| 220 | 243 | public function import($file) { |
| 221 | 244 | global $globalTransaction, $globalDebug; |
| 222 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo 'Import '.$file."\n"; |
|
| 247 | + } |
|
| 223 | 248 | $result = array(); |
| 224 | 249 | if (file_exists($file)) { |
| 225 | 250 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -230,8 +255,11 @@ discard block |
||
| 230 | 255 | } |
| 231 | 256 | fclose($handle); |
| 232 | 257 | } |
| 233 | - if (!empty($result)) $this->add($result,true); |
|
| 234 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 258 | + if (!empty($result)) { |
|
| 259 | + $this->add($result,true); |
|
| 260 | + } elseif ($globalDebug) { |
|
| 261 | + echo 'Nothing to import'; |
|
| 262 | + } |
|
| 235 | 263 | } |
| 236 | 264 | } |
| 237 | 265 | |
@@ -267,14 +295,23 @@ discard block |
||
| 267 | 295 | } |
| 268 | 296 | } |
| 269 | 297 | fclose($handle); |
| 270 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 271 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 298 | + } elseif ($globalDebug) { |
|
| 299 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 300 | + } |
|
| 301 | + } elseif ($globalDebug) { |
|
| 302 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 303 | + } |
|
| 272 | 304 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 273 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 305 | + if (empty($result) && $globalDebug) { |
|
| 306 | + echo 'Nothing to update'; |
|
| 307 | + } |
|
| 274 | 308 | foreach ($result as $file => $md5) { |
| 275 | 309 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 276 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 277 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 310 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 311 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 312 | + } elseif ($globalDebug) { |
|
| 313 | + echo 'Download '.$file.' failed'; |
|
| 314 | + } |
|
| 278 | 315 | } |
| 279 | 316 | } |
| 280 | 317 | |
@@ -291,13 +328,17 @@ discard block |
||
| 291 | 328 | $Image = new Image($this->db); |
| 292 | 329 | $Spotter = new Spotter($this->db); |
| 293 | 330 | |
| 294 | - if (empty($crash)) return false; |
|
| 331 | + if (empty($crash)) { |
|
| 332 | + return false; |
|
| 333 | + } |
|
| 295 | 334 | if (!$new) { |
| 296 | 335 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 297 | 336 | $sthd = $Connection->db->prepare($query_delete); |
| 298 | 337 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 299 | 338 | } |
| 300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 339 | + if ($globalTransaction) { |
|
| 340 | + $Connection->db->beginTransaction(); |
|
| 341 | + } |
|
| 301 | 342 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 302 | 343 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 303 | 344 | $sth_check = $Connection->db->prepare($query_check); |
@@ -312,7 +353,9 @@ discard block |
||
| 312 | 353 | return $value === "" ? NULL : $value; |
| 313 | 354 | }, $cr); |
| 314 | 355 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 356 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 357 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 358 | + } |
|
| 316 | 359 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 317 | 360 | $sth_check->execute($query_check_values); |
| 318 | 361 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -321,13 +364,19 @@ discard block |
||
| 321 | 364 | $sth->execute($query_values); |
| 322 | 365 | if ($cr['date'] > time()-(30*86400)) { |
| 323 | 366 | if (empty($Image->getSpotterImage($cr['registration']))) { |
| 324 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 367 | + if ($globalDebug) { |
|
| 368 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 369 | + } |
|
| 325 | 370 | $Image->addSpotterImage($cr['registration']); |
| 326 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo "\t".'Done'."\n"; |
|
| 373 | + } |
|
| 327 | 374 | } |
| 328 | 375 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 329 | 376 | } |
| 330 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 377 | + if ($cr['title'] == '') { |
|
| 378 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 379 | + } |
|
| 331 | 380 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 332 | 381 | } |
| 333 | 382 | } |
@@ -336,9 +385,13 @@ discard block |
||
| 336 | 385 | $Connection->db->beginTransaction(); |
| 337 | 386 | } |
| 338 | 387 | } |
| 339 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 388 | + if ($globalTransaction) { |
|
| 389 | + $Connection->db->commit(); |
|
| 390 | + } |
|
| 340 | 391 | } catch(PDOException $e) { |
| 341 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 392 | + if ($globalTransaction) { |
|
| 393 | + $Connection->db->rollBack(); |
|
| 394 | + } |
|
| 342 | 395 | echo $e->getMessage(); |
| 343 | 396 | } |
| 344 | 397 | $sth_check->closeCursor(); |
@@ -377,8 +430,11 @@ discard block |
||
| 377 | 430 | return "error : ".$e->getMessage(); |
| 378 | 431 | } |
| 379 | 432 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 380 | - if ($row['nb'] > 0) return false; |
|
| 381 | - else return true; |
|
| 433 | + if ($row['nb'] > 0) { |
|
| 434 | + return false; |
|
| 435 | + } else { |
|
| 436 | + return true; |
|
| 437 | + } |
|
| 382 | 438 | } |
| 383 | 439 | |
| 384 | 440 | public static function insert_last_accidents_update() { |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param Array $filter the filter |
|
| 15 | - * @return Array the SQL part |
|
| 16 | - */ |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param Array $filter the filter |
|
| 15 | + * @return Array the SQL part |
|
| 16 | + */ |
|
| 17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
@@ -106,44 +106,44 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Gets all the spotter information based on a particular callsign |
|
| 111 | - * |
|
| 112 | - * @return Array the spotter information |
|
| 113 | - * |
|
| 114 | - */ |
|
| 115 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
| 116 | - { |
|
| 109 | + /** |
|
| 110 | + * Gets all the spotter information based on a particular callsign |
|
| 111 | + * |
|
| 112 | + * @return Array the spotter information |
|
| 113 | + * |
|
| 114 | + */ |
|
| 115 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
| 116 | + { |
|
| 117 | 117 | $Tracker = new Tracker($this->db); |
| 118 | - date_default_timezone_set('UTC'); |
|
| 118 | + date_default_timezone_set('UTC'); |
|
| 119 | 119 | |
| 120 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 121 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 120 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 121 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 123 | 123 | |
| 124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 124 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 125 | 125 | |
| 126 | - return $spotter_array; |
|
| 127 | - } |
|
| 126 | + return $spotter_array; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Gets last the spotter information based on a particular id |
|
| 132 | - * |
|
| 133 | - * @return Array the spotter information |
|
| 134 | - * |
|
| 135 | - */ |
|
| 136 | - public function getLastArchiveTrackerDataById($id) |
|
| 137 | - { |
|
| 138 | - $Tracker = new Tracker($this->db); |
|
| 139 | - date_default_timezone_set('UTC'); |
|
| 140 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 141 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 142 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 130 | + /** |
|
| 131 | + * Gets last the spotter information based on a particular id |
|
| 132 | + * |
|
| 133 | + * @return Array the spotter information |
|
| 134 | + * |
|
| 135 | + */ |
|
| 136 | + public function getLastArchiveTrackerDataById($id) |
|
| 137 | + { |
|
| 138 | + $Tracker = new Tracker($this->db); |
|
| 139 | + date_default_timezone_set('UTC'); |
|
| 140 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 141 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 142 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 144 | 144 | |
| 145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 146 | - /* |
|
| 146 | + /* |
|
| 147 | 147 | try { |
| 148 | 148 | $Connection = new Connection(); |
| 149 | 149 | $sth = Connection->$db->prepare($query); |
@@ -153,232 +153,232 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 155 | 155 | */ |
| 156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 157 | - |
|
| 158 | - return $spotter_array; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Gets all the spotter information based on a particular id |
|
| 163 | - * |
|
| 164 | - * @return Array the spotter information |
|
| 165 | - * |
|
| 166 | - */ |
|
| 167 | - public function getAllArchiveTrackerDataById($id) |
|
| 156 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 157 | + |
|
| 158 | + return $spotter_array; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Gets all the spotter information based on a particular id |
|
| 163 | + * |
|
| 164 | + * @return Array the spotter information |
|
| 165 | + * |
|
| 166 | + */ |
|
| 167 | + public function getAllArchiveTrackerDataById($id) |
|
| 168 | 168 | { |
| 169 | - date_default_timezone_set('UTC'); |
|
| 170 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 169 | + date_default_timezone_set('UTC'); |
|
| 170 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 172 | 172 | |
| 173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 174 | 174 | |
| 175 | - try { |
|
| 176 | - $sth = $this->db->prepare($query); |
|
| 177 | - $sth->execute(array(':id' => $id)); |
|
| 178 | - } catch(PDOException $e) { |
|
| 179 | - echo $e->getMessage(); |
|
| 180 | - die; |
|
| 181 | - } |
|
| 182 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 183 | - |
|
| 184 | - return $spotter_array; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Gets coordinate & time spotter information based on a particular id |
|
| 189 | - * |
|
| 190 | - * @return Array the spotter information |
|
| 191 | - * |
|
| 192 | - */ |
|
| 193 | - public function getCoordArchiveTrackerDataById($id) |
|
| 194 | - { |
|
| 195 | - date_default_timezone_set('UTC'); |
|
| 196 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 175 | + try { |
|
| 176 | + $sth = $this->db->prepare($query); |
|
| 177 | + $sth->execute(array(':id' => $id)); |
|
| 178 | + } catch(PDOException $e) { |
|
| 179 | + echo $e->getMessage(); |
|
| 180 | + die; |
|
| 181 | + } |
|
| 182 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 183 | + |
|
| 184 | + return $spotter_array; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Gets coordinate & time spotter information based on a particular id |
|
| 189 | + * |
|
| 190 | + * @return Array the spotter information |
|
| 191 | + * |
|
| 192 | + */ |
|
| 193 | + public function getCoordArchiveTrackerDataById($id) |
|
| 194 | + { |
|
| 195 | + date_default_timezone_set('UTC'); |
|
| 196 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 198 | 198 | |
| 199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 200 | |
| 201 | - try { |
|
| 202 | - $sth = $this->db->prepare($query); |
|
| 203 | - $sth->execute(array(':id' => $id)); |
|
| 204 | - } catch(PDOException $e) { |
|
| 205 | - echo $e->getMessage(); |
|
| 206 | - die; |
|
| 207 | - } |
|
| 208 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 201 | + try { |
|
| 202 | + $sth = $this->db->prepare($query); |
|
| 203 | + $sth->execute(array(':id' => $id)); |
|
| 204 | + } catch(PDOException $e) { |
|
| 205 | + echo $e->getMessage(); |
|
| 206 | + die; |
|
| 207 | + } |
|
| 208 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 209 | 209 | |
| 210 | - return $spotter_array; |
|
| 211 | - } |
|
| 210 | + return $spotter_array; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Gets altitude information based on a particular callsign |
|
| 216 | - * |
|
| 217 | - * @return Array the spotter information |
|
| 218 | - * |
|
| 219 | - */ |
|
| 220 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 221 | - { |
|
| 214 | + /** |
|
| 215 | + * Gets altitude information based on a particular callsign |
|
| 216 | + * |
|
| 217 | + * @return Array the spotter information |
|
| 218 | + * |
|
| 219 | + */ |
|
| 220 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 221 | + { |
|
| 222 | 222 | |
| 223 | - date_default_timezone_set('UTC'); |
|
| 223 | + date_default_timezone_set('UTC'); |
|
| 224 | 224 | |
| 225 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 225 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 227 | 227 | |
| 228 | - try { |
|
| 229 | - $sth = $this->db->prepare($query); |
|
| 230 | - $sth->execute(array(':ident' => $ident)); |
|
| 231 | - } catch(PDOException $e) { |
|
| 232 | - echo $e->getMessage(); |
|
| 233 | - die; |
|
| 234 | - } |
|
| 235 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 228 | + try { |
|
| 229 | + $sth = $this->db->prepare($query); |
|
| 230 | + $sth->execute(array(':ident' => $ident)); |
|
| 231 | + } catch(PDOException $e) { |
|
| 232 | + echo $e->getMessage(); |
|
| 233 | + die; |
|
| 234 | + } |
|
| 235 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 236 | 236 | |
| 237 | - return $spotter_array; |
|
| 238 | - } |
|
| 237 | + return $spotter_array; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Gets altitude information based on a particular id |
|
| 242 | - * |
|
| 243 | - * @return Array the spotter information |
|
| 244 | - * |
|
| 245 | - */ |
|
| 246 | - public function getAltitudeArchiveTrackerDataById($id) |
|
| 247 | - { |
|
| 240 | + /** |
|
| 241 | + * Gets altitude information based on a particular id |
|
| 242 | + * |
|
| 243 | + * @return Array the spotter information |
|
| 244 | + * |
|
| 245 | + */ |
|
| 246 | + public function getAltitudeArchiveTrackerDataById($id) |
|
| 247 | + { |
|
| 248 | 248 | |
| 249 | - date_default_timezone_set('UTC'); |
|
| 249 | + date_default_timezone_set('UTC'); |
|
| 250 | 250 | |
| 251 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 251 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | 253 | |
| 254 | - try { |
|
| 255 | - $sth = $this->db->prepare($query); |
|
| 256 | - $sth->execute(array(':id' => $id)); |
|
| 257 | - } catch(PDOException $e) { |
|
| 258 | - echo $e->getMessage(); |
|
| 259 | - die; |
|
| 260 | - } |
|
| 261 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 254 | + try { |
|
| 255 | + $sth = $this->db->prepare($query); |
|
| 256 | + $sth->execute(array(':id' => $id)); |
|
| 257 | + } catch(PDOException $e) { |
|
| 258 | + echo $e->getMessage(); |
|
| 259 | + die; |
|
| 260 | + } |
|
| 261 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 262 | 262 | |
| 263 | - return $spotter_array; |
|
| 264 | - } |
|
| 263 | + return $spotter_array; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Gets altitude & speed information based on a particular id |
|
| 268 | - * |
|
| 269 | - * @return Array the spotter information |
|
| 270 | - * |
|
| 271 | - */ |
|
| 272 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 273 | - { |
|
| 266 | + /** |
|
| 267 | + * Gets altitude & speed information based on a particular id |
|
| 268 | + * |
|
| 269 | + * @return Array the spotter information |
|
| 270 | + * |
|
| 271 | + */ |
|
| 272 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 273 | + { |
|
| 274 | 274 | |
| 275 | - date_default_timezone_set('UTC'); |
|
| 275 | + date_default_timezone_set('UTC'); |
|
| 276 | 276 | |
| 277 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 277 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 279 | 279 | |
| 280 | - try { |
|
| 281 | - $sth = $this->db->prepare($query); |
|
| 282 | - $sth->execute(array(':id' => $id)); |
|
| 283 | - } catch(PDOException $e) { |
|
| 284 | - echo $e->getMessage(); |
|
| 285 | - die; |
|
| 286 | - } |
|
| 287 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 280 | + try { |
|
| 281 | + $sth = $this->db->prepare($query); |
|
| 282 | + $sth->execute(array(':id' => $id)); |
|
| 283 | + } catch(PDOException $e) { |
|
| 284 | + echo $e->getMessage(); |
|
| 285 | + die; |
|
| 286 | + } |
|
| 287 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 288 | 288 | |
| 289 | - return $spotter_array; |
|
| 290 | - } |
|
| 289 | + return $spotter_array; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Gets altitude information based on a particular callsign |
|
| 295 | - * |
|
| 296 | - * @return Array the spotter information |
|
| 297 | - * |
|
| 298 | - */ |
|
| 299 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 300 | - { |
|
| 293 | + /** |
|
| 294 | + * Gets altitude information based on a particular callsign |
|
| 295 | + * |
|
| 296 | + * @return Array the spotter information |
|
| 297 | + * |
|
| 298 | + */ |
|
| 299 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 300 | + { |
|
| 301 | 301 | |
| 302 | - date_default_timezone_set('UTC'); |
|
| 302 | + date_default_timezone_set('UTC'); |
|
| 303 | 303 | |
| 304 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 304 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 307 | 307 | |
| 308 | - try { |
|
| 309 | - $sth = $this->db->prepare($query); |
|
| 310 | - $sth->execute(array(':ident' => $ident)); |
|
| 311 | - } catch(PDOException $e) { |
|
| 312 | - echo $e->getMessage(); |
|
| 313 | - die; |
|
| 314 | - } |
|
| 315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 308 | + try { |
|
| 309 | + $sth = $this->db->prepare($query); |
|
| 310 | + $sth->execute(array(':ident' => $ident)); |
|
| 311 | + } catch(PDOException $e) { |
|
| 312 | + echo $e->getMessage(); |
|
| 313 | + die; |
|
| 314 | + } |
|
| 315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 316 | 316 | |
| 317 | - return $spotter_array; |
|
| 318 | - } |
|
| 317 | + return $spotter_array; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | |
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Gets all the archive spotter information |
|
| 324 | - * |
|
| 325 | - * @return Array the spotter information |
|
| 326 | - * |
|
| 327 | - */ |
|
| 328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 329 | - { |
|
| 330 | - $Tracker = new Tracker($this->db); |
|
| 331 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 322 | + /** |
|
| 323 | + * Gets all the archive spotter information |
|
| 324 | + * |
|
| 325 | + * @return Array the spotter information |
|
| 326 | + * |
|
| 327 | + */ |
|
| 328 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 329 | + { |
|
| 330 | + $Tracker = new Tracker($this->db); |
|
| 331 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 333 | 333 | |
| 334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 334 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 335 | 335 | |
| 336 | - return $spotter_array; |
|
| 337 | - } |
|
| 336 | + return $spotter_array; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - public function deleteTrackerArchiveTrackData() |
|
| 340 | - { |
|
| 339 | + public function deleteTrackerArchiveTrackData() |
|
| 340 | + { |
|
| 341 | 341 | global $globalArchiveKeepTrackMonths; |
| 342 | - date_default_timezone_set('UTC'); |
|
| 342 | + date_default_timezone_set('UTC'); |
|
| 343 | 343 | $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 344 | - try { |
|
| 345 | - $sth = $this->db->prepare($query); |
|
| 346 | - $sth->execute(); |
|
| 347 | - } catch(PDOException $e) { |
|
| 348 | - echo $e->getMessage(); |
|
| 349 | - die; |
|
| 350 | - } |
|
| 344 | + try { |
|
| 345 | + $sth = $this->db->prepare($query); |
|
| 346 | + $sth->execute(); |
|
| 347 | + } catch(PDOException $e) { |
|
| 348 | + echo $e->getMessage(); |
|
| 349 | + die; |
|
| 350 | + } |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | - * Gets Minimal Live Tracker data |
|
| 355 | - * |
|
| 356 | - * @return Array the spotter information |
|
| 357 | - * |
|
| 358 | - */ |
|
| 359 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 360 | - { |
|
| 361 | - global $globalDBdriver, $globalLiveInterval; |
|
| 362 | - date_default_timezone_set('UTC'); |
|
| 363 | - |
|
| 364 | - $filter_query = ''; |
|
| 365 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 366 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 367 | - } |
|
| 368 | - // Use spotter_output also ? |
|
| 369 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 370 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 371 | - } |
|
| 372 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 374 | - } |
|
| 375 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 376 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 377 | - } |
|
| 354 | + * Gets Minimal Live Tracker data |
|
| 355 | + * |
|
| 356 | + * @return Array the spotter information |
|
| 357 | + * |
|
| 358 | + */ |
|
| 359 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 360 | + { |
|
| 361 | + global $globalDBdriver, $globalLiveInterval; |
|
| 362 | + date_default_timezone_set('UTC'); |
|
| 363 | + |
|
| 364 | + $filter_query = ''; |
|
| 365 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 366 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 367 | + } |
|
| 368 | + // Use spotter_output also ? |
|
| 369 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 370 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 371 | + } |
|
| 372 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 374 | + } |
|
| 375 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 376 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 380 | - if ($globalDBdriver == 'mysql') { |
|
| 381 | - /* |
|
| 379 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 380 | + if ($globalDBdriver == 'mysql') { |
|
| 381 | + /* |
|
| 382 | 382 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 383 | 383 | FROM tracker_archive |
| 384 | 384 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -397,56 +397,56 @@ discard block |
||
| 397 | 397 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 398 | 398 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 399 | 399 | '.$filter_query.' ORDER BY famtrackid'; |
| 400 | - } else { |
|
| 401 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 402 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 400 | + } else { |
|
| 401 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 402 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 403 | 403 | FROM tracker_archive |
| 404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 405 | 405 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
| 406 | 406 | '.$filter_query.' ORDER BY famtrackid'; |
| 407 | - } |
|
| 408 | - //echo $query; |
|
| 409 | - try { |
|
| 410 | - $sth = $this->db->prepare($query); |
|
| 411 | - $sth->execute(); |
|
| 412 | - } catch(PDOException $e) { |
|
| 413 | - echo $e->getMessage(); |
|
| 414 | - die; |
|
| 415 | - } |
|
| 416 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 407 | + } |
|
| 408 | + //echo $query; |
|
| 409 | + try { |
|
| 410 | + $sth = $this->db->prepare($query); |
|
| 411 | + $sth->execute(); |
|
| 412 | + } catch(PDOException $e) { |
|
| 413 | + echo $e->getMessage(); |
|
| 414 | + die; |
|
| 415 | + } |
|
| 416 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 417 | 417 | |
| 418 | - return $spotter_array; |
|
| 419 | - } |
|
| 418 | + return $spotter_array; |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | 421 | /** |
| 422 | - * Gets Minimal Live Tracker data |
|
| 423 | - * |
|
| 424 | - * @return Array the spotter information |
|
| 425 | - * |
|
| 426 | - */ |
|
| 427 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 428 | - { |
|
| 429 | - global $globalDBdriver, $globalLiveInterval; |
|
| 430 | - date_default_timezone_set('UTC'); |
|
| 431 | - |
|
| 432 | - $filter_query = ''; |
|
| 433 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 434 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 435 | - } |
|
| 436 | - // Should use spotter_output also ? |
|
| 437 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 438 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 439 | - } |
|
| 440 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 442 | - } |
|
| 443 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 444 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 445 | - } |
|
| 422 | + * Gets Minimal Live Tracker data |
|
| 423 | + * |
|
| 424 | + * @return Array the spotter information |
|
| 425 | + * |
|
| 426 | + */ |
|
| 427 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 428 | + { |
|
| 429 | + global $globalDBdriver, $globalLiveInterval; |
|
| 430 | + date_default_timezone_set('UTC'); |
|
| 431 | + |
|
| 432 | + $filter_query = ''; |
|
| 433 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 434 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 435 | + } |
|
| 436 | + // Should use spotter_output also ? |
|
| 437 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 438 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 439 | + } |
|
| 440 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 442 | + } |
|
| 443 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 444 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 448 | - if ($globalDBdriver == 'mysql') { |
|
| 449 | - /* |
|
| 447 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 448 | + if ($globalDBdriver == 'mysql') { |
|
| 449 | + /* |
|
| 450 | 450 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 451 | 451 | FROM tracker_archive |
| 452 | 452 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -457,95 +457,95 @@ discard block |
||
| 457 | 457 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 458 | 458 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 459 | 459 | |
| 460 | - } else { |
|
| 461 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 462 | - /* |
|
| 460 | + } else { |
|
| 461 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 462 | + /* |
|
| 463 | 463 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
| 464 | 464 | FROM tracker_archive_output |
| 465 | 465 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 466 | 466 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 467 | 467 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 468 | 468 | */ |
| 469 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 469 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 470 | 470 | FROM tracker_archive_output |
| 471 | 471 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 472 | 472 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 473 | 473 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 474 | 474 | // .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 475 | 475 | |
| 476 | - } |
|
| 477 | - //echo $query; |
|
| 478 | - try { |
|
| 479 | - $sth = $this->db->prepare($query); |
|
| 480 | - $sth->execute(); |
|
| 481 | - } catch(PDOException $e) { |
|
| 482 | - echo $e->getMessage(); |
|
| 483 | - die; |
|
| 484 | - } |
|
| 485 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 476 | + } |
|
| 477 | + //echo $query; |
|
| 478 | + try { |
|
| 479 | + $sth = $this->db->prepare($query); |
|
| 480 | + $sth->execute(); |
|
| 481 | + } catch(PDOException $e) { |
|
| 482 | + echo $e->getMessage(); |
|
| 483 | + die; |
|
| 484 | + } |
|
| 485 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 486 | 486 | |
| 487 | - return $spotter_array; |
|
| 488 | - } |
|
| 487 | + return $spotter_array; |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | - * Gets count Live Tracker data |
|
| 492 | - * |
|
| 493 | - * @return Array the spotter information |
|
| 494 | - * |
|
| 495 | - */ |
|
| 496 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 497 | - { |
|
| 498 | - global $globalDBdriver, $globalLiveInterval; |
|
| 499 | - date_default_timezone_set('UTC'); |
|
| 500 | - |
|
| 501 | - $filter_query = ''; |
|
| 502 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 503 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 504 | - } |
|
| 505 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 506 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 507 | - } |
|
| 508 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 510 | - } |
|
| 511 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 512 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 513 | - } |
|
| 491 | + * Gets count Live Tracker data |
|
| 492 | + * |
|
| 493 | + * @return Array the spotter information |
|
| 494 | + * |
|
| 495 | + */ |
|
| 496 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 497 | + { |
|
| 498 | + global $globalDBdriver, $globalLiveInterval; |
|
| 499 | + date_default_timezone_set('UTC'); |
|
| 514 | 500 | |
| 515 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 516 | - if ($globalDBdriver == 'mysql') { |
|
| 501 | + $filter_query = ''; |
|
| 502 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 503 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 504 | + } |
|
| 505 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 506 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 507 | + } |
|
| 508 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 510 | + } |
|
| 511 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 512 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 516 | + if ($globalDBdriver == 'mysql') { |
|
| 517 | 517 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
| 518 | 518 | FROM tracker_archive l |
| 519 | 519 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 520 | - } else { |
|
| 520 | + } else { |
|
| 521 | 521 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 522 | - } |
|
| 523 | - //echo $query; |
|
| 524 | - try { |
|
| 525 | - $sth = $this->db->prepare($query); |
|
| 526 | - $sth->execute(); |
|
| 527 | - } catch(PDOException $e) { |
|
| 528 | - echo $e->getMessage(); |
|
| 529 | - die; |
|
| 530 | - } |
|
| 522 | + } |
|
| 523 | + //echo $query; |
|
| 524 | + try { |
|
| 525 | + $sth = $this->db->prepare($query); |
|
| 526 | + $sth->execute(); |
|
| 527 | + } catch(PDOException $e) { |
|
| 528 | + echo $e->getMessage(); |
|
| 529 | + die; |
|
| 530 | + } |
|
| 531 | 531 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 532 | 532 | $sth->closeCursor(); |
| 533 | - return $result['nb']; |
|
| 533 | + return $result['nb']; |
|
| 534 | 534 | |
| 535 | - } |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | |
| 539 | 539 | // tracker_archive_output |
| 540 | 540 | |
| 541 | - /** |
|
| 542 | - * Gets all the spotter information |
|
| 543 | - * |
|
| 544 | - * @return Array the spotter information |
|
| 545 | - * |
|
| 546 | - */ |
|
| 547 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 548 | - { |
|
| 541 | + /** |
|
| 542 | + * Gets all the spotter information |
|
| 543 | + * |
|
| 544 | + * @return Array the spotter information |
|
| 545 | + * |
|
| 546 | + */ |
|
| 547 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 548 | + { |
|
| 549 | 549 | global $globalTimezone, $globalDBdriver; |
| 550 | 550 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 551 | 551 | $Translation = new Translation($this->db); |
@@ -559,159 +559,159 @@ discard block |
||
| 559 | 559 | $filter_query = $this->getFilter($filters); |
| 560 | 560 | if ($q != "") |
| 561 | 561 | { |
| 562 | - if (!is_string($q)) |
|
| 563 | - { |
|
| 562 | + if (!is_string($q)) |
|
| 563 | + { |
|
| 564 | 564 | return false; |
| 565 | - } else { |
|
| 565 | + } else { |
|
| 566 | 566 | |
| 567 | 567 | $q_array = explode(" ", $q); |
| 568 | 568 | |
| 569 | 569 | foreach ($q_array as $q_item){ |
| 570 | - $additional_query .= " AND ("; |
|
| 571 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 572 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 573 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 574 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 575 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 576 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 577 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 578 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 579 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 580 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 581 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 582 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 583 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 584 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 585 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 586 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 587 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 588 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 589 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 590 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 591 | - $translate = $Translation->ident2icao($q_item); |
|
| 592 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 593 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 594 | - $additional_query .= ")"; |
|
| 570 | + $additional_query .= " AND ("; |
|
| 571 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 572 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 573 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 574 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 575 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 576 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 577 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 578 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 579 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 580 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 581 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 582 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 583 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 584 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 585 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 586 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 587 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 588 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 589 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 590 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 591 | + $translate = $Translation->ident2icao($q_item); |
|
| 592 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 593 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 594 | + $additional_query .= ")"; |
|
| 595 | + } |
|
| 595 | 596 | } |
| 596 | - } |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | if ($registration != "") |
| 600 | 600 | { |
| 601 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 602 | - if (!is_string($registration)) |
|
| 603 | - { |
|
| 601 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 602 | + if (!is_string($registration)) |
|
| 603 | + { |
|
| 604 | 604 | return false; |
| 605 | - } else { |
|
| 605 | + } else { |
|
| 606 | 606 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
| 607 | - } |
|
| 607 | + } |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | if ($aircraft_icao != "") |
| 611 | 611 | { |
| 612 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 613 | - if (!is_string($aircraft_icao)) |
|
| 614 | - { |
|
| 612 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 613 | + if (!is_string($aircraft_icao)) |
|
| 614 | + { |
|
| 615 | 615 | return false; |
| 616 | - } else { |
|
| 616 | + } else { |
|
| 617 | 617 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 618 | - } |
|
| 618 | + } |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | if ($aircraft_manufacturer != "") |
| 622 | 622 | { |
| 623 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 624 | - if (!is_string($aircraft_manufacturer)) |
|
| 625 | - { |
|
| 623 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 624 | + if (!is_string($aircraft_manufacturer)) |
|
| 625 | + { |
|
| 626 | 626 | return false; |
| 627 | - } else { |
|
| 627 | + } else { |
|
| 628 | 628 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 629 | - } |
|
| 629 | + } |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | if ($highlights == "true") |
| 633 | 633 | { |
| 634 | - if (!is_string($highlights)) |
|
| 635 | - { |
|
| 634 | + if (!is_string($highlights)) |
|
| 635 | + { |
|
| 636 | 636 | return false; |
| 637 | - } else { |
|
| 637 | + } else { |
|
| 638 | 638 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
| 639 | - } |
|
| 639 | + } |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | if ($airline_icao != "") |
| 643 | 643 | { |
| 644 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 645 | - if (!is_string($airline_icao)) |
|
| 646 | - { |
|
| 644 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 645 | + if (!is_string($airline_icao)) |
|
| 646 | + { |
|
| 647 | 647 | return false; |
| 648 | - } else { |
|
| 648 | + } else { |
|
| 649 | 649 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
| 650 | - } |
|
| 650 | + } |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | if ($airline_country != "") |
| 654 | 654 | { |
| 655 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 656 | - if (!is_string($airline_country)) |
|
| 657 | - { |
|
| 655 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 656 | + if (!is_string($airline_country)) |
|
| 657 | + { |
|
| 658 | 658 | return false; |
| 659 | - } else { |
|
| 659 | + } else { |
|
| 660 | 660 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
| 661 | - } |
|
| 661 | + } |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | if ($airline_type != "") |
| 665 | 665 | { |
| 666 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 667 | - if (!is_string($airline_type)) |
|
| 668 | - { |
|
| 666 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 667 | + if (!is_string($airline_type)) |
|
| 668 | + { |
|
| 669 | 669 | return false; |
| 670 | - } else { |
|
| 670 | + } else { |
|
| 671 | 671 | if ($airline_type == "passenger") |
| 672 | 672 | { |
| 673 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 673 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 674 | 674 | } |
| 675 | 675 | if ($airline_type == "cargo") |
| 676 | 676 | { |
| 677 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 677 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 678 | 678 | } |
| 679 | 679 | if ($airline_type == "military") |
| 680 | 680 | { |
| 681 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 681 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 682 | + } |
|
| 682 | 683 | } |
| 683 | - } |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if ($airport != "") |
| 687 | 687 | { |
| 688 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 689 | - if (!is_string($airport)) |
|
| 690 | - { |
|
| 688 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 689 | + if (!is_string($airport)) |
|
| 690 | + { |
|
| 691 | 691 | return false; |
| 692 | - } else { |
|
| 692 | + } else { |
|
| 693 | 693 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 694 | - } |
|
| 694 | + } |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | if ($airport_country != "") |
| 698 | 698 | { |
| 699 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 700 | - if (!is_string($airport_country)) |
|
| 701 | - { |
|
| 699 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 700 | + if (!is_string($airport_country)) |
|
| 701 | + { |
|
| 702 | 702 | return false; |
| 703 | - } else { |
|
| 703 | + } else { |
|
| 704 | 704 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 705 | - } |
|
| 705 | + } |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | if ($callsign != "") |
| 709 | 709 | { |
| 710 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 711 | - if (!is_string($callsign)) |
|
| 712 | - { |
|
| 710 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 711 | + if (!is_string($callsign)) |
|
| 712 | + { |
|
| 713 | 713 | return false; |
| 714 | - } else { |
|
| 714 | + } else { |
|
| 715 | 715 | $translate = $Translation->ident2icao($callsign); |
| 716 | 716 | if ($translate != $callsign) { |
| 717 | 717 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -719,99 +719,99 @@ discard block |
||
| 719 | 719 | } else { |
| 720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 721 | 721 | } |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | if ($owner != "") |
| 726 | 726 | { |
| 727 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 728 | - if (!is_string($owner)) |
|
| 729 | - { |
|
| 727 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 728 | + if (!is_string($owner)) |
|
| 729 | + { |
|
| 730 | 730 | return false; |
| 731 | - } else { |
|
| 731 | + } else { |
|
| 732 | 732 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
| 733 | - } |
|
| 733 | + } |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | if ($pilot_name != "") |
| 737 | 737 | { |
| 738 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($pilot_name)) |
|
| 740 | - { |
|
| 738 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($pilot_name)) |
|
| 740 | + { |
|
| 741 | 741 | return false; |
| 742 | - } else { |
|
| 742 | + } else { |
|
| 743 | 743 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | if ($pilot_id != "") |
| 748 | 748 | { |
| 749 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 750 | - if (!is_string($pilot_id)) |
|
| 751 | - { |
|
| 749 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 750 | + if (!is_string($pilot_id)) |
|
| 751 | + { |
|
| 752 | 752 | return false; |
| 753 | - } else { |
|
| 753 | + } else { |
|
| 754 | 754 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
| 755 | - } |
|
| 755 | + } |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if ($departure_airport_route != "") |
| 759 | 759 | { |
| 760 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($departure_airport_route)) |
|
| 762 | - { |
|
| 760 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($departure_airport_route)) |
|
| 762 | + { |
|
| 763 | 763 | return false; |
| 764 | - } else { |
|
| 764 | + } else { |
|
| 765 | 765 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 766 | - } |
|
| 766 | + } |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | if ($arrival_airport_route != "") |
| 770 | 770 | { |
| 771 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 772 | - if (!is_string($arrival_airport_route)) |
|
| 773 | - { |
|
| 771 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 772 | + if (!is_string($arrival_airport_route)) |
|
| 773 | + { |
|
| 774 | 774 | return false; |
| 775 | - } else { |
|
| 775 | + } else { |
|
| 776 | 776 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 777 | - } |
|
| 777 | + } |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | if ($altitude != "") |
| 781 | 781 | { |
| 782 | - $altitude_array = explode(",", $altitude); |
|
| 782 | + $altitude_array = explode(",", $altitude); |
|
| 783 | 783 | |
| 784 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 786 | 786 | |
| 787 | 787 | |
| 788 | - if ($altitude_array[1] != "") |
|
| 789 | - { |
|
| 788 | + if ($altitude_array[1] != "") |
|
| 789 | + { |
|
| 790 | 790 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 791 | 791 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 792 | 792 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 793 | - } else { |
|
| 793 | + } else { |
|
| 794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 795 | 795 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 796 | - } |
|
| 796 | + } |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | if ($date_posted != "") |
| 800 | 800 | { |
| 801 | - $date_array = explode(",", $date_posted); |
|
| 801 | + $date_array = explode(",", $date_posted); |
|
| 802 | 802 | |
| 803 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 804 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 803 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 804 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 805 | 805 | |
| 806 | - if ($globalTimezone != '') { |
|
| 806 | + if ($globalTimezone != '') { |
|
| 807 | 807 | date_default_timezone_set($globalTimezone); |
| 808 | 808 | $datetime = new DateTime(); |
| 809 | 809 | $offset = $datetime->format('P'); |
| 810 | - } else $offset = '+00:00'; |
|
| 810 | + } else $offset = '+00:00'; |
|
| 811 | 811 | |
| 812 | 812 | |
| 813 | - if ($date_array[1] != "") |
|
| 814 | - { |
|
| 813 | + if ($date_array[1] != "") |
|
| 814 | + { |
|
| 815 | 815 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 816 | 816 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 817 | 817 | if ($globalDBdriver == 'mysql') { |
@@ -819,28 +819,28 @@ discard block |
||
| 819 | 819 | } else { |
| 820 | 820 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 821 | 821 | } |
| 822 | - } else { |
|
| 822 | + } else { |
|
| 823 | 823 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 824 | - if ($globalDBdriver == 'mysql') { |
|
| 824 | + if ($globalDBdriver == 'mysql') { |
|
| 825 | 825 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 826 | 826 | } else { |
| 827 | 827 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 828 | 828 | } |
| 829 | - } |
|
| 829 | + } |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | if ($limit != "") |
| 833 | 833 | { |
| 834 | - $limit_array = explode(",", $limit); |
|
| 834 | + $limit_array = explode(",", $limit); |
|
| 835 | 835 | |
| 836 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | 838 | |
| 839 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 840 | - { |
|
| 839 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 840 | + { |
|
| 841 | 841 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 842 | 842 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 843 | - } |
|
| 843 | + } |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | |
@@ -871,33 +871,33 @@ discard block |
||
| 871 | 871 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
| 872 | 872 | |
| 873 | 873 | return $spotter_array; |
| 874 | - } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - public function deleteTrackerArchiveData() |
|
| 877 | - { |
|
| 876 | + public function deleteTrackerArchiveData() |
|
| 877 | + { |
|
| 878 | 878 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 879 | - date_default_timezone_set('UTC'); |
|
| 880 | - if ($globalDBdriver == 'mysql') { |
|
| 879 | + date_default_timezone_set('UTC'); |
|
| 880 | + if ($globalDBdriver == 'mysql') { |
|
| 881 | 881 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 882 | 882 | } else { |
| 883 | 883 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 884 | 884 | } |
| 885 | - try { |
|
| 886 | - $sth = $this->db->prepare($query); |
|
| 887 | - $sth->execute(); |
|
| 888 | - } catch(PDOException $e) { |
|
| 889 | - return "error"; |
|
| 890 | - } |
|
| 885 | + try { |
|
| 886 | + $sth = $this->db->prepare($query); |
|
| 887 | + $sth->execute(); |
|
| 888 | + } catch(PDOException $e) { |
|
| 889 | + return "error"; |
|
| 890 | + } |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - /** |
|
| 894 | - * Gets all the spotter information based on the callsign |
|
| 895 | - * |
|
| 896 | - * @return Array the spotter information |
|
| 897 | - * |
|
| 898 | - */ |
|
| 899 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 900 | - { |
|
| 893 | + /** |
|
| 894 | + * Gets all the spotter information based on the callsign |
|
| 895 | + * |
|
| 896 | + * @return Array the spotter information |
|
| 897 | + * |
|
| 898 | + */ |
|
| 899 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 900 | + { |
|
| 901 | 901 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 902 | 902 | |
| 903 | 903 | date_default_timezone_set('UTC'); |
@@ -909,35 +909,35 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | if ($ident != "") |
| 911 | 911 | { |
| 912 | - if (!is_string($ident)) |
|
| 913 | - { |
|
| 912 | + if (!is_string($ident)) |
|
| 913 | + { |
|
| 914 | 914 | return false; |
| 915 | - } else { |
|
| 915 | + } else { |
|
| 916 | 916 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
| 917 | 917 | $query_values = array(':ident' => $ident); |
| 918 | - } |
|
| 918 | + } |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | if ($limit != "") |
| 922 | 922 | { |
| 923 | - $limit_array = explode(",", $limit); |
|
| 923 | + $limit_array = explode(",", $limit); |
|
| 924 | 924 | |
| 925 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | 927 | |
| 928 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 929 | - { |
|
| 928 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 929 | + { |
|
| 930 | 930 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 931 | 931 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 932 | - } |
|
| 932 | + } |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | if ($sort != "") |
| 936 | 936 | { |
| 937 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 938 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 937 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 938 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 939 | 939 | } else { |
| 940 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 940 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -945,17 +945,17 @@ discard block |
||
| 945 | 945 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 946 | 946 | |
| 947 | 947 | return $spotter_array; |
| 948 | - } |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | 950 | |
| 951 | - /** |
|
| 952 | - * Gets all the spotter information based on the owner |
|
| 953 | - * |
|
| 954 | - * @return Array the spotter information |
|
| 955 | - * |
|
| 956 | - */ |
|
| 957 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 958 | - { |
|
| 951 | + /** |
|
| 952 | + * Gets all the spotter information based on the owner |
|
| 953 | + * |
|
| 954 | + * @return Array the spotter information |
|
| 955 | + * |
|
| 956 | + */ |
|
| 957 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 958 | + { |
|
| 959 | 959 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 960 | 960 | |
| 961 | 961 | date_default_timezone_set('UTC'); |
@@ -968,35 +968,35 @@ discard block |
||
| 968 | 968 | |
| 969 | 969 | if ($owner != "") |
| 970 | 970 | { |
| 971 | - if (!is_string($owner)) |
|
| 972 | - { |
|
| 971 | + if (!is_string($owner)) |
|
| 972 | + { |
|
| 973 | 973 | return false; |
| 974 | - } else { |
|
| 974 | + } else { |
|
| 975 | 975 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
| 976 | 976 | $query_values = array(':owner' => $owner); |
| 977 | - } |
|
| 977 | + } |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | if ($limit != "") |
| 981 | 981 | { |
| 982 | - $limit_array = explode(",", $limit); |
|
| 982 | + $limit_array = explode(",", $limit); |
|
| 983 | 983 | |
| 984 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 986 | 986 | |
| 987 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 988 | - { |
|
| 987 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 988 | + { |
|
| 989 | 989 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 990 | 990 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 991 | - } |
|
| 991 | + } |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | if ($sort != "") |
| 995 | 995 | { |
| 996 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 997 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 996 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 997 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 998 | 998 | } else { |
| 999 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 999 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1004,16 +1004,16 @@ discard block |
||
| 1004 | 1004 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1005 | 1005 | |
| 1006 | 1006 | return $spotter_array; |
| 1007 | - } |
|
| 1008 | - |
|
| 1009 | - /** |
|
| 1010 | - * Gets all the spotter information based on the pilot |
|
| 1011 | - * |
|
| 1012 | - * @return Array the spotter information |
|
| 1013 | - * |
|
| 1014 | - */ |
|
| 1015 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1016 | - { |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + /** |
|
| 1010 | + * Gets all the spotter information based on the pilot |
|
| 1011 | + * |
|
| 1012 | + * @return Array the spotter information |
|
| 1013 | + * |
|
| 1014 | + */ |
|
| 1015 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1016 | + { |
|
| 1017 | 1017 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 1018 | 1018 | |
| 1019 | 1019 | date_default_timezone_set('UTC'); |
@@ -1032,24 +1032,24 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | if ($limit != "") |
| 1034 | 1034 | { |
| 1035 | - $limit_array = explode(",", $limit); |
|
| 1035 | + $limit_array = explode(",", $limit); |
|
| 1036 | 1036 | |
| 1037 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1037 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1039 | 1039 | |
| 1040 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1041 | - { |
|
| 1040 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1041 | + { |
|
| 1042 | 1042 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1043 | 1043 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1044 | - } |
|
| 1044 | + } |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | if ($sort != "") |
| 1048 | 1048 | { |
| 1049 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1050 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1049 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1050 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1051 | 1051 | } else { |
| 1052 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1052 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1057,16 +1057,16 @@ discard block |
||
| 1057 | 1057 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1058 | 1058 | |
| 1059 | 1059 | return $spotter_array; |
| 1060 | - } |
|
| 1061 | - |
|
| 1062 | - /** |
|
| 1063 | - * Gets all number of flight over countries |
|
| 1064 | - * |
|
| 1065 | - * @return Array the airline country list |
|
| 1066 | - * |
|
| 1067 | - */ |
|
| 1068 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1069 | - { |
|
| 1060 | + } |
|
| 1061 | + |
|
| 1062 | + /** |
|
| 1063 | + * Gets all number of flight over countries |
|
| 1064 | + * |
|
| 1065 | + * @return Array the airline country list |
|
| 1066 | + * |
|
| 1067 | + */ |
|
| 1068 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1069 | + { |
|
| 1070 | 1070 | global $globalDBdriver; |
| 1071 | 1071 | /* |
| 1072 | 1072 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1076,14 +1076,14 @@ discard block |
||
| 1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1077 | 1077 | FROM countries c, tracker_archive s |
| 1078 | 1078 | WHERE c.iso2 = s.over_country "; |
| 1079 | - if ($olderthanmonths > 0) { |
|
| 1080 | - if ($globalDBdriver == 'mysql') { |
|
| 1079 | + if ($olderthanmonths > 0) { |
|
| 1080 | + if ($globalDBdriver == 'mysql') { |
|
| 1081 | 1081 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1082 | 1082 | } else { |
| 1083 | 1083 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1086 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1087 | 1087 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1088 | 1088 | if ($limit) $query .= " LIMIT 0,10"; |
| 1089 | 1089 | |
@@ -1096,23 +1096,23 @@ discard block |
||
| 1096 | 1096 | |
| 1097 | 1097 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1098 | 1098 | { |
| 1099 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1100 | - $temp_array['flight_country'] = $row['name']; |
|
| 1101 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1102 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1103 | - $flight_array[] = $temp_array; |
|
| 1099 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1100 | + $temp_array['flight_country'] = $row['name']; |
|
| 1101 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1102 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1103 | + $flight_array[] = $temp_array; |
|
| 1104 | 1104 | } |
| 1105 | 1105 | return $flight_array; |
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - /** |
|
| 1109 | - * Gets all number of flight over countries |
|
| 1110 | - * |
|
| 1111 | - * @return Array the airline country list |
|
| 1112 | - * |
|
| 1113 | - */ |
|
| 1114 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1115 | - { |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + /** |
|
| 1109 | + * Gets all number of flight over countries |
|
| 1110 | + * |
|
| 1111 | + * @return Array the airline country list |
|
| 1112 | + * |
|
| 1113 | + */ |
|
| 1114 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1115 | + { |
|
| 1116 | 1116 | global $globalDBdriver; |
| 1117 | 1117 | /* |
| 1118 | 1118 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1122,14 +1122,14 @@ discard block |
||
| 1122 | 1122 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1123 | 1123 | FROM countries c, tracker_archive s, spotter_output o |
| 1124 | 1124 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
| 1125 | - if ($olderthanmonths > 0) { |
|
| 1126 | - if ($globalDBdriver == 'mysql') { |
|
| 1125 | + if ($olderthanmonths > 0) { |
|
| 1126 | + if ($globalDBdriver == 'mysql') { |
|
| 1127 | 1127 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1128 | 1128 | } else { |
| 1129 | 1129 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1130 | 1130 | } |
| 1131 | 1131 | } |
| 1132 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1132 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1133 | 1133 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1134 | 1134 | if ($limit) $query .= " LIMIT 0,10"; |
| 1135 | 1135 | |
@@ -1142,24 +1142,24 @@ discard block |
||
| 1142 | 1142 | |
| 1143 | 1143 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1144 | 1144 | { |
| 1145 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1146 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1147 | - $temp_array['flight_country'] = $row['name']; |
|
| 1148 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1149 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1150 | - $flight_array[] = $temp_array; |
|
| 1145 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1146 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1147 | + $temp_array['flight_country'] = $row['name']; |
|
| 1148 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1149 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1150 | + $flight_array[] = $temp_array; |
|
| 1151 | 1151 | } |
| 1152 | 1152 | return $flight_array; |
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - /** |
|
| 1156 | - * Gets last spotter information based on a particular callsign |
|
| 1157 | - * |
|
| 1158 | - * @return Array the spotter information |
|
| 1159 | - * |
|
| 1160 | - */ |
|
| 1161 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1162 | - { |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + /** |
|
| 1156 | + * Gets last spotter information based on a particular callsign |
|
| 1157 | + * |
|
| 1158 | + * @return Array the spotter information |
|
| 1159 | + * |
|
| 1160 | + */ |
|
| 1161 | + public function getDateArchiveTrackerDataById($id,$date) |
|
| 1162 | + { |
|
| 1163 | 1163 | $Tracker = new Tracker($this->db); |
| 1164 | 1164 | date_default_timezone_set('UTC'); |
| 1165 | 1165 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1167,16 +1167,16 @@ discard block |
||
| 1167 | 1167 | $date = date('c',$date); |
| 1168 | 1168 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1169 | 1169 | return $spotter_array; |
| 1170 | - } |
|
| 1171 | - |
|
| 1172 | - /** |
|
| 1173 | - * Gets all the spotter information based on a particular callsign |
|
| 1174 | - * |
|
| 1175 | - * @return Array the spotter information |
|
| 1176 | - * |
|
| 1177 | - */ |
|
| 1178 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1179 | - { |
|
| 1170 | + } |
|
| 1171 | + |
|
| 1172 | + /** |
|
| 1173 | + * Gets all the spotter information based on a particular callsign |
|
| 1174 | + * |
|
| 1175 | + * @return Array the spotter information |
|
| 1176 | + * |
|
| 1177 | + */ |
|
| 1178 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1179 | + { |
|
| 1180 | 1180 | $Tracker = new Tracker($this->db); |
| 1181 | 1181 | date_default_timezone_set('UTC'); |
| 1182 | 1182 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1184,16 +1184,16 @@ discard block |
||
| 1184 | 1184 | $date = date('c',$date); |
| 1185 | 1185 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1186 | 1186 | return $spotter_array; |
| 1187 | - } |
|
| 1188 | - |
|
| 1189 | - /** |
|
| 1190 | - * Gets all the spotter information based on the airport |
|
| 1191 | - * |
|
| 1192 | - * @return Array the spotter information |
|
| 1193 | - * |
|
| 1194 | - */ |
|
| 1195 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1196 | - { |
|
| 1187 | + } |
|
| 1188 | + |
|
| 1189 | + /** |
|
| 1190 | + * Gets all the spotter information based on the airport |
|
| 1191 | + * |
|
| 1192 | + * @return Array the spotter information |
|
| 1193 | + * |
|
| 1194 | + */ |
|
| 1195 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1196 | + { |
|
| 1197 | 1197 | global $global_query; |
| 1198 | 1198 | $Tracker = new Tracker($this->db); |
| 1199 | 1199 | date_default_timezone_set('UTC'); |
@@ -1204,35 +1204,35 @@ discard block |
||
| 1204 | 1204 | |
| 1205 | 1205 | if ($airport != "") |
| 1206 | 1206 | { |
| 1207 | - if (!is_string($airport)) |
|
| 1208 | - { |
|
| 1207 | + if (!is_string($airport)) |
|
| 1208 | + { |
|
| 1209 | 1209 | return false; |
| 1210 | - } else { |
|
| 1210 | + } else { |
|
| 1211 | 1211 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
| 1212 | 1212 | $query_values = array(':airport' => $airport); |
| 1213 | - } |
|
| 1213 | + } |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | if ($limit != "") |
| 1217 | 1217 | { |
| 1218 | - $limit_array = explode(",", $limit); |
|
| 1218 | + $limit_array = explode(",", $limit); |
|
| 1219 | 1219 | |
| 1220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1220 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1222 | 1222 | |
| 1223 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1224 | - { |
|
| 1223 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1224 | + { |
|
| 1225 | 1225 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1226 | 1226 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1227 | - } |
|
| 1227 | + } |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | if ($sort != "") |
| 1231 | 1231 | { |
| 1232 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1233 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1232 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1233 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1234 | 1234 | } else { |
| 1235 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1235 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1240,6 +1240,6 @@ discard block |
||
| 1240 | 1240 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1241 | 1241 | |
| 1242 | 1242 | return $spotter_array; |
| 1243 | - } |
|
| 1243 | + } |
|
| 1244 | 1244 | } |
| 1245 | 1245 | ?> |
| 1246 | 1246 | \ No newline at end of file |
@@ -14,33 +14,33 @@ discard block |
||
| 14 | 14 | * @param Array $filter the filter |
| 15 | 15 | * @return Array the SQL part |
| 16 | 16 | */ |
| 17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 19 | 19 | $filters = array(); |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
| 23 | 23 | } else { |
| 24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if (isset($filter[0]['source'])) { |
| 28 | - $filters = array_merge($filters,$filter); |
|
| 28 | + $filters = array_merge($filters, $filter); |
|
| 29 | 29 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 31 | 31 | $filter_query_join = ''; |
| 32 | 32 | $filter_query_where = ''; |
| 33 | - foreach($filters as $flt) { |
|
| 33 | + foreach ($filters as $flt) { |
|
| 34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 35 | 35 | if (isset($flt['source'])) { |
| 36 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,38 +68,38 @@ discard block |
||
| 68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 71 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 75 | 75 | } |
| 76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 78 | 78 | if ($filter_query_where != '') { |
| 79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 80 | 80 | } |
| 81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
| 82 | 82 | return $filter_query; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // tracker_archive |
| 86 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
| 86 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 88 | 88 | if ($over_country == '') { |
| 89 | 89 | $Tracker = new Tracker($this->db); |
| 90 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 90 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 92 | 92 | else $country = ''; |
| 93 | 93 | } else $country = $over_country; |
| 94 | 94 | // Route is not added in tracker_archive |
| 95 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 95 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 96 | 96 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 97 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 97 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 98 | 98 | try { |
| 99 | 99 | $sth = $this->db->prepare($query); |
| 100 | 100 | $sth->execute($query_values); |
| 101 | 101 | $sth->closeCursor(); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error : ".$e->getMessage(); |
| 104 | 104 | } |
| 105 | 105 | return "success"; |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 121 | 121 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 123 | 123 | |
| 124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 124 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
| 125 | 125 | |
| 126 | 126 | return $spotter_array; |
| 127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 141 | 141 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
| 142 | 142 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 144 | 144 | |
| 145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 146 | 146 | /* |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 155 | 155 | */ |
| 156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 156 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
| 157 | 157 | |
| 158 | 158 | return $spotter_array; |
| 159 | 159 | } |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | date_default_timezone_set('UTC'); |
| 170 | 170 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 172 | 172 | |
| 173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 174 | 174 | |
| 175 | 175 | try { |
| 176 | 176 | $sth = $this->db->prepare($query); |
| 177 | 177 | $sth->execute(array(':id' => $id)); |
| 178 | - } catch(PDOException $e) { |
|
| 178 | + } catch (PDOException $e) { |
|
| 179 | 179 | echo $e->getMessage(); |
| 180 | 180 | die; |
| 181 | 181 | } |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | date_default_timezone_set('UTC'); |
| 196 | 196 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 198 | 198 | |
| 199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 200 | |
| 201 | 201 | try { |
| 202 | 202 | $sth = $this->db->prepare($query); |
| 203 | 203 | $sth->execute(array(':id' => $id)); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | echo $e->getMessage(); |
| 206 | 206 | die; |
| 207 | 207 | } |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | date_default_timezone_set('UTC'); |
| 224 | 224 | |
| 225 | 225 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 227 | 227 | |
| 228 | 228 | try { |
| 229 | 229 | $sth = $this->db->prepare($query); |
| 230 | 230 | $sth->execute(array(':ident' => $ident)); |
| 231 | - } catch(PDOException $e) { |
|
| 231 | + } catch (PDOException $e) { |
|
| 232 | 232 | echo $e->getMessage(); |
| 233 | 233 | die; |
| 234 | 234 | } |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | date_default_timezone_set('UTC'); |
| 250 | 250 | |
| 251 | 251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | 253 | |
| 254 | 254 | try { |
| 255 | 255 | $sth = $this->db->prepare($query); |
| 256 | 256 | $sth->execute(array(':id' => $id)); |
| 257 | - } catch(PDOException $e) { |
|
| 257 | + } catch (PDOException $e) { |
|
| 258 | 258 | echo $e->getMessage(); |
| 259 | 259 | die; |
| 260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | date_default_timezone_set('UTC'); |
| 276 | 276 | |
| 277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | $sth = $this->db->prepare($query); |
| 282 | 282 | $sth->execute(array(':id' => $id)); |
| 283 | - } catch(PDOException $e) { |
|
| 283 | + } catch (PDOException $e) { |
|
| 284 | 284 | echo $e->getMessage(); |
| 285 | 285 | die; |
| 286 | 286 | } |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | date_default_timezone_set('UTC'); |
| 303 | 303 | |
| 304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 307 | 307 | |
| 308 | 308 | try { |
| 309 | 309 | $sth = $this->db->prepare($query); |
| 310 | 310 | $sth->execute(array(':ident' => $ident)); |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | echo $e->getMessage(); |
| 313 | 313 | die; |
| 314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | * @return Array the spotter information |
| 326 | 326 | * |
| 327 | 327 | */ |
| 328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 328 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
| 329 | 329 | { |
| 330 | 330 | $Tracker = new Tracker($this->db); |
| 331 | 331 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 333 | 333 | |
| 334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 334 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
| 335 | 335 | |
| 336 | 336 | return $spotter_array; |
| 337 | 337 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | try { |
| 345 | 345 | $sth = $this->db->prepare($query); |
| 346 | 346 | $sth->execute(); |
| 347 | - } catch(PDOException $e) { |
|
| 347 | + } catch (PDOException $e) { |
|
| 348 | 348 | echo $e->getMessage(); |
| 349 | 349 | die; |
| 350 | 350 | } |
@@ -356,24 +356,24 @@ discard block |
||
| 356 | 356 | * @return Array the spotter information |
| 357 | 357 | * |
| 358 | 358 | */ |
| 359 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 359 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
| 360 | 360 | { |
| 361 | 361 | global $globalDBdriver, $globalLiveInterval; |
| 362 | 362 | date_default_timezone_set('UTC'); |
| 363 | 363 | |
| 364 | 364 | $filter_query = ''; |
| 365 | 365 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 366 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 366 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 367 | 367 | } |
| 368 | 368 | // Use spotter_output also ? |
| 369 | 369 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 370 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 370 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 371 | 371 | } |
| 372 | 372 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 373 | 373 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 374 | 374 | } |
| 375 | 375 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 376 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 376 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 393 | 393 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 394 | 394 | */ |
| 395 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 395 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 396 | 396 | FROM tracker_archive |
| 397 | 397 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 398 | 398 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 399 | 399 | '.$filter_query.' ORDER BY famtrackid'; |
| 400 | 400 | } else { |
| 401 | 401 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
| 402 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 402 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 403 | 403 | FROM tracker_archive |
| 404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 405 | 405 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | try { |
| 410 | 410 | $sth = $this->db->prepare($query); |
| 411 | 411 | $sth->execute(); |
| 412 | - } catch(PDOException $e) { |
|
| 412 | + } catch (PDOException $e) { |
|
| 413 | 413 | echo $e->getMessage(); |
| 414 | 414 | die; |
| 415 | 415 | } |
@@ -424,24 +424,24 @@ discard block |
||
| 424 | 424 | * @return Array the spotter information |
| 425 | 425 | * |
| 426 | 426 | */ |
| 427 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 427 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
| 428 | 428 | { |
| 429 | 429 | global $globalDBdriver, $globalLiveInterval; |
| 430 | 430 | date_default_timezone_set('UTC'); |
| 431 | 431 | |
| 432 | 432 | $filter_query = ''; |
| 433 | 433 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 434 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 434 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 435 | 435 | } |
| 436 | 436 | // Should use spotter_output also ? |
| 437 | 437 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 438 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 438 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 439 | 439 | } |
| 440 | 440 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 441 | 441 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 442 | 442 | } |
| 443 | 443 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 444 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 444 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | FROM tracker_archive |
| 452 | 452 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 453 | 453 | */ |
| 454 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 454 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 455 | 455 | FROM tracker_archive_output |
| 456 | 456 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 457 | 457 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 467 | 467 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 468 | 468 | */ |
| 469 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 469 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 470 | 470 | FROM tracker_archive_output |
| 471 | 471 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 472 | 472 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | try { |
| 479 | 479 | $sth = $this->db->prepare($query); |
| 480 | 480 | $sth->execute(); |
| 481 | - } catch(PDOException $e) { |
|
| 481 | + } catch (PDOException $e) { |
|
| 482 | 482 | echo $e->getMessage(); |
| 483 | 483 | die; |
| 484 | 484 | } |
@@ -493,23 +493,23 @@ discard block |
||
| 493 | 493 | * @return Array the spotter information |
| 494 | 494 | * |
| 495 | 495 | */ |
| 496 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 496 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
| 497 | 497 | { |
| 498 | 498 | global $globalDBdriver, $globalLiveInterval; |
| 499 | 499 | date_default_timezone_set('UTC'); |
| 500 | 500 | |
| 501 | 501 | $filter_query = ''; |
| 502 | 502 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 503 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 503 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 504 | 504 | } |
| 505 | 505 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 506 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 506 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 507 | 507 | } |
| 508 | 508 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 509 | 509 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 510 | 510 | } |
| 511 | 511 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 512 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 512 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | try { |
| 525 | 525 | $sth = $this->db->prepare($query); |
| 526 | 526 | $sth->execute(); |
| 527 | - } catch(PDOException $e) { |
|
| 527 | + } catch (PDOException $e) { |
|
| 528 | 528 | echo $e->getMessage(); |
| 529 | 529 | die; |
| 530 | 530 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @return Array the spotter information |
| 545 | 545 | * |
| 546 | 546 | */ |
| 547 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 547 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 548 | 548 | { |
| 549 | 549 | global $globalTimezone, $globalDBdriver; |
| 550 | 550 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | $q_array = explode(" ", $q); |
| 568 | 568 | |
| 569 | - foreach ($q_array as $q_item){ |
|
| 569 | + foreach ($q_array as $q_item) { |
|
| 570 | 570 | $additional_query .= " AND ("; |
| 571 | 571 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 572 | 572 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | if ($registration != "") |
| 600 | 600 | { |
| 601 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 601 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 602 | 602 | if (!is_string($registration)) |
| 603 | 603 | { |
| 604 | 604 | return false; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | if ($aircraft_icao != "") |
| 611 | 611 | { |
| 612 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 612 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 613 | 613 | if (!is_string($aircraft_icao)) |
| 614 | 614 | { |
| 615 | 615 | return false; |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | if ($aircraft_manufacturer != "") |
| 622 | 622 | { |
| 623 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 623 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 624 | 624 | if (!is_string($aircraft_manufacturer)) |
| 625 | 625 | { |
| 626 | 626 | return false; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | if ($airline_icao != "") |
| 643 | 643 | { |
| 644 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 644 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 645 | 645 | if (!is_string($airline_icao)) |
| 646 | 646 | { |
| 647 | 647 | return false; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if ($airline_country != "") |
| 654 | 654 | { |
| 655 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 655 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 656 | 656 | if (!is_string($airline_country)) |
| 657 | 657 | { |
| 658 | 658 | return false; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | if ($airline_type != "") |
| 665 | 665 | { |
| 666 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 666 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 667 | 667 | if (!is_string($airline_type)) |
| 668 | 668 | { |
| 669 | 669 | return false; |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | if ($airport != "") |
| 687 | 687 | { |
| 688 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 688 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 689 | 689 | if (!is_string($airport)) |
| 690 | 690 | { |
| 691 | 691 | return false; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | if ($airport_country != "") |
| 698 | 698 | { |
| 699 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 699 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 700 | 700 | if (!is_string($airport_country)) |
| 701 | 701 | { |
| 702 | 702 | return false; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | if ($callsign != "") |
| 709 | 709 | { |
| 710 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 710 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 711 | 711 | if (!is_string($callsign)) |
| 712 | 712 | { |
| 713 | 713 | return false; |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | $translate = $Translation->ident2icao($callsign); |
| 716 | 716 | if ($translate != $callsign) { |
| 717 | 717 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
| 718 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 718 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 719 | 719 | } else { |
| 720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 721 | 721 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($owner != "") |
| 726 | 726 | { |
| 727 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 727 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($owner)) |
| 729 | 729 | { |
| 730 | 730 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($pilot_name != "") |
| 737 | 737 | { |
| 738 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 738 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($pilot_name)) |
| 740 | 740 | { |
| 741 | 741 | return false; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ($pilot_id != "") |
| 748 | 748 | { |
| 749 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 749 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 750 | 750 | if (!is_string($pilot_id)) |
| 751 | 751 | { |
| 752 | 752 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($departure_airport_route != "") |
| 759 | 759 | { |
| 760 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 760 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($departure_airport_route)) |
| 762 | 762 | { |
| 763 | 763 | return false; |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($arrival_airport_route != "") |
| 770 | 770 | { |
| 771 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 771 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($arrival_airport_route)) |
| 773 | 773 | { |
| 774 | 774 | return false; |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | { |
| 782 | 782 | $altitude_array = explode(",", $altitude); |
| 783 | 783 | |
| 784 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 786 | 786 | |
| 787 | 787 | |
| 788 | 788 | if ($altitude_array[1] != "") |
@@ -800,8 +800,8 @@ discard block |
||
| 800 | 800 | { |
| 801 | 801 | $date_array = explode(",", $date_posted); |
| 802 | 802 | |
| 803 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 804 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 803 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 804 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 805 | 805 | |
| 806 | 806 | if ($globalTimezone != '') { |
| 807 | 807 | date_default_timezone_set($globalTimezone); |
@@ -833,8 +833,8 @@ discard block |
||
| 833 | 833 | { |
| 834 | 834 | $limit_array = explode(",", $limit); |
| 835 | 835 | |
| 836 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | 838 | |
| 839 | 839 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 840 | 840 | { |
@@ -845,8 +845,8 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | |
| 847 | 847 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 848 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 849 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 848 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 849 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 850 | 850 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 851 | 851 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 852 | 852 | } else { |
@@ -863,12 +863,12 @@ discard block |
||
| 863 | 863 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 866 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 867 | 867 | WHERE tracker_archive_output.ident <> '' |
| 868 | 868 | ".$additional_query." |
| 869 | 869 | ".$filter_query.$orderby_query; |
| 870 | 870 | } |
| 871 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 871 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 872 | 872 | |
| 873 | 873 | return $spotter_array; |
| 874 | 874 | } |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | try { |
| 886 | 886 | $sth = $this->db->prepare($query); |
| 887 | 887 | $sth->execute(); |
| 888 | - } catch(PDOException $e) { |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | return "error"; |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -922,8 +922,8 @@ discard block |
||
| 922 | 922 | { |
| 923 | 923 | $limit_array = explode(",", $limit); |
| 924 | 924 | |
| 925 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | 927 | |
| 928 | 928 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 929 | 929 | { |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | $query_values = array(); |
| 965 | 965 | $limit_query = ''; |
| 966 | 966 | $additional_query = ''; |
| 967 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 967 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 968 | 968 | |
| 969 | 969 | if ($owner != "") |
| 970 | 970 | { |
@@ -981,8 +981,8 @@ discard block |
||
| 981 | 981 | { |
| 982 | 982 | $limit_array = explode(",", $limit); |
| 983 | 983 | |
| 984 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 986 | 986 | |
| 987 | 987 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 988 | 988 | { |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | $query_values = array(); |
| 1023 | 1023 | $limit_query = ''; |
| 1024 | 1024 | $additional_query = ''; |
| 1025 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1025 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1026 | 1026 | |
| 1027 | 1027 | if ($pilot != "") |
| 1028 | 1028 | { |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | { |
| 1035 | 1035 | $limit_array = explode(",", $limit); |
| 1036 | 1036 | |
| 1037 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1037 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1039 | 1039 | |
| 1040 | 1040 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1041 | 1041 | { |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * @return Array the airline country list |
| 1066 | 1066 | * |
| 1067 | 1067 | */ |
| 1068 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1068 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1069 | 1069 | { |
| 1070 | 1070 | global $globalDBdriver; |
| 1071 | 1071 | /* |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | $flight_array = array(); |
| 1095 | 1095 | $temp_array = array(); |
| 1096 | 1096 | |
| 1097 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1097 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | $temp_array['flight_count'] = $row['nb']; |
| 1100 | 1100 | $temp_array['flight_country'] = $row['name']; |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | * @return Array the airline country list |
| 1112 | 1112 | * |
| 1113 | 1113 | */ |
| 1114 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1114 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1115 | 1115 | { |
| 1116 | 1116 | global $globalDBdriver; |
| 1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | $flight_array = array(); |
| 1141 | 1141 | $temp_array = array(); |
| 1142 | 1142 | |
| 1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1144 | 1144 | { |
| 1145 | 1145 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1146 | 1146 | $temp_array['flight_count'] = $row['nb']; |
@@ -1158,14 +1158,14 @@ discard block |
||
| 1158 | 1158 | * @return Array the spotter information |
| 1159 | 1159 | * |
| 1160 | 1160 | */ |
| 1161 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1161 | + public function getDateArchiveTrackerDataById($id, $date) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | $Tracker = new Tracker($this->db); |
| 1164 | 1164 | date_default_timezone_set('UTC'); |
| 1165 | 1165 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1166 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1167 | - $date = date('c',$date); |
|
| 1168 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1166 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1167 | + $date = date('c', $date); |
|
| 1168 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1169 | 1169 | return $spotter_array; |
| 1170 | 1170 | } |
| 1171 | 1171 | |
@@ -1175,14 +1175,14 @@ discard block |
||
| 1175 | 1175 | * @return Array the spotter information |
| 1176 | 1176 | * |
| 1177 | 1177 | */ |
| 1178 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1178 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
| 1179 | 1179 | { |
| 1180 | 1180 | $Tracker = new Tracker($this->db); |
| 1181 | 1181 | date_default_timezone_set('UTC'); |
| 1182 | 1182 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1183 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1184 | - $date = date('c',$date); |
|
| 1185 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1183 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1184 | + $date = date('c', $date); |
|
| 1185 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1186 | 1186 | return $spotter_array; |
| 1187 | 1187 | } |
| 1188 | 1188 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @return Array the spotter information |
| 1193 | 1193 | * |
| 1194 | 1194 | */ |
| 1195 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1195 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1196 | 1196 | { |
| 1197 | 1197 | global $global_query; |
| 1198 | 1198 | $Tracker = new Tracker($this->db); |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | $query_values = array(); |
| 1201 | 1201 | $limit_query = ''; |
| 1202 | 1202 | $additional_query = ''; |
| 1203 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1203 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1204 | 1204 | |
| 1205 | 1205 | if ($airport != "") |
| 1206 | 1206 | { |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | { |
| 1218 | 1218 | $limit_array = explode(",", $limit); |
| 1219 | 1219 | |
| 1220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1220 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1222 | 1222 | |
| 1223 | 1223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1224 | 1224 | { |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function checkAll() { |
| 55 | 55 | global $globalDebug; |
| 56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo "Update last seen tracked data...\n"; |
|
| 58 | + } |
|
| 57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
| 66 | 68 | public function del() { |
| 67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 70 | // Delete old infos |
| 69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 71 | + if ($globalDebug) { |
|
| 72 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 73 | + } |
|
| 70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 75 | if (isset($flight['lastupdate'])) { |
| 72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
| 73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 81 | + } |
|
| 76 | 82 | /* |
| 77 | 83 | $MarineLive = new MarineLive(); |
| 78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
| 82 | 88 | $Marine = new Marine($this->db); |
| 83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 91 | + if ($globalDebug && $result != 'success') { |
|
| 92 | + echo '!!! ERROR : '.$result."\n"; |
|
| 93 | + } |
|
| 86 | 94 | } |
| 87 | 95 | // Put in archive |
| 88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
| 96 | 104 | |
| 97 | 105 | public function add($line) { |
| 98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 108 | + $globalCoordMinChange = '0.02'; |
|
| 109 | + } |
|
| 100 | 110 | date_default_timezone_set('UTC'); |
| 101 | 111 | $dataFound = false; |
| 102 | 112 | $send = false; |
@@ -110,20 +120,30 @@ discard block |
||
| 110 | 120 | // Increment message number |
| 111 | 121 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 112 | 122 | $current_date = date('Y-m-d'); |
| 113 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 114 | - else $source = ''; |
|
| 115 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 123 | + if (isset($line['source_name'])) { |
|
| 124 | + $source = $line['source_name']; |
|
| 125 | + } else { |
|
| 126 | + $source = ''; |
|
| 127 | + } |
|
| 128 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 129 | + $source = $line['format_source']; |
|
| 130 | + } |
|
| 116 | 131 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 117 | 132 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 118 | 133 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 119 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 134 | + } else { |
|
| 135 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 136 | + } |
|
| 120 | 137 | } |
| 121 | 138 | |
| 122 | 139 | |
| 123 | 140 | $Common = new Common(); |
| 124 | 141 | $AIS = new AIS(); |
| 125 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 126 | - else $id = trim($line['id']); |
|
| 142 | + if (!isset($line['id'])) { |
|
| 143 | + $id = trim($line['mmsi']); |
|
| 144 | + } else { |
|
| 145 | + $id = trim($line['id']); |
|
| 146 | + } |
|
| 127 | 147 | |
| 128 | 148 | if (!isset($this->all_tracked[$id])) { |
| 129 | 149 | $this->all_tracked[$id] = array(); |
@@ -131,10 +151,16 @@ discard block |
||
| 131 | 151 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
| 132 | 152 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 133 | 153 | if (!isset($line['id'])) { |
| 134 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 154 | + if (!isset($globalDaemon)) { |
|
| 155 | + $globalDaemon = TRUE; |
|
| 156 | + } |
|
| 135 | 157 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 136 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 137 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 158 | + } else { |
|
| 159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 160 | + } |
|
| 161 | + if ($globalAllTracked !== FALSE) { |
|
| 162 | + $dataFound = true; |
|
| 163 | + } |
|
| 138 | 164 | } |
| 139 | 165 | |
| 140 | 166 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -184,34 +210,49 @@ discard block |
||
| 184 | 210 | $Marine = new Marine($this->db); |
| 185 | 211 | $fromsource = NULL; |
| 186 | 212 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 213 | + if ($globalDebug && $result != 'success') { |
|
| 214 | + echo '!!! ERROR : '.$result."\n"; |
|
| 215 | + } |
|
| 188 | 216 | $Marine->db = null; |
| 189 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 217 | + if ($globalDebugTimeElapsed) { |
|
| 218 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 219 | + } |
|
| 190 | 220 | } |
| 191 | 221 | } |
| 192 | 222 | } |
| 193 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 223 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 225 | + } |
|
| 194 | 226 | } |
| 195 | 227 | |
| 196 | 228 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 197 | 229 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 198 | 230 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 199 | 231 | } else { |
| 200 | - 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"; |
|
| 201 | - 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"; |
|
| 232 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 233 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 234 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 235 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 236 | + } |
|
| 202 | 237 | return ''; |
| 203 | 238 | } |
| 204 | 239 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 205 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 240 | + if ($globalDebug) { |
|
| 241 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 242 | + } |
|
| 206 | 243 | return ''; |
| 207 | 244 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 208 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 247 | + } |
|
| 209 | 248 | return ''; |
| 210 | 249 | } elseif (!isset($line['datetime'])) { |
| 211 | 250 | date_default_timezone_set('UTC'); |
| 212 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 213 | 252 | } else { |
| 214 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 253 | + if ($globalDebug) { |
|
| 254 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 255 | + } |
|
| 215 | 256 | return ''; |
| 216 | 257 | } |
| 217 | 258 | |
@@ -224,14 +265,21 @@ discard block |
||
| 224 | 265 | if ($distance > 1000 && $distance < 10000) { |
| 225 | 266 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 226 | 267 | $speed = $speed*3.6; |
| 227 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 228 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 268 | + if ($speed < 1000) { |
|
| 269 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 270 | + } |
|
| 271 | + if ($globalDebug) { |
|
| 272 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 273 | + } |
|
| 229 | 274 | } |
| 230 | 275 | } |
| 231 | 276 | |
| 232 | 277 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 233 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 234 | - else unset($timediff); |
|
| 278 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 279 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 280 | + } else { |
|
| 281 | + unset($timediff); |
|
| 282 | + } |
|
| 235 | 283 | 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')))) { |
| 236 | 284 | 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'])) { |
| 237 | 285 | 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'])) { |
@@ -239,22 +287,32 @@ discard block |
||
| 239 | 287 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 240 | 288 | $this->all_tracked[$id]['putinarchive'] = true; |
| 241 | 289 | |
| 242 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 290 | + if ($globalDebug) { |
|
| 291 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 292 | + } |
|
| 243 | 293 | $timeelapsed = microtime(true); |
| 244 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 245 | 295 | $Marine = new Marine($this->db); |
| 246 | 296 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 247 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 297 | + if (!empty($all_country)) { |
|
| 298 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 299 | + } |
|
| 248 | 300 | $Marine->db = null; |
| 249 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 301 | + if ($globalDebugTimeElapsed) { |
|
| 302 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 303 | + } |
|
| 250 | 304 | } |
| 251 | 305 | $this->tmd = 0; |
| 252 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 306 | + if ($globalDebug) { |
|
| 307 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 308 | + } |
|
| 253 | 309 | } |
| 254 | 310 | } |
| 255 | 311 | |
| 256 | 312 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 257 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 313 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 314 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 315 | + } |
|
| 258 | 316 | 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') { |
| 259 | 317 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 260 | 318 | $dataFound = true; |
@@ -263,8 +321,12 @@ discard block |
||
| 263 | 321 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 264 | 322 | } |
| 265 | 323 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 266 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 267 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 324 | + if ($line['longitude'] > 180) { |
|
| 325 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 326 | + } |
|
| 327 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 328 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 329 | + } |
|
| 268 | 330 | 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') { |
| 269 | 331 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 270 | 332 | $dataFound = true; |
@@ -282,7 +344,9 @@ discard block |
||
| 282 | 344 | } |
| 283 | 345 | } |
| 284 | 346 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 285 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 347 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 348 | + $dataFound = true; |
|
| 349 | + } |
|
| 286 | 350 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 287 | 351 | } |
| 288 | 352 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -312,15 +376,21 @@ discard block |
||
| 312 | 376 | } |
| 313 | 377 | |
| 314 | 378 | if (isset($line['heading']) && $line['heading'] != '') { |
| 315 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 379 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 380 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 381 | + } |
|
| 316 | 382 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 317 | 383 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 318 | 384 | //$dataFound = true; |
| 319 | 385 | } 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']) { |
| 320 | 386 | $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']); |
| 321 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 322 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 323 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 389 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 390 | + } |
|
| 391 | + if ($globalDebug) { |
|
| 392 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 393 | + } |
|
| 324 | 394 | } |
| 325 | 395 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 326 | 396 | |
@@ -332,23 +402,38 @@ discard block |
||
| 332 | 402 | 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'])) { |
| 333 | 403 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 334 | 404 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 335 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 405 | + if ($globalDebug) { |
|
| 406 | + echo "Check if aircraft is already in DB..."; |
|
| 407 | + } |
|
| 336 | 408 | $timeelapsed = microtime(true); |
| 337 | 409 | $MarineLive = new MarineLive($this->db); |
| 338 | 410 | if (isset($line['id'])) { |
| 339 | 411 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 340 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 412 | + if ($globalDebugTimeElapsed) { |
|
| 413 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 414 | + } |
|
| 341 | 415 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 342 | 416 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 417 | + if ($globalDebugTimeElapsed) { |
|
| 418 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 419 | + } |
|
| 344 | 420 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 345 | 421 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 347 | - } else $recent_ident = ''; |
|
| 422 | + if ($globalDebugTimeElapsed) { |
|
| 423 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 424 | + } |
|
| 425 | + } else { |
|
| 426 | + $recent_ident = ''; |
|
| 427 | + } |
|
| 348 | 428 | $MarineLive->db=null; |
| 349 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 350 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 351 | - } else $recent_ident = ''; |
|
| 429 | + if ($globalDebug && $recent_ident == '') { |
|
| 430 | + echo " Not in DB.\n"; |
|
| 431 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 432 | + echo " Already in DB.\n"; |
|
| 433 | + } |
|
| 434 | + } else { |
|
| 435 | + $recent_ident = ''; |
|
| 436 | + } |
|
| 352 | 437 | } else { |
| 353 | 438 | $recent_ident = ''; |
| 354 | 439 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -356,30 +441,44 @@ discard block |
||
| 356 | 441 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 357 | 442 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 358 | 443 | { |
| 359 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 444 | + if ($globalDebug) { |
|
| 445 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 446 | + } |
|
| 360 | 447 | //adds the spotter data for the archive |
| 361 | 448 | $highlight = ''; |
| 362 | - 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'))); |
|
| 449 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 450 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 451 | + } |
|
| 363 | 452 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 364 | 453 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 365 | 454 | $timeelapsed = microtime(true); |
| 366 | 455 | $Marine = new Marine($this->db); |
| 367 | 456 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 368 | 457 | $Marine->db = null; |
| 369 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 370 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 458 | + if ($globalDebug && isset($result)) { |
|
| 459 | + echo $result."\n"; |
|
| 460 | + } |
|
| 461 | + if ($globalDebugTimeElapsed) { |
|
| 462 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 463 | + } |
|
| 371 | 464 | } |
| 372 | 465 | } |
| 373 | 466 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 374 | 467 | // Add source stat in DB |
| 375 | 468 | $Stats = new Stats($this->db); |
| 376 | 469 | if (!empty($this->stats)) { |
| 377 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 470 | + if ($globalDebug) { |
|
| 471 | + echo 'Add source stats : '; |
|
| 472 | + } |
|
| 378 | 473 | foreach($this->stats as $date => $data) { |
| 379 | 474 | foreach($data as $source => $sourced) { |
| 380 | 475 | //print_r($sourced); |
| 381 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 382 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 476 | + if (isset($sourced['polar'])) { |
|
| 477 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 478 | + } |
|
| 479 | + if (isset($sourced['hist'])) { |
|
| 480 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 481 | + } |
|
| 383 | 482 | if (isset($sourced['msg'])) { |
| 384 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
| 385 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -392,7 +491,9 @@ discard block |
||
| 392 | 491 | unset($this->stats[$date]); |
| 393 | 492 | } |
| 394 | 493 | } |
| 395 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 494 | + if ($globalDebug) { |
|
| 495 | + echo 'Done'."\n"; |
|
| 496 | + } |
|
| 396 | 497 | } |
| 397 | 498 | $Stats->db = null; |
| 398 | 499 | } |
@@ -402,13 +503,17 @@ discard block |
||
| 402 | 503 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 403 | 504 | //print_r($this->all_tracked[$id]); |
| 404 | 505 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 405 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 506 | + if ($globalDebug) { |
|
| 507 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 508 | + } |
|
| 406 | 509 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 407 | 510 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 408 | 511 | $MarineLive = new MarineLive($this->db); |
| 409 | 512 | $MarineLive->deleteLiveMarineData(); |
| 410 | 513 | $MarineLive->db=null; |
| 411 | - if ($globalDebug) echo " Done\n"; |
|
| 514 | + if ($globalDebug) { |
|
| 515 | + echo " Done\n"; |
|
| 516 | + } |
|
| 412 | 517 | } |
| 413 | 518 | $this->last_delete = time(); |
| 414 | 519 | } |
@@ -434,15 +539,21 @@ discard block |
||
| 434 | 539 | |
| 435 | 540 | if (!$ignoreImport) { |
| 436 | 541 | 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'])) { |
| 437 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 542 | + if ($globalDebug) { |
|
| 543 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 544 | + } |
|
| 438 | 545 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 439 | 546 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 440 | 547 | $timeelapsed = microtime(true); |
| 441 | 548 | $MarineLive = new MarineLive($this->db); |
| 442 | 549 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 443 | 550 | $MarineLive->db = null; |
| 444 | - if ($globalDebug) echo $result."\n"; |
|
| 445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 551 | + if ($globalDebug) { |
|
| 552 | + echo $result."\n"; |
|
| 553 | + } |
|
| 554 | + if ($globalDebugTimeElapsed) { |
|
| 555 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 556 | + } |
|
| 446 | 557 | } |
| 447 | 558 | } |
| 448 | 559 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -454,7 +565,9 @@ discard block |
||
| 454 | 565 | |
| 455 | 566 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 456 | 567 | $source = $this->all_tracked[$id]['source_name']; |
| 457 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 568 | + if ($source == '') { |
|
| 569 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 570 | + } |
|
| 458 | 571 | if (!isset($this->source_location[$source])) { |
| 459 | 572 | $Location = new Source($this->db); |
| 460 | 573 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -475,7 +588,9 @@ discard block |
||
| 475 | 588 | $stats_heading = round($stats_heading/22.5); |
| 476 | 589 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 477 | 590 | $current_date = date('Y-m-d'); |
| 478 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 591 | + if ($stats_heading == 16) { |
|
| 592 | + $stats_heading = 0; |
|
| 593 | + } |
|
| 479 | 594 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 480 | 595 | for ($i=0;$i<=15;$i++) { |
| 481 | 596 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -493,7 +608,9 @@ discard block |
||
| 493 | 608 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 494 | 609 | end($this->stats[$current_date][$source]['hist']); |
| 495 | 610 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 496 | - } else $mini = 0; |
|
| 611 | + } else { |
|
| 612 | + $mini = 0; |
|
| 613 | + } |
|
| 497 | 614 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 498 | 615 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 499 | 616 | } |
@@ -505,19 +622,27 @@ discard block |
||
| 505 | 622 | |
| 506 | 623 | |
| 507 | 624 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 508 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 509 | - } 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"; |
|
| 625 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 626 | + $send = true; |
|
| 627 | + } |
|
| 628 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 629 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 630 | + } |
|
| 510 | 631 | //$this->del(); |
| 511 | 632 | |
| 512 | 633 | |
| 513 | 634 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 514 | 635 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 515 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 636 | + if ($globalDebug) { |
|
| 637 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 638 | + } |
|
| 516 | 639 | $MarineLive = new MarineLive($this->db); |
| 517 | 640 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 518 | 641 | $MarineLive->db = null; |
| 519 | 642 | //MarineLive->deleteLiveMarineData(); |
| 520 | - if ($globalDebug) echo " Done\n"; |
|
| 643 | + if ($globalDebug) { |
|
| 644 | + echo " Done\n"; |
|
| 645 | + } |
|
| 521 | 646 | } |
| 522 | 647 | $this->last_delete_hourly = time(); |
| 523 | 648 | } |
@@ -526,7 +651,9 @@ discard block |
||
| 526 | 651 | //$ignoreImport = false; |
| 527 | 652 | } |
| 528 | 653 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 529 | - if ($send) return $this->all_tracked[$id]; |
|
| 654 | + if ($send) { |
|
| 655 | + return $this->all_tracked[$id]; |
|
| 656 | + } |
|
| 530 | 657 | } |
| 531 | 658 | } |
| 532 | 659 | } |