@@ -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 | } |
@@ -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,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() { |
@@ -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 | } |
@@ -13,10 +13,14 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct($dbc = null) { |
| 15 | 15 | global $globalFilterName; |
| 16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 16 | + if (isset($globalFilterName)) { |
|
| 17 | + $this->filter_name = $globalFilterName; |
|
| 18 | + } |
|
| 17 | 19 | $Connection = new Connection($dbc); |
| 18 | 20 | $this->db = $Connection->db(); |
| 19 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 21 | + if ($this->db === null) { |
|
| 22 | + die('Error: No DB connection.'); |
|
| 23 | + } |
|
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | |
| 85 | 89 | public function getAllAirlineNames($filter_name = '') { |
| 86 | 90 | global $globalStatsFilters; |
| 87 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 91 | + if ($filter_name == '') { |
|
| 92 | + $filter_name = $this->filter_name; |
|
| 93 | + } |
|
| 88 | 94 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 89 | 95 | try { |
| 90 | 96 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | return $all; |
| 105 | 111 | } |
| 106 | 112 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 113 | + if ($filter_name == '') { |
|
| 114 | + $filter_name = $this->filter_name; |
|
| 115 | + } |
|
| 108 | 116 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 109 | 117 | try { |
| 110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | return $all; |
| 117 | 125 | } |
| 118 | 126 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 127 | + if ($filter_name == '') { |
|
| 128 | + $filter_name = $this->filter_name; |
|
| 129 | + } |
|
| 120 | 130 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 121 | 131 | try { |
| 122 | 132 | $sth = $this->db->prepare($query); |
@@ -128,7 +138,9 @@ discard block |
||
| 128 | 138 | return $all; |
| 129 | 139 | } |
| 130 | 140 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 131 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 141 | + if ($filter_name == '') { |
|
| 142 | + $filter_name = $this->filter_name; |
|
| 143 | + } |
|
| 132 | 144 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 133 | 145 | try { |
| 134 | 146 | $sth = $this->db->prepare($query); |
@@ -141,7 +153,9 @@ discard block |
||
| 141 | 153 | } |
| 142 | 154 | |
| 143 | 155 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 144 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 156 | + if ($filter_name == '') { |
|
| 157 | + $filter_name = $this->filter_name; |
|
| 158 | + } |
|
| 145 | 159 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 146 | 160 | try { |
| 147 | 161 | $sth = $this->db->prepare($query); |
@@ -154,7 +168,9 @@ discard block |
||
| 154 | 168 | } |
| 155 | 169 | |
| 156 | 170 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 171 | + if ($filter_name == '') { |
|
| 172 | + $filter_name = $this->filter_name; |
|
| 173 | + } |
|
| 158 | 174 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 159 | 175 | try { |
| 160 | 176 | $sth = $this->db->prepare($query); |
@@ -169,7 +185,9 @@ discard block |
||
| 169 | 185 | |
| 170 | 186 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 171 | 187 | global $globalStatsFilters; |
| 172 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 188 | + if ($filter_name == '') { |
|
| 189 | + $filter_name = $this->filter_name; |
|
| 190 | + } |
|
| 173 | 191 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 174 | 192 | $Spotter = new Spotter($this->db); |
| 175 | 193 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -178,8 +196,11 @@ discard block |
||
| 178 | 196 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 179 | 197 | } |
| 180 | 198 | if ($year == '' && $month == '') { |
| 181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 199 | + if ($limit) { |
|
| 200 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 201 | + } else { |
|
| 202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 203 | + } |
|
| 183 | 204 | try { |
| 184 | 205 | $sth = $this->db->prepare($query); |
| 185 | 206 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -187,11 +208,16 @@ discard block |
||
| 187 | 208 | echo "error : ".$e->getMessage(); |
| 188 | 209 | } |
| 189 | 210 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 190 | - } else $all = array(); |
|
| 211 | + } else { |
|
| 212 | + $all = array(); |
|
| 213 | + } |
|
| 191 | 214 | } else { |
| 192 | 215 | if ($year == '' && $month == '') { |
| 193 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 194 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 216 | + if ($limit) { |
|
| 217 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 218 | + } else { |
|
| 219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 220 | + } |
|
| 195 | 221 | try { |
| 196 | 222 | $sth = $this->db->prepare($query); |
| 197 | 223 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,7 +225,9 @@ discard block |
||
| 199 | 225 | echo "error : ".$e->getMessage(); |
| 200 | 226 | } |
| 201 | 227 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 202 | - } else $all = array(); |
|
| 228 | + } else { |
|
| 229 | + $all = array(); |
|
| 230 | + } |
|
| 203 | 231 | } |
| 204 | 232 | if (empty($all)) { |
| 205 | 233 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -218,10 +246,15 @@ discard block |
||
| 218 | 246 | } |
| 219 | 247 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 220 | 248 | global $globalStatsFilters; |
| 221 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 249 | + if ($filter_name == '') { |
|
| 250 | + $filter_name = $this->filter_name; |
|
| 251 | + } |
|
| 222 | 252 | if ($year == '' && $month == '') { |
| 223 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 224 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 253 | + if ($limit) { |
|
| 254 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 255 | + } else { |
|
| 256 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
| 257 | + } |
|
| 225 | 258 | try { |
| 226 | 259 | $sth = $this->db->prepare($query); |
| 227 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -229,7 +262,9 @@ discard block |
||
| 229 | 262 | echo "error : ".$e->getMessage(); |
| 230 | 263 | } |
| 231 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 232 | - } else $all = array(); |
|
| 265 | + } else { |
|
| 266 | + $all = array(); |
|
| 267 | + } |
|
| 233 | 268 | if (empty($all)) { |
| 234 | 269 | $Spotter = new Spotter($this->db); |
| 235 | 270 | $filters = array(); |
@@ -244,7 +279,9 @@ discard block |
||
| 244 | 279 | } |
| 245 | 280 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 246 | 281 | global $globalStatsFilters; |
| 247 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 282 | + if ($filter_name == '') { |
|
| 283 | + $filter_name = $this->filter_name; |
|
| 284 | + } |
|
| 248 | 285 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 249 | 286 | $Spotter = new Spotter($this->db); |
| 250 | 287 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -253,8 +290,11 @@ discard block |
||
| 253 | 290 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 254 | 291 | } |
| 255 | 292 | if ($year == '' && $month == '') { |
| 256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 293 | + if ($limit) { |
|
| 294 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 295 | + } else { |
|
| 296 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 297 | + } |
|
| 258 | 298 | try { |
| 259 | 299 | $sth = $this->db->prepare($query); |
| 260 | 300 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -262,11 +302,16 @@ discard block |
||
| 262 | 302 | echo "error : ".$e->getMessage(); |
| 263 | 303 | } |
| 264 | 304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 265 | - } else $all = array(); |
|
| 305 | + } else { |
|
| 306 | + $all = array(); |
|
| 307 | + } |
|
| 266 | 308 | } else { |
| 267 | 309 | if ($year == '' && $month == '') { |
| 268 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 269 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 310 | + if ($limit) { |
|
| 311 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 312 | + } else { |
|
| 313 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 314 | + } |
|
| 270 | 315 | try { |
| 271 | 316 | $sth = $this->db->prepare($query); |
| 272 | 317 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,7 +319,9 @@ discard block |
||
| 274 | 319 | echo "error : ".$e->getMessage(); |
| 275 | 320 | } |
| 276 | 321 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 277 | - } else $all = array(); |
|
| 322 | + } else { |
|
| 323 | + $all = array(); |
|
| 324 | + } |
|
| 278 | 325 | } |
| 279 | 326 | if (empty($all)) { |
| 280 | 327 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -294,7 +341,9 @@ discard block |
||
| 294 | 341 | |
| 295 | 342 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 296 | 343 | global $globalStatsFilters; |
| 297 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 344 | + if ($filter_name == '') { |
|
| 345 | + $filter_name = $this->filter_name; |
|
| 346 | + } |
|
| 298 | 347 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 299 | 348 | $Spotter = new Spotter($this->db); |
| 300 | 349 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -303,8 +352,11 @@ discard block |
||
| 303 | 352 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 304 | 353 | } |
| 305 | 354 | if ($year == '' && $month == '') { |
| 306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 355 | + if ($limit) { |
|
| 356 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 357 | + } else { |
|
| 358 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 359 | + } |
|
| 308 | 360 | try { |
| 309 | 361 | $sth = $this->db->prepare($query); |
| 310 | 362 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -312,11 +364,16 @@ discard block |
||
| 312 | 364 | echo "error : ".$e->getMessage(); |
| 313 | 365 | } |
| 314 | 366 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 315 | - } else $all = array(); |
|
| 367 | + } else { |
|
| 368 | + $all = array(); |
|
| 369 | + } |
|
| 316 | 370 | } else { |
| 317 | 371 | if ($year == '' && $month == '') { |
| 318 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 319 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 372 | + if ($limit) { |
|
| 373 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 374 | + } else { |
|
| 375 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 376 | + } |
|
| 320 | 377 | try { |
| 321 | 378 | $sth = $this->db->prepare($query); |
| 322 | 379 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -324,7 +381,9 @@ discard block |
||
| 324 | 381 | echo "error : ".$e->getMessage(); |
| 325 | 382 | } |
| 326 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 327 | - } else $all = array(); |
|
| 384 | + } else { |
|
| 385 | + $all = array(); |
|
| 386 | + } |
|
| 328 | 387 | } |
| 329 | 388 | if (empty($all)) { |
| 330 | 389 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -343,7 +402,9 @@ discard block |
||
| 343 | 402 | } |
| 344 | 403 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 345 | 404 | global $globalStatsFilters; |
| 346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 405 | + if ($filter_name == '') { |
|
| 406 | + $filter_name = $this->filter_name; |
|
| 407 | + } |
|
| 347 | 408 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 348 | 409 | $Spotter = new Spotter($this->db); |
| 349 | 410 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -351,12 +412,18 @@ discard block |
||
| 351 | 412 | foreach ($airlines as $airline) { |
| 352 | 413 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 353 | 414 | } |
| 354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 415 | + if ($limit) { |
|
| 416 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 417 | + } else { |
|
| 418 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 419 | + } |
|
| 356 | 420 | $query_values = array(':filter_name' => $filter_name); |
| 357 | 421 | } else { |
| 358 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 359 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 422 | + if ($limit) { |
|
| 423 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 424 | + } else { |
|
| 425 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 426 | + } |
|
| 360 | 427 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 361 | 428 | } |
| 362 | 429 | try { |
@@ -384,17 +451,29 @@ discard block |
||
| 384 | 451 | |
| 385 | 452 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 386 | 453 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 387 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 454 | + if ($filter_name == '') { |
|
| 455 | + $filter_name = $this->filter_name; |
|
| 456 | + } |
|
| 388 | 457 | if ($year == '' && $month == '') { |
| 389 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 390 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 458 | + if ($globalVATSIM) { |
|
| 459 | + $forsource = 'vatsim'; |
|
| 460 | + } |
|
| 461 | + if ($globalIVAO) { |
|
| 462 | + $forsource = 'ivao'; |
|
| 463 | + } |
|
| 391 | 464 | if (isset($forsource)) { |
| 392 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 393 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 465 | + if ($limit) { |
|
| 466 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 467 | + } else { |
|
| 468 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 469 | + } |
|
| 394 | 470 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 395 | 471 | } else { |
| 396 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 397 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 472 | + if ($limit) { |
|
| 473 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 474 | + } else { |
|
| 475 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 476 | + } |
|
| 398 | 477 | $query_values = array(':filter_name' => $filter_name); |
| 399 | 478 | } |
| 400 | 479 | try { |
@@ -404,7 +483,9 @@ discard block |
||
| 404 | 483 | echo "error : ".$e->getMessage(); |
| 405 | 484 | } |
| 406 | 485 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 407 | - } else $all = array(); |
|
| 486 | + } else { |
|
| 487 | + $all = array(); |
|
| 488 | + } |
|
| 408 | 489 | if (empty($all)) { |
| 409 | 490 | $Spotter = new Spotter($this->db); |
| 410 | 491 | $filters = array(); |
@@ -419,7 +500,9 @@ discard block |
||
| 419 | 500 | } |
| 420 | 501 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 421 | 502 | global $globalStatsFilters; |
| 422 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 503 | + if ($filter_name == '') { |
|
| 504 | + $filter_name = $this->filter_name; |
|
| 505 | + } |
|
| 423 | 506 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 424 | 507 | $Spotter = new Spotter($this->db); |
| 425 | 508 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -428,8 +511,11 @@ discard block |
||
| 428 | 511 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 429 | 512 | } |
| 430 | 513 | if ($year == '' && $month == '') { |
| 431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 514 | + if ($limit) { |
|
| 515 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 516 | + } else { |
|
| 517 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 518 | + } |
|
| 433 | 519 | try { |
| 434 | 520 | $sth = $this->db->prepare($query); |
| 435 | 521 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -437,11 +523,16 @@ discard block |
||
| 437 | 523 | echo "error : ".$e->getMessage(); |
| 438 | 524 | } |
| 439 | 525 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 440 | - } else $all = array(); |
|
| 526 | + } else { |
|
| 527 | + $all = array(); |
|
| 528 | + } |
|
| 441 | 529 | } else { |
| 442 | 530 | if ($year == '' && $month == '') { |
| 443 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 444 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 531 | + if ($limit) { |
|
| 532 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 533 | + } else { |
|
| 534 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 535 | + } |
|
| 445 | 536 | try { |
| 446 | 537 | $sth = $this->db->prepare($query); |
| 447 | 538 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -449,7 +540,9 @@ discard block |
||
| 449 | 540 | echo "error : ".$e->getMessage(); |
| 450 | 541 | } |
| 451 | 542 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 452 | - } else $all = array(); |
|
| 543 | + } else { |
|
| 544 | + $all = array(); |
|
| 545 | + } |
|
| 453 | 546 | } |
| 454 | 547 | if (empty($all)) { |
| 455 | 548 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -468,7 +561,9 @@ discard block |
||
| 468 | 561 | } |
| 469 | 562 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 470 | 563 | global $globalStatsFilters; |
| 471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 564 | + if ($filter_name == '') { |
|
| 565 | + $filter_name = $this->filter_name; |
|
| 566 | + } |
|
| 472 | 567 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 473 | 568 | $Spotter = new Spotter($this->db); |
| 474 | 569 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -477,8 +572,11 @@ discard block |
||
| 477 | 572 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 478 | 573 | } |
| 479 | 574 | if ($year == '' && $month == '') { |
| 480 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 575 | + if ($limit) { |
|
| 576 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 577 | + } else { |
|
| 578 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 579 | + } |
|
| 482 | 580 | try { |
| 483 | 581 | $sth = $this->db->prepare($query); |
| 484 | 582 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -486,11 +584,16 @@ discard block |
||
| 486 | 584 | echo "error : ".$e->getMessage(); |
| 487 | 585 | } |
| 488 | 586 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 489 | - } else $all = array(); |
|
| 587 | + } else { |
|
| 588 | + $all = array(); |
|
| 589 | + } |
|
| 490 | 590 | } else { |
| 491 | 591 | if ($year == '' && $month == '') { |
| 492 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 493 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 592 | + if ($limit) { |
|
| 593 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 594 | + } else { |
|
| 595 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 596 | + } |
|
| 494 | 597 | try { |
| 495 | 598 | $sth = $this->db->prepare($query); |
| 496 | 599 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -498,7 +601,9 @@ discard block |
||
| 498 | 601 | echo "error : ".$e->getMessage(); |
| 499 | 602 | } |
| 500 | 603 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 501 | - } else $all = array(); |
|
| 604 | + } else { |
|
| 605 | + $all = array(); |
|
| 606 | + } |
|
| 502 | 607 | } |
| 503 | 608 | if (empty($all)) { |
| 504 | 609 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -517,7 +622,9 @@ discard block |
||
| 517 | 622 | } |
| 518 | 623 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 519 | 624 | $Connection = new Connection($this->db); |
| 520 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 625 | + if ($filter_name == '') { |
|
| 626 | + $filter_name = $this->filter_name; |
|
| 627 | + } |
|
| 521 | 628 | if ($Connection->tableExists('countries')) { |
| 522 | 629 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 523 | 630 | $Spotter = new Spotter($this->db); |
@@ -527,8 +634,11 @@ discard block |
||
| 527 | 634 | foreach ($airlines as $airline) { |
| 528 | 635 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 529 | 636 | } |
| 530 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 637 | + if ($limit) { |
|
| 638 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 639 | + } else { |
|
| 640 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 641 | + } |
|
| 532 | 642 | try { |
| 533 | 643 | $sth = $this->db->prepare($query); |
| 534 | 644 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -537,11 +647,16 @@ discard block |
||
| 537 | 647 | } |
| 538 | 648 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 539 | 649 | return $all; |
| 540 | - } else return array(); |
|
| 650 | + } else { |
|
| 651 | + return array(); |
|
| 652 | + } |
|
| 541 | 653 | } else { |
| 542 | 654 | if ($year == '' && $month == '') { |
| 543 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 544 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 655 | + if ($limit) { |
|
| 656 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 657 | + } else { |
|
| 658 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 659 | + } |
|
| 545 | 660 | try { |
| 546 | 661 | $sth = $this->db->prepare($query); |
| 547 | 662 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -550,7 +665,9 @@ discard block |
||
| 550 | 665 | } |
| 551 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 552 | 667 | return $all; |
| 553 | - } else return array(); |
|
| 668 | + } else { |
|
| 669 | + return array(); |
|
| 670 | + } |
|
| 554 | 671 | } |
| 555 | 672 | } else { |
| 556 | 673 | /* |
@@ -564,10 +681,15 @@ discard block |
||
| 564 | 681 | } |
| 565 | 682 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 566 | 683 | global $globalStatsFilters; |
| 567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 684 | + if ($filter_name == '') { |
|
| 685 | + $filter_name = $this->filter_name; |
|
| 686 | + } |
|
| 568 | 687 | if ($year == '' && $month == '') { |
| 569 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 570 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 688 | + if ($limit) { |
|
| 689 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 690 | + } else { |
|
| 691 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 692 | + } |
|
| 571 | 693 | try { |
| 572 | 694 | $sth = $this->db->prepare($query); |
| 573 | 695 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -575,7 +697,9 @@ discard block |
||
| 575 | 697 | echo "error : ".$e->getMessage(); |
| 576 | 698 | } |
| 577 | 699 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 578 | - } else $all = array(); |
|
| 700 | + } else { |
|
| 701 | + $all = array(); |
|
| 702 | + } |
|
| 579 | 703 | if (empty($all)) { |
| 580 | 704 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 581 | 705 | if ($filter_name != '') { |
@@ -590,7 +714,9 @@ discard block |
||
| 590 | 714 | |
| 591 | 715 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 592 | 716 | global $globalStatsFilters; |
| 593 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 717 | + if ($filter_name == '') { |
|
| 718 | + $filter_name = $this->filter_name; |
|
| 719 | + } |
|
| 594 | 720 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 595 | 721 | $Spotter = new Spotter($this->db); |
| 596 | 722 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -599,8 +725,11 @@ discard block |
||
| 599 | 725 | foreach ($airlines as $airline) { |
| 600 | 726 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 601 | 727 | } |
| 602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 728 | + if ($limit) { |
|
| 729 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 730 | + } else { |
|
| 731 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 732 | + } |
|
| 604 | 733 | try { |
| 605 | 734 | $sth = $this->db->prepare($query); |
| 606 | 735 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,11 +737,16 @@ discard block |
||
| 608 | 737 | echo "error : ".$e->getMessage(); |
| 609 | 738 | } |
| 610 | 739 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 611 | - } else $all = array(); |
|
| 740 | + } else { |
|
| 741 | + $all = array(); |
|
| 742 | + } |
|
| 612 | 743 | } else { |
| 613 | 744 | if ($year == '' && $month == '') { |
| 614 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 615 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 745 | + if ($limit) { |
|
| 746 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 747 | + } else { |
|
| 748 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 749 | + } |
|
| 616 | 750 | try { |
| 617 | 751 | $sth = $this->db->prepare($query); |
| 618 | 752 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -620,7 +754,9 @@ discard block |
||
| 620 | 754 | echo "error : ".$e->getMessage(); |
| 621 | 755 | } |
| 622 | 756 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | - } else $all = array(); |
|
| 757 | + } else { |
|
| 758 | + $all = array(); |
|
| 759 | + } |
|
| 624 | 760 | } |
| 625 | 761 | if (empty($all)) { |
| 626 | 762 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -639,7 +775,9 @@ discard block |
||
| 639 | 775 | } |
| 640 | 776 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 641 | 777 | global $globalStatsFilters; |
| 642 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 778 | + if ($filter_name == '') { |
|
| 779 | + $filter_name = $this->filter_name; |
|
| 780 | + } |
|
| 643 | 781 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 644 | 782 | $Spotter = new Spotter($this->db); |
| 645 | 783 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -648,8 +786,11 @@ discard block |
||
| 648 | 786 | foreach ($airlines as $airline) { |
| 649 | 787 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 650 | 788 | } |
| 651 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 789 | + if ($limit) { |
|
| 790 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 791 | + } else { |
|
| 792 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 793 | + } |
|
| 653 | 794 | try { |
| 654 | 795 | $sth = $this->db->prepare($query); |
| 655 | 796 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -657,11 +798,16 @@ discard block |
||
| 657 | 798 | echo "error : ".$e->getMessage(); |
| 658 | 799 | } |
| 659 | 800 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 660 | - } else $all = array(); |
|
| 801 | + } else { |
|
| 802 | + $all = array(); |
|
| 803 | + } |
|
| 661 | 804 | } else { |
| 662 | 805 | if ($year == '' && $month == '') { |
| 663 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 664 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 806 | + if ($limit) { |
|
| 807 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 808 | + } else { |
|
| 809 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 810 | + } |
|
| 665 | 811 | try { |
| 666 | 812 | $sth = $this->db->prepare($query); |
| 667 | 813 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -669,7 +815,9 @@ discard block |
||
| 669 | 815 | echo "error : ".$e->getMessage(); |
| 670 | 816 | } |
| 671 | 817 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | - } else $all = array(); |
|
| 818 | + } else { |
|
| 819 | + $all = array(); |
|
| 820 | + } |
|
| 673 | 821 | } |
| 674 | 822 | if (empty($all)) { |
| 675 | 823 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -694,7 +842,9 @@ discard block |
||
| 694 | 842 | $icao = $value['airport_departure_icao']; |
| 695 | 843 | if (isset($all[$icao])) { |
| 696 | 844 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 697 | - } else $all[$icao] = $value; |
|
| 845 | + } else { |
|
| 846 | + $all[$icao] = $value; |
|
| 847 | + } |
|
| 698 | 848 | } |
| 699 | 849 | $count = array(); |
| 700 | 850 | foreach ($all as $key => $row) { |
@@ -706,7 +856,9 @@ discard block |
||
| 706 | 856 | } |
| 707 | 857 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 708 | 858 | global $globalStatsFilters; |
| 709 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 859 | + if ($filter_name == '') { |
|
| 860 | + $filter_name = $this->filter_name; |
|
| 861 | + } |
|
| 710 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 711 | 863 | $Spotter = new Spotter($this->db); |
| 712 | 864 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -715,8 +867,11 @@ discard block |
||
| 715 | 867 | foreach ($airlines as $airline) { |
| 716 | 868 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 717 | 869 | } |
| 718 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 870 | + if ($limit) { |
|
| 871 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 872 | + } else { |
|
| 873 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 874 | + } |
|
| 720 | 875 | try { |
| 721 | 876 | $sth = $this->db->prepare($query); |
| 722 | 877 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -724,11 +879,16 @@ discard block |
||
| 724 | 879 | echo "error : ".$e->getMessage(); |
| 725 | 880 | } |
| 726 | 881 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 727 | - } else $all = array(); |
|
| 882 | + } else { |
|
| 883 | + $all = array(); |
|
| 884 | + } |
|
| 728 | 885 | } else { |
| 729 | 886 | if ($year == '' && $month == '') { |
| 730 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 731 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 887 | + if ($limit) { |
|
| 888 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 889 | + } else { |
|
| 890 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 891 | + } |
|
| 732 | 892 | try { |
| 733 | 893 | $sth = $this->db->prepare($query); |
| 734 | 894 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -736,7 +896,9 @@ discard block |
||
| 736 | 896 | echo "error : ".$e->getMessage(); |
| 737 | 897 | } |
| 738 | 898 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 739 | - } else $all = array(); |
|
| 899 | + } else { |
|
| 900 | + $all = array(); |
|
| 901 | + } |
|
| 740 | 902 | } |
| 741 | 903 | if (empty($all)) { |
| 742 | 904 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -761,7 +923,9 @@ discard block |
||
| 761 | 923 | $icao = $value['airport_arrival_icao']; |
| 762 | 924 | if (isset($all[$icao])) { |
| 763 | 925 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 764 | - } else $all[$icao] = $value; |
|
| 926 | + } else { |
|
| 927 | + $all[$icao] = $value; |
|
| 928 | + } |
|
| 765 | 929 | } |
| 766 | 930 | $count = array(); |
| 767 | 931 | foreach ($all as $key => $row) { |
@@ -773,7 +937,9 @@ discard block |
||
| 773 | 937 | } |
| 774 | 938 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 775 | 939 | global $globalDBdriver, $globalStatsFilters; |
| 776 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 940 | + if ($filter_name == '') { |
|
| 941 | + $filter_name = $this->filter_name; |
|
| 942 | + } |
|
| 777 | 943 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 778 | 944 | $Spotter = new Spotter($this->db); |
| 779 | 945 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -782,20 +948,32 @@ discard block |
||
| 782 | 948 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 783 | 949 | } |
| 784 | 950 | if ($globalDBdriver == 'mysql') { |
| 785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 951 | + if ($limit) { |
|
| 952 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 953 | + } else { |
|
| 954 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 955 | + } |
|
| 787 | 956 | } else { |
| 788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 957 | + if ($limit) { |
|
| 958 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 959 | + } else { |
|
| 960 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 961 | + } |
|
| 790 | 962 | } |
| 791 | 963 | $query_data = array(':filter_name' => $filter_name); |
| 792 | 964 | } else { |
| 793 | 965 | if ($globalDBdriver == 'mysql') { |
| 794 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 795 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 966 | + if ($limit) { |
|
| 967 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 968 | + } else { |
|
| 969 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 970 | + } |
|
| 796 | 971 | } else { |
| 797 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 798 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 972 | + if ($limit) { |
|
| 973 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 974 | + } else { |
|
| 975 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 976 | + } |
|
| 799 | 977 | } |
| 800 | 978 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 801 | 979 | } |
@@ -823,7 +1001,9 @@ discard block |
||
| 823 | 1001 | |
| 824 | 1002 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 825 | 1003 | global $globalStatsFilters; |
| 826 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1004 | + if ($filter_name == '') { |
|
| 1005 | + $filter_name = $this->filter_name; |
|
| 1006 | + } |
|
| 827 | 1007 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 828 | 1008 | $Spotter = new Spotter($this->db); |
| 829 | 1009 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -860,7 +1040,9 @@ discard block |
||
| 860 | 1040 | } |
| 861 | 1041 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 862 | 1042 | global $globalDBdriver, $globalStatsFilters; |
| 863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1043 | + if ($filter_name == '') { |
|
| 1044 | + $filter_name = $this->filter_name; |
|
| 1045 | + } |
|
| 864 | 1046 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 865 | 1047 | $Spotter = new Spotter($this->db); |
| 866 | 1048 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -905,7 +1087,9 @@ discard block |
||
| 905 | 1087 | } |
| 906 | 1088 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 907 | 1089 | global $globalStatsFilters; |
| 908 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1090 | + if ($filter_name == '') { |
|
| 1091 | + $filter_name = $this->filter_name; |
|
| 1092 | + } |
|
| 909 | 1093 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 910 | 1094 | $Spotter = new Spotter($this->db); |
| 911 | 1095 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -942,7 +1126,9 @@ discard block |
||
| 942 | 1126 | } |
| 943 | 1127 | public function countAllDatesByAirlines($filter_name = '') { |
| 944 | 1128 | global $globalStatsFilters; |
| 945 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1129 | + if ($filter_name == '') { |
|
| 1130 | + $filter_name = $this->filter_name; |
|
| 1131 | + } |
|
| 946 | 1132 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
| 947 | 1133 | $query_data = array('filter_name' => $filter_name); |
| 948 | 1134 | try { |
@@ -964,7 +1150,9 @@ discard block |
||
| 964 | 1150 | } |
| 965 | 1151 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 966 | 1152 | global $globalStatsFilters, $globalDBdriver; |
| 967 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1153 | + if ($filter_name == '') { |
|
| 1154 | + $filter_name = $this->filter_name; |
|
| 1155 | + } |
|
| 968 | 1156 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 969 | 1157 | $Spotter = new Spotter($this->db); |
| 970 | 1158 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1049,7 +1237,9 @@ discard block |
||
| 1049 | 1237 | } |
| 1050 | 1238 | public function countAllMilitaryMonths($filter_name = '') { |
| 1051 | 1239 | global $globalStatsFilters; |
| 1052 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1240 | + if ($filter_name == '') { |
|
| 1241 | + $filter_name = $this->filter_name; |
|
| 1242 | + } |
|
| 1053 | 1243 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
| 1054 | 1244 | try { |
| 1055 | 1245 | $sth = $this->db->prepare($query); |
@@ -1070,7 +1260,9 @@ discard block |
||
| 1070 | 1260 | } |
| 1071 | 1261 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 1072 | 1262 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1073 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1263 | + if ($filter_name == '') { |
|
| 1264 | + $filter_name = $this->filter_name; |
|
| 1265 | + } |
|
| 1074 | 1266 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1075 | 1267 | $Spotter = new Spotter($this->db); |
| 1076 | 1268 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1078,12 +1270,18 @@ discard block |
||
| 1078 | 1270 | foreach ($airlines as $airline) { |
| 1079 | 1271 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 1080 | 1272 | } |
| 1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1273 | + if ($limit) { |
|
| 1274 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1275 | + } else { |
|
| 1276 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1277 | + } |
|
| 1083 | 1278 | $query_data = array(':filter_name' => $filter_name); |
| 1084 | 1279 | } else { |
| 1085 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1086 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1280 | + if ($limit) { |
|
| 1281 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1282 | + } else { |
|
| 1283 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 1284 | + } |
|
| 1087 | 1285 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 1088 | 1286 | } |
| 1089 | 1287 | if ($orderby == 'hour') { |
@@ -1093,7 +1291,9 @@ discard block |
||
| 1093 | 1291 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 1094 | 1292 | } |
| 1095 | 1293 | } |
| 1096 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1294 | + if ($orderby == 'count') { |
|
| 1295 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1296 | + } |
|
| 1097 | 1297 | try { |
| 1098 | 1298 | $sth = $this->db->prepare($query); |
| 1099 | 1299 | $sth->execute($query_data); |
@@ -1117,8 +1317,12 @@ discard block |
||
| 1117 | 1317 | } |
| 1118 | 1318 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 1119 | 1319 | global $globalStatsFilters; |
| 1120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1121 | - if ($year == '') $year = date('Y'); |
|
| 1320 | + if ($filter_name == '') { |
|
| 1321 | + $filter_name = $this->filter_name; |
|
| 1322 | + } |
|
| 1323 | + if ($year == '') { |
|
| 1324 | + $year = date('Y'); |
|
| 1325 | + } |
|
| 1122 | 1326 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1123 | 1327 | if (empty($all)) { |
| 1124 | 1328 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1137,8 +1341,12 @@ discard block |
||
| 1137 | 1341 | } |
| 1138 | 1342 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 1139 | 1343 | global $globalStatsFilters; |
| 1140 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1141 | - if ($year == '') $year = date('Y'); |
|
| 1344 | + if ($filter_name == '') { |
|
| 1345 | + $filter_name = $this->filter_name; |
|
| 1346 | + } |
|
| 1347 | + if ($year == '') { |
|
| 1348 | + $year = date('Y'); |
|
| 1349 | + } |
|
| 1142 | 1350 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 1143 | 1351 | if (empty($all)) { |
| 1144 | 1352 | $filters = array(); |
@@ -1154,8 +1362,12 @@ discard block |
||
| 1154 | 1362 | } |
| 1155 | 1363 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 1156 | 1364 | global $globalStatsFilters; |
| 1157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1158 | - if ($year == '') $year = date('Y'); |
|
| 1365 | + if ($filter_name == '') { |
|
| 1366 | + $filter_name = $this->filter_name; |
|
| 1367 | + } |
|
| 1368 | + if ($year == '') { |
|
| 1369 | + $year = date('Y'); |
|
| 1370 | + } |
|
| 1159 | 1371 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1160 | 1372 | if (empty($all)) { |
| 1161 | 1373 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1174,7 +1386,9 @@ discard block |
||
| 1174 | 1386 | } |
| 1175 | 1387 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1176 | 1388 | global $globalStatsFilters; |
| 1177 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1389 | + if ($filter_name == '') { |
|
| 1390 | + $filter_name = $this->filter_name; |
|
| 1391 | + } |
|
| 1178 | 1392 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1179 | 1393 | $Spotter = new Spotter($this->db); |
| 1180 | 1394 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1192,7 +1406,9 @@ discard block |
||
| 1192 | 1406 | } |
| 1193 | 1407 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1194 | 1408 | $all = $result[0]['nb']; |
| 1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1409 | + } else { |
|
| 1410 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1411 | + } |
|
| 1196 | 1412 | } else { |
| 1197 | 1413 | if ($year == '' && $month == '') { |
| 1198 | 1414 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1204,7 +1420,9 @@ discard block |
||
| 1204 | 1420 | } |
| 1205 | 1421 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1206 | 1422 | $all = $result[0]['nb']; |
| 1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1423 | + } else { |
|
| 1424 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1425 | + } |
|
| 1208 | 1426 | } |
| 1209 | 1427 | if (empty($all)) { |
| 1210 | 1428 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1223,7 +1441,9 @@ discard block |
||
| 1223 | 1441 | } |
| 1224 | 1442 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 1225 | 1443 | global $globalStatsFilters; |
| 1226 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1444 | + if ($filter_name == '') { |
|
| 1445 | + $filter_name = $this->filter_name; |
|
| 1446 | + } |
|
| 1227 | 1447 | if ($year == '' && $month == '') { |
| 1228 | 1448 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 1229 | 1449 | try { |
@@ -1234,7 +1454,9 @@ discard block |
||
| 1234 | 1454 | } |
| 1235 | 1455 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1236 | 1456 | $all = $result[0]['nb_airline']; |
| 1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1457 | + } else { |
|
| 1458 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1459 | + } |
|
| 1238 | 1460 | if (empty($all)) { |
| 1239 | 1461 | $filters = array(); |
| 1240 | 1462 | $filters = array('year' => $year,'month' => $month); |
@@ -1249,7 +1471,9 @@ discard block |
||
| 1249 | 1471 | } |
| 1250 | 1472 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1251 | 1473 | global $globalStatsFilters; |
| 1252 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1474 | + if ($filter_name == '') { |
|
| 1475 | + $filter_name = $this->filter_name; |
|
| 1476 | + } |
|
| 1253 | 1477 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1254 | 1478 | $Spotter = new Spotter($this->db); |
| 1255 | 1479 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1304,7 +1528,9 @@ discard block |
||
| 1304 | 1528 | } |
| 1305 | 1529 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 1306 | 1530 | global $globalStatsFilters; |
| 1307 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1531 | + if ($filter_name == '') { |
|
| 1532 | + $filter_name = $this->filter_name; |
|
| 1533 | + } |
|
| 1308 | 1534 | //if ($year == '') $year = date('Y'); |
| 1309 | 1535 | if ($year == '' && $month == '') { |
| 1310 | 1536 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1333,7 +1559,9 @@ discard block |
||
| 1333 | 1559 | } |
| 1334 | 1560 | |
| 1335 | 1561 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 1336 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1562 | + if ($filter_name == '') { |
|
| 1563 | + $filter_name = $this->filter_name; |
|
| 1564 | + } |
|
| 1337 | 1565 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1338 | 1566 | $Spotter = new Spotter($this->db); |
| 1339 | 1567 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1357,7 +1585,9 @@ discard block |
||
| 1357 | 1585 | return $all; |
| 1358 | 1586 | } |
| 1359 | 1587 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 1360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1588 | + if ($filter_name == '') { |
|
| 1589 | + $filter_name = $this->filter_name; |
|
| 1590 | + } |
|
| 1361 | 1591 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1362 | 1592 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1363 | 1593 | try { |
@@ -1370,7 +1600,9 @@ discard block |
||
| 1370 | 1600 | return $all; |
| 1371 | 1601 | } |
| 1372 | 1602 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
| 1373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1603 | + if ($filter_name == '') { |
|
| 1604 | + $filter_name = $this->filter_name; |
|
| 1605 | + } |
|
| 1374 | 1606 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1375 | 1607 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1376 | 1608 | try { |
@@ -1381,7 +1613,9 @@ discard block |
||
| 1381 | 1613 | } |
| 1382 | 1614 | } |
| 1383 | 1615 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 1384 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1616 | + if ($filter_name == '') { |
|
| 1617 | + $filter_name = $this->filter_name; |
|
| 1618 | + } |
|
| 1385 | 1619 | global $globalArchiveMonths, $globalDBdriver; |
| 1386 | 1620 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1387 | 1621 | $Spotter = new Spotter($this->db); |
@@ -1437,7 +1671,9 @@ discard block |
||
| 1437 | 1671 | } |
| 1438 | 1672 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1439 | 1673 | global $globalArchiveMonths, $globalDBdriver; |
| 1440 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1674 | + if ($filter_name == '') { |
|
| 1675 | + $filter_name = $this->filter_name; |
|
| 1676 | + } |
|
| 1441 | 1677 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1442 | 1678 | $Spotter = new Spotter($this->db); |
| 1443 | 1679 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1470,7 +1706,9 @@ discard block |
||
| 1470 | 1706 | } |
| 1471 | 1707 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1472 | 1708 | global $globalArchiveMonths, $globalDBdriver; |
| 1473 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1709 | + if ($filter_name == '') { |
|
| 1710 | + $filter_name = $this->filter_name; |
|
| 1711 | + } |
|
| 1474 | 1712 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1475 | 1713 | $Spotter = new Spotter($this->db); |
| 1476 | 1714 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1501,7 +1739,9 @@ discard block |
||
| 1501 | 1739 | } |
| 1502 | 1740 | public function getStatsAirlineTotal($filter_name = '') { |
| 1503 | 1741 | global $globalArchiveMonths, $globalDBdriver; |
| 1504 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1742 | + if ($filter_name == '') { |
|
| 1743 | + $filter_name = $this->filter_name; |
|
| 1744 | + } |
|
| 1505 | 1745 | if ($globalDBdriver == 'mysql') { |
| 1506 | 1746 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 1507 | 1747 | } else { |
@@ -1518,7 +1758,9 @@ discard block |
||
| 1518 | 1758 | } |
| 1519 | 1759 | public function getStatsOwnerTotal($filter_name = '') { |
| 1520 | 1760 | global $globalArchiveMonths, $globalDBdriver; |
| 1521 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1761 | + if ($filter_name == '') { |
|
| 1762 | + $filter_name = $this->filter_name; |
|
| 1763 | + } |
|
| 1522 | 1764 | if ($globalDBdriver == 'mysql') { |
| 1523 | 1765 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1524 | 1766 | } else { |
@@ -1535,7 +1777,9 @@ discard block |
||
| 1535 | 1777 | } |
| 1536 | 1778 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1537 | 1779 | global $globalArchiveMonths, $globalDBdriver; |
| 1538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1780 | + if ($filter_name == '') { |
|
| 1781 | + $filter_name = $this->filter_name; |
|
| 1782 | + } |
|
| 1539 | 1783 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1540 | 1784 | try { |
| 1541 | 1785 | $sth = $this->db->prepare($query); |
@@ -1544,12 +1788,17 @@ discard block |
||
| 1544 | 1788 | echo "error : ".$e->getMessage(); |
| 1545 | 1789 | } |
| 1546 | 1790 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1547 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1548 | - else return 0; |
|
| 1791 | + if (isset($all[0]['cnt'])) { |
|
| 1792 | + return $all[0]['cnt']; |
|
| 1793 | + } else { |
|
| 1794 | + return 0; |
|
| 1795 | + } |
|
| 1549 | 1796 | } |
| 1550 | 1797 | public function getStatsPilotTotal($filter_name = '') { |
| 1551 | 1798 | global $globalArchiveMonths, $globalDBdriver; |
| 1552 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1799 | + if ($filter_name == '') { |
|
| 1800 | + $filter_name = $this->filter_name; |
|
| 1801 | + } |
|
| 1553 | 1802 | if ($globalDBdriver == 'mysql') { |
| 1554 | 1803 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1555 | 1804 | } else { |
@@ -1566,7 +1815,9 @@ discard block |
||
| 1566 | 1815 | } |
| 1567 | 1816 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1568 | 1817 | global $globalArchiveMonths, $globalDBdriver; |
| 1569 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1818 | + if ($filter_name == '') { |
|
| 1819 | + $filter_name = $this->filter_name; |
|
| 1820 | + } |
|
| 1570 | 1821 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1571 | 1822 | try { |
| 1572 | 1823 | $sth = $this->db->prepare($query); |
@@ -1575,13 +1826,18 @@ discard block |
||
| 1575 | 1826 | echo "error : ".$e->getMessage(); |
| 1576 | 1827 | } |
| 1577 | 1828 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1578 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1579 | - else return 0; |
|
| 1829 | + if (isset($all[0]['cnt'])) { |
|
| 1830 | + return $all[0]['cnt']; |
|
| 1831 | + } else { |
|
| 1832 | + return 0; |
|
| 1833 | + } |
|
| 1580 | 1834 | } |
| 1581 | 1835 | |
| 1582 | 1836 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1583 | 1837 | global $globalDBdriver; |
| 1584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1838 | + if ($filter_name == '') { |
|
| 1839 | + $filter_name = $this->filter_name; |
|
| 1840 | + } |
|
| 1585 | 1841 | if ($globalDBdriver == 'mysql') { |
| 1586 | 1842 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
| 1587 | 1843 | } else { |
@@ -1597,7 +1853,9 @@ discard block |
||
| 1597 | 1853 | } |
| 1598 | 1854 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1599 | 1855 | global $globalDBdriver; |
| 1600 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1856 | + if ($filter_name == '') { |
|
| 1857 | + $filter_name = $this->filter_name; |
|
| 1858 | + } |
|
| 1601 | 1859 | if ($globalDBdriver == 'mysql') { |
| 1602 | 1860 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1603 | 1861 | } else { |
@@ -1983,10 +2241,14 @@ discard block |
||
| 1983 | 2241 | $Connection = new Connection($this->db); |
| 1984 | 2242 | date_default_timezone_set('UTC'); |
| 1985 | 2243 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1986 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 2244 | + if ($globalDebug) { |
|
| 2245 | + echo 'Update stats !'."\n"; |
|
| 2246 | + } |
|
| 1987 | 2247 | if (isset($last_update[0]['value'])) { |
| 1988 | 2248 | $last_update_day = $last_update[0]['value']; |
| 1989 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2249 | + } else { |
|
| 2250 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2251 | + } |
|
| 1990 | 2252 | $reset = false; |
| 1991 | 2253 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 1992 | 2254 | if ($globalStatsResetYear) { |
@@ -1995,43 +2257,63 @@ discard block |
||
| 1995 | 2257 | } |
| 1996 | 2258 | $Spotter = new Spotter($this->db); |
| 1997 | 2259 | |
| 1998 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo 'Count all aircraft types...'."\n"; |
|
| 2262 | + } |
|
| 1999 | 2263 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 2000 | 2264 | foreach ($alldata as $number) { |
| 2001 | 2265 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 2002 | 2266 | } |
| 2003 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2267 | + if ($globalDebug) { |
|
| 2268 | + echo 'Count all airlines...'."\n"; |
|
| 2269 | + } |
|
| 2004 | 2270 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 2005 | 2271 | foreach ($alldata as $number) { |
| 2006 | 2272 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 2007 | 2273 | } |
| 2008 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 2274 | + if ($globalDebug) { |
|
| 2275 | + echo 'Count all registrations...'."\n"; |
|
| 2276 | + } |
|
| 2009 | 2277 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 2010 | 2278 | foreach ($alldata as $number) { |
| 2011 | 2279 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 2012 | 2280 | } |
| 2013 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2281 | + if ($globalDebug) { |
|
| 2282 | + echo 'Count all callsigns...'."\n"; |
|
| 2283 | + } |
|
| 2014 | 2284 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 2015 | 2285 | foreach ($alldata as $number) { |
| 2016 | 2286 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2017 | 2287 | } |
| 2018 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2288 | + if ($globalDebug) { |
|
| 2289 | + echo 'Count all owners...'."\n"; |
|
| 2290 | + } |
|
| 2019 | 2291 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 2020 | 2292 | foreach ($alldata as $number) { |
| 2021 | 2293 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 2022 | 2294 | } |
| 2023 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2295 | + if ($globalDebug) { |
|
| 2296 | + echo 'Count all pilots...'."\n"; |
|
| 2297 | + } |
|
| 2024 | 2298 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 2025 | 2299 | foreach ($alldata as $number) { |
| 2026 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
| 2300 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
| 2301 | + $number['pilot_id'] = $number['pilot_name']; |
|
| 2302 | + } |
|
| 2027 | 2303 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 2028 | 2304 | } |
| 2029 | 2305 | |
| 2030 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 2306 | + if ($globalDebug) { |
|
| 2307 | + echo 'Count all departure airports...'."\n"; |
|
| 2308 | + } |
|
| 2031 | 2309 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 2032 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo 'Count all detected departure airports...'."\n"; |
|
| 2312 | + } |
|
| 2033 | 2313 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 2034 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 2314 | + if ($globalDebug) { |
|
| 2315 | + echo 'Order departure airports...'."\n"; |
|
| 2316 | + } |
|
| 2035 | 2317 | $alldata = array(); |
| 2036 | 2318 | foreach ($pall as $value) { |
| 2037 | 2319 | $icao = $value['airport_departure_icao']; |
@@ -2041,7 +2323,9 @@ discard block |
||
| 2041 | 2323 | $icao = $value['airport_departure_icao']; |
| 2042 | 2324 | if (isset($alldata[$icao])) { |
| 2043 | 2325 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2044 | - } else $alldata[$icao] = $value; |
|
| 2326 | + } else { |
|
| 2327 | + $alldata[$icao] = $value; |
|
| 2328 | + } |
|
| 2045 | 2329 | } |
| 2046 | 2330 | $count = array(); |
| 2047 | 2331 | foreach ($alldata as $key => $row) { |
@@ -2051,11 +2335,17 @@ discard block |
||
| 2051 | 2335 | foreach ($alldata as $number) { |
| 2052 | 2336 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
| 2053 | 2337 | } |
| 2054 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2338 | + if ($globalDebug) { |
|
| 2339 | + echo 'Count all arrival airports...'."\n"; |
|
| 2340 | + } |
|
| 2055 | 2341 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 2056 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 2342 | + if ($globalDebug) { |
|
| 2343 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 2344 | + } |
|
| 2057 | 2345 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 2058 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 2346 | + if ($globalDebug) { |
|
| 2347 | + echo 'Order arrival airports...'."\n"; |
|
| 2348 | + } |
|
| 2059 | 2349 | $alldata = array(); |
| 2060 | 2350 | foreach ($pall as $value) { |
| 2061 | 2351 | $icao = $value['airport_arrival_icao']; |
@@ -2065,7 +2355,9 @@ discard block |
||
| 2065 | 2355 | $icao = $value['airport_arrival_icao']; |
| 2066 | 2356 | if (isset($alldata[$icao])) { |
| 2067 | 2357 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2068 | - } else $alldata[$icao] = $value; |
|
| 2358 | + } else { |
|
| 2359 | + $alldata[$icao] = $value; |
|
| 2360 | + } |
|
| 2069 | 2361 | } |
| 2070 | 2362 | $count = array(); |
| 2071 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2076,7 +2368,9 @@ discard block |
||
| 2076 | 2368 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
| 2077 | 2369 | } |
| 2078 | 2370 | if ($Connection->tableExists('countries')) { |
| 2079 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 2371 | + if ($globalDebug) { |
|
| 2372 | + echo 'Count all flights by countries...'."\n"; |
|
| 2373 | + } |
|
| 2080 | 2374 | //$SpotterArchive = new SpotterArchive(); |
| 2081 | 2375 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2082 | 2376 | $Spotter = new Spotter($this->db); |
@@ -2087,7 +2381,9 @@ discard block |
||
| 2087 | 2381 | } |
| 2088 | 2382 | |
| 2089 | 2383 | if (isset($globalAccidents) && $globalAccidents) { |
| 2090 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
| 2384 | + if ($globalDebug) { |
|
| 2385 | + echo 'Count fatalities stats...'."\n"; |
|
| 2386 | + } |
|
| 2091 | 2387 | $Accident = new Accident($this->db); |
| 2092 | 2388 | $this->deleteStatsByType('fatalities_byyear'); |
| 2093 | 2389 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2103,48 +2399,68 @@ discard block |
||
| 2103 | 2399 | |
| 2104 | 2400 | // Add by month using getstat if month finish... |
| 2105 | 2401 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 2106 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 2402 | + if ($globalDebug) { |
|
| 2403 | + echo 'Count all flights by months...'."\n"; |
|
| 2404 | + } |
|
| 2107 | 2405 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2108 | 2406 | $filter_last_month = array('since_date' => $last_month); |
| 2109 | 2407 | $Spotter = new Spotter($this->db); |
| 2110 | 2408 | $alldata = $Spotter->countAllMonths($filter_last_month); |
| 2111 | 2409 | $lastyear = false; |
| 2112 | 2410 | foreach ($alldata as $number) { |
| 2113 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2411 | + if ($number['year_name'] != date('Y')) { |
|
| 2412 | + $lastyear = true; |
|
| 2413 | + } |
|
| 2114 | 2414 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2115 | 2415 | } |
| 2116 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 2416 | + if ($globalDebug) { |
|
| 2417 | + echo 'Count all military flights by months...'."\n"; |
|
| 2418 | + } |
|
| 2117 | 2419 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2118 | 2420 | foreach ($alldata as $number) { |
| 2119 | 2421 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2120 | 2422 | } |
| 2121 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2423 | + if ($globalDebug) { |
|
| 2424 | + echo 'Count all owners by months...'."\n"; |
|
| 2425 | + } |
|
| 2122 | 2426 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2123 | 2427 | foreach ($alldata as $number) { |
| 2124 | 2428 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2125 | 2429 | } |
| 2126 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2430 | + if ($globalDebug) { |
|
| 2431 | + echo 'Count all pilots by months...'."\n"; |
|
| 2432 | + } |
|
| 2127 | 2433 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2128 | 2434 | foreach ($alldata as $number) { |
| 2129 | 2435 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2130 | 2436 | } |
| 2131 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo 'Count all airlines by months...'."\n"; |
|
| 2439 | + } |
|
| 2132 | 2440 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2133 | 2441 | foreach ($alldata as $number) { |
| 2134 | 2442 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2135 | 2443 | } |
| 2136 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2444 | + if ($globalDebug) { |
|
| 2445 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2446 | + } |
|
| 2137 | 2447 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2138 | 2448 | foreach ($alldata as $number) { |
| 2139 | 2449 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2140 | 2450 | } |
| 2141 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2451 | + if ($globalDebug) { |
|
| 2452 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2453 | + } |
|
| 2142 | 2454 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2143 | 2455 | foreach ($alldata as $number) { |
| 2144 | 2456 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2145 | 2457 | } |
| 2146 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 2147 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2458 | + if ($globalDebug) { |
|
| 2459 | + echo 'Airports data...'."\n"; |
|
| 2460 | + } |
|
| 2461 | + if ($globalDebug) { |
|
| 2462 | + echo '...Departure'."\n"; |
|
| 2463 | + } |
|
| 2148 | 2464 | $this->deleteStatAirport('daily'); |
| 2149 | 2465 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 2150 | 2466 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2262,7 +2578,9 @@ discard block |
||
| 2262 | 2578 | // Count by airlines |
| 2263 | 2579 | echo '--- Stats by airlines ---'."\n"; |
| 2264 | 2580 | if ($Connection->tableExists('countries')) { |
| 2265 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2581 | + if ($globalDebug) { |
|
| 2582 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 2583 | + } |
|
| 2266 | 2584 | $SpotterArchive = new SpotterArchive($this->db); |
| 2267 | 2585 | //$Spotter = new Spotter($this->db); |
| 2268 | 2586 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2271,37 +2589,53 @@ discard block |
||
| 2271 | 2589 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 2272 | 2590 | } |
| 2273 | 2591 | } |
| 2274 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2592 | + if ($globalDebug) { |
|
| 2593 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 2594 | + } |
|
| 2275 | 2595 | $Spotter = new Spotter($this->db); |
| 2276 | 2596 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 2277 | 2597 | foreach ($alldata as $number) { |
| 2278 | 2598 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 2279 | 2599 | } |
| 2280 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2600 | + if ($globalDebug) { |
|
| 2601 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 2602 | + } |
|
| 2281 | 2603 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 2282 | 2604 | foreach ($alldata as $number) { |
| 2283 | 2605 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 2284 | 2606 | } |
| 2285 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 2607 | + if ($globalDebug) { |
|
| 2608 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 2609 | + } |
|
| 2286 | 2610 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 2287 | 2611 | foreach ($alldata as $number) { |
| 2288 | 2612 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2289 | 2613 | } |
| 2290 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 2614 | + if ($globalDebug) { |
|
| 2615 | + echo 'Count all owners by airlines...'."\n"; |
|
| 2616 | + } |
|
| 2291 | 2617 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 2292 | 2618 | foreach ($alldata as $number) { |
| 2293 | 2619 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 2294 | 2620 | } |
| 2295 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 2621 | + if ($globalDebug) { |
|
| 2622 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 2623 | + } |
|
| 2296 | 2624 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 2297 | 2625 | foreach ($alldata as $number) { |
| 2298 | 2626 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 2299 | 2627 | } |
| 2300 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 2628 | + if ($globalDebug) { |
|
| 2629 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 2630 | + } |
|
| 2301 | 2631 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2302 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2632 | + if ($globalDebug) { |
|
| 2633 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2634 | + } |
|
| 2303 | 2635 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2304 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2636 | + if ($globalDebug) { |
|
| 2637 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2638 | + } |
|
| 2305 | 2639 | //$alldata = array(); |
| 2306 | 2640 | foreach ($dall as $value) { |
| 2307 | 2641 | $icao = $value['airport_departure_icao']; |
@@ -2322,11 +2656,17 @@ discard block |
||
| 2322 | 2656 | foreach ($alldata as $number) { |
| 2323 | 2657 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
| 2324 | 2658 | } |
| 2325 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2659 | + if ($globalDebug) { |
|
| 2660 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2661 | + } |
|
| 2326 | 2662 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2327 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2663 | + if ($globalDebug) { |
|
| 2664 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2665 | + } |
|
| 2328 | 2666 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2329 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 2667 | + if ($globalDebug) { |
|
| 2668 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 2669 | + } |
|
| 2330 | 2670 | //$alldata = array(); |
| 2331 | 2671 | foreach ($dall as $value) { |
| 2332 | 2672 | $icao = $value['airport_arrival_icao']; |
@@ -2345,37 +2685,53 @@ discard block |
||
| 2345 | 2685 | } |
| 2346 | 2686 | $alldata = $pall; |
| 2347 | 2687 | foreach ($alldata as $number) { |
| 2348 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2688 | + if ($number['airline_icao'] != '') { |
|
| 2689 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2690 | + } |
|
| 2691 | + } |
|
| 2692 | + if ($globalDebug) { |
|
| 2693 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 2349 | 2694 | } |
| 2350 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 2351 | 2695 | $Spotter = new Spotter($this->db); |
| 2352 | 2696 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
| 2353 | 2697 | $lastyear = false; |
| 2354 | 2698 | foreach ($alldata as $number) { |
| 2355 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2699 | + if ($number['year_name'] != date('Y')) { |
|
| 2700 | + $lastyear = true; |
|
| 2701 | + } |
|
| 2356 | 2702 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2357 | 2703 | } |
| 2358 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 2704 | + if ($globalDebug) { |
|
| 2705 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2706 | + } |
|
| 2359 | 2707 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2360 | 2708 | foreach ($alldata as $number) { |
| 2361 | 2709 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2362 | 2710 | } |
| 2363 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2713 | + } |
|
| 2364 | 2714 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2365 | 2715 | foreach ($alldata as $number) { |
| 2366 | 2716 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2367 | 2717 | } |
| 2368 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2718 | + if ($globalDebug) { |
|
| 2719 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2720 | + } |
|
| 2369 | 2721 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2370 | 2722 | foreach ($alldata as $number) { |
| 2371 | 2723 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2372 | 2724 | } |
| 2373 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2725 | + if ($globalDebug) { |
|
| 2726 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2727 | + } |
|
| 2374 | 2728 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2375 | 2729 | foreach ($alldata as $number) { |
| 2376 | 2730 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 2377 | 2731 | } |
| 2378 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2732 | + if ($globalDebug) { |
|
| 2733 | + echo '...Departure'."\n"; |
|
| 2734 | + } |
|
| 2379 | 2735 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 2380 | 2736 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 2381 | 2737 | foreach ($dall as $value) { |
@@ -2398,7 +2754,9 @@ discard block |
||
| 2398 | 2754 | foreach ($alldata as $number) { |
| 2399 | 2755 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
| 2400 | 2756 | } |
| 2401 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2757 | + if ($globalDebug) { |
|
| 2758 | + echo '...Arrival'."\n"; |
|
| 2759 | + } |
|
| 2402 | 2760 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 2403 | 2761 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 2404 | 2762 | foreach ($dall as $value) { |
@@ -2422,13 +2780,19 @@ discard block |
||
| 2422 | 2780 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
| 2423 | 2781 | } |
| 2424 | 2782 | |
| 2425 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 2426 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2783 | + if ($globalDebug) { |
|
| 2784 | + echo 'Flights data...'."\n"; |
|
| 2785 | + } |
|
| 2786 | + if ($globalDebug) { |
|
| 2787 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2788 | + } |
|
| 2427 | 2789 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2428 | 2790 | foreach ($alldata as $number) { |
| 2429 | 2791 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 2430 | 2792 | } |
| 2431 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2793 | + if ($globalDebug) { |
|
| 2794 | + echo '-> countAllDates...'."\n"; |
|
| 2795 | + } |
|
| 2432 | 2796 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2433 | 2797 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
| 2434 | 2798 | $values = array(); |
@@ -2441,21 +2805,27 @@ discard block |
||
| 2441 | 2805 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 2442 | 2806 | } |
| 2443 | 2807 | |
| 2444 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2808 | + if ($globalDebug) { |
|
| 2809 | + echo '-> countAllHours...'."\n"; |
|
| 2810 | + } |
|
| 2445 | 2811 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
| 2446 | 2812 | foreach ($alldata as $number) { |
| 2447 | 2813 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 2448 | 2814 | } |
| 2449 | 2815 | |
| 2450 | 2816 | // Stats by filters |
| 2451 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2817 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2818 | + $globalStatsFilters = array(); |
|
| 2819 | + } |
|
| 2452 | 2820 | foreach ($globalStatsFilters as $name => $filter) { |
| 2453 | 2821 | //$filter_name = $filter['name']; |
| 2454 | 2822 | $filter_name = $name; |
| 2455 | 2823 | $reset = false; |
| 2456 | 2824 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 2457 | 2825 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 2458 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2826 | + if ($globalDebug) { |
|
| 2827 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2828 | + } |
|
| 2459 | 2829 | $this->deleteOldStats($filter_name); |
| 2460 | 2830 | unset($last_update); |
| 2461 | 2831 | } |
@@ -2474,7 +2844,9 @@ discard block |
||
| 2474 | 2844 | |
| 2475 | 2845 | |
| 2476 | 2846 | // Count by filter |
| 2477 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2847 | + if ($globalDebug) { |
|
| 2848 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2849 | + } |
|
| 2478 | 2850 | $Spotter = new Spotter($this->db); |
| 2479 | 2851 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 2480 | 2852 | foreach ($alldata as $number) { |
@@ -2511,7 +2883,9 @@ discard block |
||
| 2511 | 2883 | $icao = $value['airport_departure_icao']; |
| 2512 | 2884 | if (isset($alldata[$icao])) { |
| 2513 | 2885 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2514 | - } else $alldata[$icao] = $value; |
|
| 2886 | + } else { |
|
| 2887 | + $alldata[$icao] = $value; |
|
| 2888 | + } |
|
| 2515 | 2889 | } |
| 2516 | 2890 | $count = array(); |
| 2517 | 2891 | foreach ($alldata as $key => $row) { |
@@ -2532,7 +2906,9 @@ discard block |
||
| 2532 | 2906 | $icao = $value['airport_arrival_icao']; |
| 2533 | 2907 | if (isset($alldata[$icao])) { |
| 2534 | 2908 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2535 | - } else $alldata[$icao] = $value; |
|
| 2909 | + } else { |
|
| 2910 | + $alldata[$icao] = $value; |
|
| 2911 | + } |
|
| 2536 | 2912 | } |
| 2537 | 2913 | $count = array(); |
| 2538 | 2914 | foreach ($alldata as $key => $row) { |
@@ -2546,7 +2922,9 @@ discard block |
||
| 2546 | 2922 | $alldata = $Spotter->countAllMonths($filter); |
| 2547 | 2923 | $lastyear = false; |
| 2548 | 2924 | foreach ($alldata as $number) { |
| 2549 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2925 | + if ($number['year_name'] != date('Y')) { |
|
| 2926 | + $lastyear = true; |
|
| 2927 | + } |
|
| 2550 | 2928 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2551 | 2929 | } |
| 2552 | 2930 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -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 | /** |
@@ -32,7 +34,9 @@ discard block |
||
| 32 | 34 | if (isset($filter[0]['source'])) { |
| 33 | 35 | $filters = array_merge($filters,$filter); |
| 34 | 36 | } |
| 35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 37 | + if (is_array($globalFilter)) { |
|
| 38 | + $filter = array_merge($filter,$globalFilter); |
|
| 39 | + } |
|
| 36 | 40 | $filter_query_join = ''; |
| 37 | 41 | $filter_query_where = ''; |
| 38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
| 71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 72 | 76 | } |
| 73 | 77 | } |
| 74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 78 | + if ($filter_query_where == '' && $where) { |
|
| 79 | + $filter_query_where = ' WHERE'; |
|
| 80 | + } elseif ($filter_query_where != '' && $and) { |
|
| 81 | + $filter_query_where .= ' AND'; |
|
| 82 | + } |
|
| 76 | 83 | if ($filter_query_where != '') { |
| 77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
| 126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 127 | 134 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 128 | 135 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 129 | - */} |
|
| 130 | - elseif (isset($row['trackerid'])) { |
|
| 136 | + */} elseif (isset($row['trackerid'])) { |
|
| 131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
| 132 | 138 | } else { |
| 133 | 139 | $temp_array['trackerid'] = ''; |
| 134 | 140 | } |
| 135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
| 141 | + if (isset($row['famtrackid'])) { |
|
| 142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 143 | + } |
|
| 144 | + if (isset($row['type'])) { |
|
| 145 | + $temp_array['type'] = $row['type']; |
|
| 146 | + } |
|
| 147 | + if (isset($row['comment'])) { |
|
| 148 | + $temp_array['comment'] = $row['comment']; |
|
| 149 | + } |
|
| 138 | 150 | $temp_array['ident'] = $row['ident']; |
| 139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
| 151 | + if (isset($row['latitude'])) { |
|
| 152 | + $temp_array['latitude'] = $row['latitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['longitude'])) { |
|
| 155 | + $temp_array['longitude'] = $row['longitude']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['format_source'])) { |
|
| 158 | + $temp_array['format_source'] = $row['format_source']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['altitude'])) { |
|
| 161 | + $temp_array['altitude'] = $row['altitude']; |
|
| 162 | + } |
|
| 143 | 163 | if (isset($row['heading'])) { |
| 144 | 164 | $temp_array['heading'] = $row['heading']; |
| 145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
| 146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + if (isset($row['ground_speed'])) { |
|
| 171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 147 | 172 | } |
| 148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 149 | 173 | |
| 150 | 174 | if (isset($row['date'])) { |
| 151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
| 188 | 212 | } |
| 189 | 213 | |
| 190 | 214 | $fromsource = NULL; |
| 191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 216 | + $temp_array['source_name'] = $row['source_name']; |
|
| 217 | + } |
|
| 218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 219 | + $temp_array['over_country'] = $row['over_country']; |
|
| 220 | + } |
|
| 221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 222 | + $temp_array['distance'] = $row['distance']; |
|
| 223 | + } |
|
| 194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
| 195 | 225 | $spotter_array[] = $temp_array; |
| 196 | 226 | } |
| 197 | - if ($num_rows == 0) return array(); |
|
| 227 | + if ($num_rows == 0) { |
|
| 228 | + return array(); |
|
| 229 | + } |
|
| 198 | 230 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 199 | 231 | return $spotter_array; |
| 200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
| 225 | 257 | { |
| 226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 228 | - } else $limit_query = ""; |
|
| 229 | - } else $limit_query = ""; |
|
| 260 | + } else { |
|
| 261 | + $limit_query = ""; |
|
| 262 | + } |
|
| 263 | + } else { |
|
| 264 | + $limit_query = ""; |
|
| 265 | + } |
|
| 230 | 266 | |
| 231 | 267 | if ($sort != "") |
| 232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
| 254 | 290 | global $global_query; |
| 255 | 291 | |
| 256 | 292 | date_default_timezone_set('UTC'); |
| 257 | - if ($id == '') return array(); |
|
| 293 | + if ($id == '') { |
|
| 294 | + return array(); |
|
| 295 | + } |
|
| 258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
| 259 | 297 | $query_values = array(':id' => $id); |
| 260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
| 397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
| 398 | 436 | |
| 399 | 437 | $sth = $this->db->prepare($query); |
| 400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 401 | - else $sth->execute(); |
|
| 438 | + if (!empty($query_values)) { |
|
| 439 | + $sth->execute($query_values); |
|
| 440 | + } else { |
|
| 441 | + $sth->execute(); |
|
| 442 | + } |
|
| 402 | 443 | |
| 403 | 444 | $source_array = array(); |
| 404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
| 453 | 494 | date_default_timezone_set($globalTimezone); |
| 454 | 495 | $datetime = new DateTime(); |
| 455 | 496 | $offset = $datetime->format('P'); |
| 456 | - } else $offset = '+00:00'; |
|
| 497 | + } else { |
|
| 498 | + $offset = '+00:00'; |
|
| 499 | + } |
|
| 457 | 500 | |
| 458 | 501 | if ($globalDBdriver == 'mysql') { |
| 459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
| 609 | 652 | { |
| 610 | 653 | return false; |
| 611 | 654 | } |
| 612 | - } else $altitude = 0; |
|
| 655 | + } else { |
|
| 656 | + $altitude = 0; |
|
| 657 | + } |
|
| 613 | 658 | |
| 614 | 659 | if ($heading != "") |
| 615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
| 648 | 693 | $latitude = 0; |
| 649 | 694 | $longitude = 0; |
| 650 | 695 | } |
| 651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 697 | + $heading = 0; |
|
| 698 | + } |
|
| 699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 700 | + $groundspeed = 0; |
|
| 701 | + } |
|
| 653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
| 654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 655 | 704 | |
@@ -758,7 +807,9 @@ discard block |
||
| 758 | 807 | global $globalDBdriver, $globalArchive; |
| 759 | 808 | //$filter_query = $this->getFilter($filters,true,true); |
| 760 | 809 | $Connection= new Connection($this->db); |
| 761 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 810 | + if (!$Connection->tableExists('countries')) { |
|
| 811 | + return array(); |
|
| 812 | + } |
|
| 762 | 813 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 763 | 814 | require_once('class.TrackerLive.php'); |
| 764 | 815 | $TrackerLive = new TrackerLive($this->db); |
@@ -801,7 +852,9 @@ discard block |
||
| 801 | 852 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 802 | 853 | } |
| 803 | 854 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 804 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 855 | + if ($limit) { |
|
| 856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 857 | + } |
|
| 805 | 858 | |
| 806 | 859 | |
| 807 | 860 | $sth = $this->db->prepare($query); |
@@ -834,12 +887,18 @@ discard block |
||
| 834 | 887 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
| 835 | 888 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 836 | 889 | if ($olderthanmonths > 0) { |
| 837 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 838 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 890 | + if ($globalDBdriver == 'mysql') { |
|
| 891 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 892 | + } else { |
|
| 893 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 894 | + } |
|
| 839 | 895 | } |
| 840 | 896 | if ($sincedate != '') { |
| 841 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 842 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 897 | + if ($globalDBdriver == 'mysql') { |
|
| 898 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 899 | + } else { |
|
| 900 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 901 | + } |
|
| 843 | 902 | } |
| 844 | 903 | $query_values = array(); |
| 845 | 904 | if ($year != '') { |
@@ -870,7 +929,9 @@ discard block |
||
| 870 | 929 | } |
| 871 | 930 | } |
| 872 | 931 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
| 873 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 932 | + if ($limit) { |
|
| 933 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 934 | + } |
|
| 874 | 935 | |
| 875 | 936 | $sth = $this->db->prepare($query); |
| 876 | 937 | $sth->execute($query_values); |
@@ -905,7 +966,9 @@ discard block |
||
| 905 | 966 | date_default_timezone_set($globalTimezone); |
| 906 | 967 | $datetime = new DateTime(); |
| 907 | 968 | $offset = $datetime->format('P'); |
| 908 | - } else $offset = '+00:00'; |
|
| 969 | + } else { |
|
| 970 | + $offset = '+00:00'; |
|
| 971 | + } |
|
| 909 | 972 | |
| 910 | 973 | if ($globalDBdriver == 'mysql') { |
| 911 | 974 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -955,7 +1018,9 @@ discard block |
||
| 955 | 1018 | date_default_timezone_set($globalTimezone); |
| 956 | 1019 | $datetime = new DateTime(); |
| 957 | 1020 | $offset = $datetime->format('P'); |
| 958 | - } else $offset = '+00:00'; |
|
| 1021 | + } else { |
|
| 1022 | + $offset = '+00:00'; |
|
| 1023 | + } |
|
| 959 | 1024 | $filter_query = $this->getFilter($filters,true,true); |
| 960 | 1025 | if ($globalDBdriver == 'mysql') { |
| 961 | 1026 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1001,7 +1066,9 @@ discard block |
||
| 1001 | 1066 | date_default_timezone_set($globalTimezone); |
| 1002 | 1067 | $datetime = new DateTime(); |
| 1003 | 1068 | $offset = $datetime->format('P'); |
| 1004 | - } else $offset = '+00:00'; |
|
| 1069 | + } else { |
|
| 1070 | + $offset = '+00:00'; |
|
| 1071 | + } |
|
| 1005 | 1072 | $filter_query = $this->getFilter($filters,true,true); |
| 1006 | 1073 | if ($globalDBdriver == 'mysql') { |
| 1007 | 1074 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1049,7 +1116,9 @@ discard block |
||
| 1049 | 1116 | date_default_timezone_set($globalTimezone); |
| 1050 | 1117 | $datetime = new DateTime(); |
| 1051 | 1118 | $offset = $datetime->format('P'); |
| 1052 | - } else $offset = '+00:00'; |
|
| 1119 | + } else { |
|
| 1120 | + $offset = '+00:00'; |
|
| 1121 | + } |
|
| 1053 | 1122 | |
| 1054 | 1123 | if ($globalDBdriver == 'mysql') { |
| 1055 | 1124 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1098,7 +1167,9 @@ discard block |
||
| 1098 | 1167 | date_default_timezone_set($globalTimezone); |
| 1099 | 1168 | $datetime = new DateTime(); |
| 1100 | 1169 | $offset = $datetime->format('P'); |
| 1101 | - } else $offset = '+00:00'; |
|
| 1170 | + } else { |
|
| 1171 | + $offset = '+00:00'; |
|
| 1172 | + } |
|
| 1102 | 1173 | $filter_query = $this->getFilter($filters,true,true); |
| 1103 | 1174 | if ($globalDBdriver == 'mysql') { |
| 1104 | 1175 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1147,7 +1218,9 @@ discard block |
||
| 1147 | 1218 | date_default_timezone_set($globalTimezone); |
| 1148 | 1219 | $datetime = new DateTime(); |
| 1149 | 1220 | $offset = $datetime->format('P'); |
| 1150 | - } else $offset = '+00:00'; |
|
| 1221 | + } else { |
|
| 1222 | + $offset = '+00:00'; |
|
| 1223 | + } |
|
| 1151 | 1224 | |
| 1152 | 1225 | $orderby_sql = ''; |
| 1153 | 1226 | if ($orderby == "hour") |
@@ -1216,7 +1289,9 @@ discard block |
||
| 1216 | 1289 | date_default_timezone_set($globalTimezone); |
| 1217 | 1290 | $datetime = new DateTime($date); |
| 1218 | 1291 | $offset = $datetime->format('P'); |
| 1219 | - } else $offset = '+00:00'; |
|
| 1292 | + } else { |
|
| 1293 | + $offset = '+00:00'; |
|
| 1294 | + } |
|
| 1220 | 1295 | |
| 1221 | 1296 | if ($globalDBdriver == 'mysql') { |
| 1222 | 1297 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1264,7 +1339,9 @@ discard block |
||
| 1264 | 1339 | date_default_timezone_set($globalTimezone); |
| 1265 | 1340 | $datetime = new DateTime(); |
| 1266 | 1341 | $offset = $datetime->format('P'); |
| 1267 | - } else $offset = '+00:00'; |
|
| 1342 | + } else { |
|
| 1343 | + $offset = '+00:00'; |
|
| 1344 | + } |
|
| 1268 | 1345 | |
| 1269 | 1346 | if ($globalDBdriver == 'mysql') { |
| 1270 | 1347 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1329,8 +1406,11 @@ discard block |
||
| 1329 | 1406 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1330 | 1407 | } |
| 1331 | 1408 | } |
| 1332 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1409 | + if (empty($query_values)) { |
|
| 1410 | + $queryi .= $this->getFilter($filters); |
|
| 1411 | + } else { |
|
| 1412 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1413 | + } |
|
| 1334 | 1414 | |
| 1335 | 1415 | $sth = $this->db->prepare($queryi); |
| 1336 | 1416 | $sth->execute($query_values); |
@@ -1367,8 +1447,11 @@ discard block |
||
| 1367 | 1447 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1368 | 1448 | } |
| 1369 | 1449 | } |
| 1370 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1450 | + if (empty($query_values)) { |
|
| 1451 | + $queryi .= $this->getFilter($filters); |
|
| 1452 | + } else { |
|
| 1453 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1454 | + } |
|
| 1372 | 1455 | |
| 1373 | 1456 | $sth = $this->db->prepare($queryi); |
| 1374 | 1457 | $sth->execute($query_values); |
@@ -1390,7 +1473,9 @@ discard block |
||
| 1390 | 1473 | date_default_timezone_set($globalTimezone); |
| 1391 | 1474 | $datetime = new DateTime(); |
| 1392 | 1475 | $offset = $datetime->format('P'); |
| 1393 | - } else $offset = '+00:00'; |
|
| 1476 | + } else { |
|
| 1477 | + $offset = '+00:00'; |
|
| 1478 | + } |
|
| 1394 | 1479 | |
| 1395 | 1480 | if ($globalDBdriver == 'mysql') { |
| 1396 | 1481 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1494,7 +1579,9 @@ discard block |
||
| 1494 | 1579 | */ |
| 1495 | 1580 | public function parseDirection($direction = 0) |
| 1496 | 1581 | { |
| 1497 | - if ($direction == '') $direction = 0; |
|
| 1582 | + if ($direction == '') { |
|
| 1583 | + $direction = 0; |
|
| 1584 | + } |
|
| 1498 | 1585 | $direction_array = array(); |
| 1499 | 1586 | $temp_array = array(); |
| 1500 | 1587 | |
@@ -1583,7 +1670,9 @@ discard block |
||
| 1583 | 1670 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1584 | 1671 | |
| 1585 | 1672 | $Connection = new Connection($this->db); |
| 1586 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1673 | + if (!$Connection->tableExists('countries')) { |
|
| 1674 | + return ''; |
|
| 1675 | + } |
|
| 1587 | 1676 | |
| 1588 | 1677 | try { |
| 1589 | 1678 | /* |
@@ -1603,9 +1692,13 @@ discard block |
||
| 1603 | 1692 | $sth->closeCursor(); |
| 1604 | 1693 | if (count($row) > 0) { |
| 1605 | 1694 | return $row; |
| 1606 | - } else return ''; |
|
| 1695 | + } else { |
|
| 1696 | + return ''; |
|
| 1697 | + } |
|
| 1607 | 1698 | } catch (PDOException $e) { |
| 1608 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1699 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1700 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1701 | + } |
|
| 1609 | 1702 | return ''; |
| 1610 | 1703 | } |
| 1611 | 1704 | |
@@ -1623,7 +1716,9 @@ discard block |
||
| 1623 | 1716 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1624 | 1717 | |
| 1625 | 1718 | $Connection = new Connection($this->db); |
| 1626 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1719 | + if (!$Connection->tableExists('countries')) { |
|
| 1720 | + return ''; |
|
| 1721 | + } |
|
| 1627 | 1722 | |
| 1628 | 1723 | try { |
| 1629 | 1724 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1635,9 +1730,13 @@ discard block |
||
| 1635 | 1730 | $sth->closeCursor(); |
| 1636 | 1731 | if (count($row) > 0) { |
| 1637 | 1732 | return $row; |
| 1638 | - } else return ''; |
|
| 1733 | + } else { |
|
| 1734 | + return ''; |
|
| 1735 | + } |
|
| 1639 | 1736 | } catch (PDOException $e) { |
| 1640 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1737 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1738 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1739 | + } |
|
| 1641 | 1740 | return ''; |
| 1642 | 1741 | } |
| 1643 | 1742 | |
@@ -1698,7 +1797,9 @@ discard block |
||
| 1698 | 1797 | } |
| 1699 | 1798 | } |
| 1700 | 1799 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
| 1701 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1800 | + if ($limit) { |
|
| 1801 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1802 | + } |
|
| 1702 | 1803 | $sth = $this->db->prepare($query); |
| 1703 | 1804 | $sth->execute($query_values); |
| 1704 | 1805 | $tracker_array = array(); |
@@ -1725,7 +1826,9 @@ discard block |
||
| 1725 | 1826 | { |
| 1726 | 1827 | global $globalBitlyAccessToken; |
| 1727 | 1828 | |
| 1728 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1829 | + if ($globalBitlyAccessToken == '') { |
|
| 1830 | + return $url; |
|
| 1831 | + } |
|
| 1729 | 1832 | |
| 1730 | 1833 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1731 | 1834 | |