@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class MarineImport { |
| 16 | - private $all_tracked = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_tracked = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
| 27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 28 | - $Connection = new Connection($dbc); |
|
| 29 | - $this->db = $Connection->db(); |
|
| 30 | - date_default_timezone_set('UTC'); |
|
| 28 | + $Connection = new Connection($dbc); |
|
| 29 | + $this->db = $Connection->db(); |
|
| 30 | + date_default_timezone_set('UTC'); |
|
| 31 | 31 | } |
| 32 | 32 | // Get previous source stats |
| 33 | 33 | /* |
@@ -46,75 +46,75 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | */ |
| 48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 49 | - $APRSMarine = new APRSMarine(); |
|
| 50 | - //$APRSSpotter->connect(); |
|
| 49 | + $APRSMarine = new APRSMarine(); |
|
| 50 | + //$APRSSpotter->connect(); |
|
| 51 | + } |
|
| 51 | 52 | } |
| 52 | - } |
|
| 53 | 53 | |
| 54 | - public function checkAll() { |
|
| 54 | + public function checkAll() { |
|
| 55 | 55 | global $globalDebug, $globalNoDB; |
| 56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | - foreach ($this->all_tracked as $key => $flight) { |
|
| 57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | + foreach ($this->all_tracked as $key => $flight) { |
|
| 59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
| 60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | - $Marine = new Marine($this->db); |
|
| 62 | - if (isset($globalVM) && $globalVM) { |
|
| 60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | + $Marine = new Marine($this->db); |
|
| 62 | + if (isset($globalVM) && $globalVM) { |
|
| 63 | 63 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 64 | - $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 65 | - } else { |
|
| 66 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | - $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 68 | - } |
|
| 69 | - } else { |
|
| 64 | + $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 65 | + } else { |
|
| 66 | + $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | + $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 68 | + } |
|
| 69 | + } else { |
|
| 70 | 70 | $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | - } |
|
| 73 | + } |
|
| 74 | + } |
|
| 74 | 75 | } |
| 75 | - } |
|
| 76 | 76 | |
| 77 | - public function del() { |
|
| 77 | + public function del() { |
|
| 78 | 78 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 79 | 79 | // Delete old infos |
| 80 | 80 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 81 | 81 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | - if (isset($flight['lastupdate'])) { |
|
| 83 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 84 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 85 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 86 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 87 | - /* |
|
| 82 | + if (isset($flight['lastupdate'])) { |
|
| 83 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 84 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 85 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 86 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 87 | + /* |
|
| 88 | 88 | $MarineLive = new MarineLive(); |
| 89 | 89 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 90 | 90 | $MarineLive->db = null; |
| 91 | 91 | */ |
| 92 | - //$real_arrival = $this->arrival($key); |
|
| 93 | - $Marine = new Marine($this->db); |
|
| 94 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 92 | + //$real_arrival = $this->arrival($key); |
|
| 93 | + $Marine = new Marine($this->db); |
|
| 94 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 95 | 95 | if (isset($globalVM) && $globalVM) { |
| 96 | - if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
| 96 | + if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
| 97 | 97 | $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 98 | - } else { |
|
| 98 | + } else { |
|
| 99 | 99 | $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
| 100 | 100 | $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 101 | - } |
|
| 101 | + } |
|
| 102 | 102 | } else { |
| 103 | 103 | $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 104 | 104 | } |
| 105 | 105 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 106 | - } |
|
| 107 | - // Put in archive |
|
| 106 | + } |
|
| 107 | + // Put in archive |
|
| 108 | 108 | // $Marine->db = null; |
| 109 | 109 | } |
| 110 | - } |
|
| 111 | - unset($this->all_tracked[$key]); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 110 | + } |
|
| 111 | + unset($this->all_tracked[$key]); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - public function add($line) { |
|
| 117 | + public function add($line) { |
|
| 118 | 118 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
| 119 | 119 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 120 | 120 | date_default_timezone_set('UTC'); |
@@ -123,106 +123,106 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // SBS format is CSV format |
| 125 | 125 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
| 126 | - //print_r($line); |
|
| 127 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 126 | + //print_r($line); |
|
| 127 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | // Increment message number |
| 131 | 131 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 132 | - $current_date = date('Y-m-d'); |
|
| 133 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | - else $source = ''; |
|
| 135 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 136 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 137 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 138 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 139 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 132 | + $current_date = date('Y-m-d'); |
|
| 133 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | + else $source = ''; |
|
| 135 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 136 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 137 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 138 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 139 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | $Common = new Common(); |
| 144 | 144 | $AIS = new AIS(); |
| 145 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | - else $id = trim($line['id']); |
|
| 145 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | + else $id = trim($line['id']); |
|
| 147 | 147 | |
| 148 | 148 | if (!isset($this->all_tracked[$id])) { |
| 149 | - $this->all_tracked[$id] = array(); |
|
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
|
| 152 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 153 | - if (!isset($line['id'])) { |
|
| 149 | + $this->all_tracked[$id] = array(); |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
|
| 152 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 153 | + if (!isset($line['id'])) { |
|
| 154 | 154 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 155 | 155 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 156 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 162 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 162 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 163 | 163 | $Marine = new Marine($this->db); |
| 164 | 164 | $identity = $Marine->getIdentity($line['mmsi']); |
| 165 | 165 | if (!empty($identity)) { |
| 166 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 167 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 166 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 167 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 169 | 169 | } |
| 170 | 170 | //print_r($identity); |
| 171 | 171 | unset($Marine); |
| 172 | 172 | //$dataFound = true; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | if (isset($line['type_id'])) { |
| 176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 178 | 178 | } |
| 179 | 179 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 180 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 180 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 182 | 182 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
| 183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 184 | 184 | } |
| 185 | 185 | if (isset($line['status']) && $line['status'] != '') { |
| 186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 187 | 187 | } |
| 188 | 188 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 190 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 190 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 191 | 191 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 192 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 192 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 193 | 193 | $Marine = new Marine($this->db); |
| 194 | 194 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
| 195 | 195 | unset($Marine); |
| 196 | - } |
|
| 196 | + } |
|
| 197 | + } |
|
| 197 | 198 | } |
| 198 | - } |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 203 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 203 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 204 | 204 | } |
| 205 | 205 | if (isset($line['imo']) && $line['imo'] != '') { |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 207 | 207 | } |
| 208 | 208 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 209 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 209 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 210 | 210 | } |
| 211 | 211 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 212 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 213 | 213 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 214 | 214 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 215 | 215 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 216 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 217 | 217 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 218 | - $Marine = new Marine($this->db); |
|
| 219 | - $fromsource = NULL; |
|
| 220 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 221 | - $Marine->db = null; |
|
| 218 | + $Marine = new Marine($this->db); |
|
| 219 | + $fromsource = NULL; |
|
| 220 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 221 | + $Marine->db = null; |
|
| 222 | + } |
|
| 222 | 223 | } |
| 223 | - } |
|
| 224 | 224 | } |
| 225 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 225 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 226 | 226 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 227 | 227 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 228 | 228 | if (!isset($line['id'])) { |
@@ -230,50 +230,50 @@ discard block |
||
| 230 | 230 | $this->all_tracked[$id]['forcenew'] = 1; |
| 231 | 231 | $this->all_tracked[$id]['addedMarine'] = 0; |
| 232 | 232 | } |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 236 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 243 | 243 | } |
| 244 | 244 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 245 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 245 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 246 | 246 | } |
| 247 | 247 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 249 | 249 | } |
| 250 | 250 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
| 251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 252 | 252 | } |
| 253 | 253 | if (isset($line['race_time']) && $line['race_time'] != '') { |
| 254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 255 | 255 | } |
| 256 | 256 | if (isset($line['race_begin']) && $line['race_begin'] != '') { |
| 257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 258 | 258 | } |
| 259 | 259 | if (isset($line['distance']) && $line['distance'] != '') { |
| 260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 264 | 264 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 265 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 265 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | - $timeelapsed = microtime(true); |
|
| 268 | - $Marine = new Marine($this->db); |
|
| 269 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 270 | - $Marine->db = null; |
|
| 267 | + $timeelapsed = microtime(true); |
|
| 268 | + $Marine = new Marine($this->db); |
|
| 269 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 270 | + $Marine->db = null; |
|
| 271 | + } |
|
| 271 | 272 | } |
| 272 | - } |
|
| 273 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 274 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 273 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 274 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 275 | 275 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 276 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 276 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 277 | 277 | $timeelapsed = microtime(true); |
| 278 | 278 | $Marine = new Marine($this->db); |
| 279 | 279 | $fromsource = NULL; |
@@ -281,20 +281,20 @@ discard block |
||
| 281 | 281 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 282 | 282 | $Marine->db = null; |
| 283 | 283 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 284 | - } |
|
| 284 | + } |
|
| 285 | + } |
|
| 285 | 286 | } |
| 286 | - } |
|
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 287 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 291 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 291 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 292 | 292 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 293 | - } else { |
|
| 293 | + } else { |
|
| 294 | 294 | 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"; |
| 295 | 295 | 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"; |
| 296 | 296 | return ''; |
| 297 | - } |
|
| 297 | + } |
|
| 298 | 298 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 299 | 299 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 300 | 300 | return ''; |
@@ -311,33 +311,33 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | if (isset($line['speed'])) { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 316 | 316 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 317 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 318 | - if ($distance > 1000 && $distance < 10000) { |
|
| 317 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 318 | + if ($distance > 1000 && $distance < 10000) { |
|
| 319 | 319 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 320 | $speed = $speed*3.6; |
| 321 | 321 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
| 322 | 322 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 323 | - } |
|
| 323 | + } |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | - else unset($timediff); |
|
| 329 | - if ($this->tmd > 5 || |
|
| 330 | - !isset($timediff) || |
|
| 331 | - $timediff > $globalLiveInterval || |
|
| 332 | - ( |
|
| 333 | - $timediff > 30 && |
|
| 334 | - isset($this->all_tracked[$id]['latitude']) && |
|
| 335 | - isset($this->all_tracked[$id]['longitude']) && |
|
| 336 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 337 | - ) |
|
| 338 | - ) { |
|
| 326 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 327 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | + else unset($timediff); |
|
| 329 | + if ($this->tmd > 5 || |
|
| 330 | + !isset($timediff) || |
|
| 331 | + $timediff > $globalLiveInterval || |
|
| 332 | + ( |
|
| 333 | + $timediff > 30 && |
|
| 334 | + isset($this->all_tracked[$id]['latitude']) && |
|
| 335 | + isset($this->all_tracked[$id]['longitude']) && |
|
| 336 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 337 | + ) |
|
| 338 | + ) { |
|
| 339 | 339 | 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'])) { |
| 340 | - 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'])) { |
|
| 340 | + 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'])) { |
|
| 341 | 341 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 342 | 342 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 343 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -345,213 +345,213 @@ discard block |
||
| 345 | 345 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 346 | 346 | $timeelapsed = microtime(true); |
| 347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | - $Marine = new Marine($this->db); |
|
| 349 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 350 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 351 | - $Marine->db = null; |
|
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 348 | + $Marine = new Marine($this->db); |
|
| 349 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 350 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 351 | + $Marine->db = null; |
|
| 352 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 353 | 353 | } |
| 354 | 354 | $this->tmd = 0; |
| 355 | 355 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 356 | - } |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | 360 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 361 | 361 | 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') { |
| 362 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 363 | - $dataFound = true; |
|
| 364 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 362 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 363 | + $dataFound = true; |
|
| 364 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 365 | 365 | } |
| 366 | 366 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 367 | 367 | } |
| 368 | 368 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 369 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 370 | 370 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 371 | 371 | 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') { |
| 372 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 373 | - $dataFound = true; |
|
| 374 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 372 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 373 | + $dataFound = true; |
|
| 374 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 375 | 375 | } |
| 376 | 376 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - } else if ($globalDebug && $timediff > 20) { |
|
| 379 | + } else if ($globalDebug && $timediff > 20) { |
|
| 380 | 380 | $this->tmd = $this->tmd + 1; |
| 381 | 381 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 382 | 382 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 383 | 383 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 384 | 384 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 389 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 388 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 389 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 390 | 390 | } |
| 391 | 391 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 392 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 392 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 393 | 393 | } |
| 394 | 394 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 395 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 395 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 396 | 396 | } |
| 397 | 397 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 398 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 398 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 405 | - //$dataFound = true; |
|
| 402 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 405 | + //$dataFound = true; |
|
| 406 | 406 | } 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']) { |
| 407 | - $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']); |
|
| 408 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 407 | + $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']); |
|
| 408 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 411 | 411 | } |
| 412 | 412 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 413 | 413 | |
| 414 | 414 | |
| 415 | 415 | |
| 416 | 416 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 417 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 418 | - if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
| 419 | - 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'])) { |
|
| 420 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 417 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 418 | + if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
| 419 | + 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'])) { |
|
| 420 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 423 | - $timeelapsed = microtime(true); |
|
| 424 | - $MarineLive = new MarineLive($this->db); |
|
| 425 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 422 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 423 | + $timeelapsed = microtime(true); |
|
| 424 | + $MarineLive = new MarineLive($this->db); |
|
| 425 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 426 | 426 | $Marine = new Marine($this->db); |
| 427 | 427 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | 428 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 429 | 429 | $Marine->db=null; |
| 430 | - } elseif (isset($line['id'])) { |
|
| 430 | + } elseif (isset($line['id'])) { |
|
| 431 | 431 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | 432 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 433 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 433 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 434 | 434 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | 435 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 436 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 436 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 437 | 437 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | 438 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 439 | - } else $recent_ident = ''; |
|
| 440 | - $MarineLive->db=null; |
|
| 441 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 439 | + } else $recent_ident = ''; |
|
| 440 | + $MarineLive->db=null; |
|
| 441 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 443 | 443 | } else $recent_ident = ''; |
| 444 | - } else { |
|
| 444 | + } else { |
|
| 445 | 445 | $recent_ident = ''; |
| 446 | 446 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 447 | - } |
|
| 448 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 449 | - if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | - { |
|
| 447 | + } |
|
| 448 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 449 | + if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | + { |
|
| 451 | 451 | if ($globalDebug) { |
| 452 | 452 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 453 | 453 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 454 | 454 | } |
| 455 | 455 | //adds the spotter data for the archive |
| 456 | - $highlight = ''; |
|
| 457 | - 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'))); |
|
| 458 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 456 | + $highlight = ''; |
|
| 457 | + 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'))); |
|
| 458 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 459 | 459 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | - $timeelapsed = microtime(true); |
|
| 461 | - $Marine = new Marine($this->db); |
|
| 462 | - if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') { |
|
| 460 | + $timeelapsed = microtime(true); |
|
| 461 | + $Marine = new Marine($this->db); |
|
| 462 | + if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') { |
|
| 463 | 463 | $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]['race_begin'], $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 464 | - } else { |
|
| 464 | + } else { |
|
| 465 | 465 | $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 466 | - } |
|
| 467 | - $Marine->db = null; |
|
| 468 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 466 | + } |
|
| 467 | + $Marine->db = null; |
|
| 468 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 470 | + } |
|
| 470 | 471 | } |
| 471 | - } |
|
| 472 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 472 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 473 | 473 | // Add source stat in DB |
| 474 | 474 | $Stats = new Stats($this->db); |
| 475 | 475 | if (!empty($this->stats)) { |
| 476 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 477 | - foreach($this->stats as $date => $data) { |
|
| 476 | + if ($globalDebug) echo 'Add source stats : '; |
|
| 477 | + foreach($this->stats as $date => $data) { |
|
| 478 | 478 | foreach($data as $source => $sourced) { |
| 479 | - //print_r($sourced); |
|
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 482 | - if (isset($sourced['msg'])) { |
|
| 483 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 484 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 485 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 486 | - unset($this->stats[$date][$source]['msg']); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - if ($date != date('Y-m-d')) { |
|
| 491 | - unset($this->stats[$date]); |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 479 | + //print_r($sourced); |
|
| 480 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 482 | + if (isset($sourced['msg'])) { |
|
| 483 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 484 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 485 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 486 | + unset($this->stats[$date][$source]['msg']); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + if ($date != date('Y-m-d')) { |
|
| 491 | + unset($this->stats[$date]); |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 495 | 495 | } |
| 496 | 496 | $Stats->db = null; |
| 497 | - } |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - $this->del(); |
|
| 499 | + $this->del(); |
|
| 500 | 500 | //$ignoreImport = false; |
| 501 | 501 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 502 | 502 | //print_r($this->all_tracked[$id]); |
| 503 | 503 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 504 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 505 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 506 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 504 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 505 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 506 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 507 | 507 | $MarineLive = new MarineLive($this->db); |
| 508 | 508 | $MarineLive->deleteLiveMarineData(); |
| 509 | 509 | $MarineLive->db=null; |
| 510 | 510 | if ($globalDebug) echo " Done\n"; |
| 511 | - } |
|
| 512 | - $this->last_delete = time(); |
|
| 511 | + } |
|
| 512 | + $this->last_delete = time(); |
|
| 513 | 513 | } |
| 514 | - } elseif ($recent_ident != '') { |
|
| 514 | + } elseif ($recent_ident != '') { |
|
| 515 | 515 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 516 | 516 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 517 | 517 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 518 | - if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
| 518 | + if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
| 519 | 519 | $Marine = new Marine($this->db); |
| 520 | 520 | if (isset($globalVM) && $globalVM) { |
| 521 | - if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
| 521 | + if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
| 522 | 522 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
| 523 | - } else { |
|
| 523 | + } else { |
|
| 524 | 524 | $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
| 525 | 525 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | } else { |
| 528 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
| 528 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
| 529 | 529 | } |
| 530 | 530 | $Marine->db = null; |
| 531 | - } |
|
| 531 | + } |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - } |
|
| 534 | + } |
|
| 535 | + } |
|
| 535 | 536 | } |
| 536 | - } |
|
| 537 | - //adds the spotter LIVE data |
|
| 538 | - if ($globalDebug) { |
|
| 537 | + //adds the spotter LIVE data |
|
| 538 | + if ($globalDebug) { |
|
| 539 | 539 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 540 | - } |
|
| 541 | - $ignoreImport = false; |
|
| 542 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 543 | - if (!$ignoreImport) { |
|
| 540 | + } |
|
| 541 | + $ignoreImport = false; |
|
| 542 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 543 | + if (!$ignoreImport) { |
|
| 544 | 544 | 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'])) { |
| 545 | 545 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 546 | 546 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 547 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 548 | 548 | $timeelapsed = microtime(true); |
| 549 | 549 | $MarineLive = new MarineLive($this->db); |
| 550 | 550 | $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 551 | 551 | $MarineLive->db = null; |
| 552 | 552 | if ($globalDebug) echo $result."\n"; |
| 553 | 553 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 554 | - } |
|
| 554 | + } |
|
| 555 | 555 | } |
| 556 | 556 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 557 | 557 | $APRSMarine->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']); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | if ($stats_heading == 16) $stats_heading = 0; |
| 587 | 587 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | 588 | for ($i=0;$i<=15;$i++) { |
| 589 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 589 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 590 | 590 | } |
| 591 | 591 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 592 | 592 | } else { |
@@ -599,11 +599,11 @@ discard block |
||
| 599 | 599 | //var_dump($this->stats); |
| 600 | 600 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 601 | 601 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | - end($this->stats[$current_date][$source]['hist']); |
|
| 603 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 602 | + end($this->stats[$current_date][$source]['hist']); |
|
| 603 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 604 | 604 | } else $mini = 0; |
| 605 | 605 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 606 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 606 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 607 | 607 | } |
| 608 | 608 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 609 | 609 | } else { |
@@ -619,24 +619,24 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | |
| 621 | 621 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 622 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 622 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 623 | 623 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 624 | 624 | $MarineLive = new MarineLive($this->db); |
| 625 | 625 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 626 | 626 | $MarineLive->db = null; |
| 627 | 627 | //MarineLive->deleteLiveMarineData(); |
| 628 | 628 | if ($globalDebug) echo " Done\n"; |
| 629 | - } |
|
| 630 | - $this->last_delete_hourly = time(); |
|
| 629 | + } |
|
| 630 | + $this->last_delete_hourly = time(); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - } |
|
| 634 | - //$ignoreImport = false; |
|
| 633 | + } |
|
| 634 | + //$ignoreImport = false; |
|
| 635 | 635 | } |
| 636 | 636 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 637 | 637 | if ($send) return $this->all_tracked[$id]; |
| 638 | - } |
|
| 638 | + } |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | 641 | } |
| 642 | 642 | ?> |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | $Marine = new Marine($this->db); |
| 62 | 62 | if (isset($globalVM) && $globalVM) { |
| 63 | 63 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 64 | - $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 64 | + $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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 65 | 65 | } else { |
| 66 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | - $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 66 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']); |
|
| 67 | + $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'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 70 | + $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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 81 | 81 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | 82 | if (isset($flight['lastupdate'])) { |
| 83 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 83 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 84 | 84 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 85 | 85 | if (isset($this->all_tracked[$key]['id'])) { |
| 86 | 86 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 95 | 95 | if (isset($globalVM) && $globalVM) { |
| 96 | 96 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 97 | - $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 97 | + $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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 98 | 98 | } else { |
| 99 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 100 | - $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 99 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']); |
|
| 100 | + $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'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
|
| 103 | + $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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']); |
|
| 104 | 104 | } |
| 105 | 105 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 106 | 106 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function add($line) { |
| 118 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
|
| 118 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM; |
|
| 119 | 119 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 120 | 120 | date_default_timezone_set('UTC'); |
| 121 | 121 | $dataFound = false; |
| 122 | 122 | $send = false; |
| 123 | 123 | |
| 124 | 124 | // SBS format is CSV format |
| 125 | - if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
| 125 | + if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
| 126 | 126 | //print_r($line); |
| 127 | 127 | if (isset($line['mmsi']) || isset($line['id'])) { |
| 128 | 128 | |
@@ -147,25 +147,25 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if (!isset($this->all_tracked[$id])) { |
| 149 | 149 | $this->all_tracked[$id] = array(); |
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
|
| 152 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 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' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '', 'distance' => NULL, 'race_rank' => NULL, 'race_time' => NULL, 'race_begin' => '')); |
|
| 152 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 153 | 153 | if (!isset($line['id'])) { |
| 154 | 154 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 155 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 155 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 156 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 157 | 157 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 162 | 162 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 163 | 163 | $Marine = new Marine($this->db); |
| 164 | 164 | $identity = $Marine->getIdentity($line['mmsi']); |
| 165 | 165 | if (!empty($identity)) { |
| 166 | 166 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
| 167 | 167 | $this->all_tracked[$id]['type'] = $identity['type']; |
| 168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 169 | 169 | } |
| 170 | 170 | //print_r($identity); |
| 171 | 171 | unset($Marine); |
@@ -173,25 +173,25 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | if (isset($line['type_id'])) { |
| 176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
| 178 | 178 | } |
| 179 | 179 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 180 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 180 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 182 | 182 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
| 183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 184 | 184 | } |
| 185 | 185 | if (isset($line['status']) && $line['status'] != '') { |
| 186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 187 | 187 | } |
| 188 | 188 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
| 190 | 190 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 191 | 191 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 192 | 192 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 193 | 193 | $Marine = new Marine($this->db); |
| 194 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
| 194 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
| 195 | 195 | unset($Marine); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -200,24 +200,24 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 203 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 203 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
| 204 | 204 | } |
| 205 | 205 | if (isset($line['imo']) && $line['imo'] != '') { |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 207 | 207 | } |
| 208 | 208 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 209 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 209 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 210 | 210 | } |
| 211 | 211 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | 212 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 213 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 214 | 214 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 215 | 215 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | 216 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 217 | 217 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 218 | 218 | $Marine = new Marine($this->db); |
| 219 | 219 | $fromsource = NULL; |
| 220 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 220 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
| 221 | 221 | $Marine->db = null; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -233,31 +233,31 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 236 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
| 243 | 243 | } |
| 244 | 244 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 245 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 245 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
| 246 | 246 | } |
| 247 | 247 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
| 249 | 249 | } |
| 250 | 250 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
| 251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank'])); |
|
| 252 | 252 | } |
| 253 | 253 | if (isset($line['race_time']) && $line['race_time'] != '') { |
| 254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time'])); |
|
| 255 | 255 | } |
| 256 | 256 | if (isset($line['race_begin']) && $line['race_begin'] != '') { |
| 257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_begin' => $line['race_begin'])); |
|
| 258 | 258 | } |
| 259 | 259 | if (isset($line['distance']) && $line['distance'] != '') { |
| 260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance'])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -266,44 +266,44 @@ discard block |
||
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | 267 | $timeelapsed = microtime(true); |
| 268 | 268 | $Marine = new Marine($this->db); |
| 269 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 269 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
| 270 | 270 | $Marine->db = null; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 273 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 274 | 274 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 275 | 275 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 276 | 276 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 277 | 277 | $timeelapsed = microtime(true); |
| 278 | 278 | $Marine = new Marine($this->db); |
| 279 | 279 | $fromsource = NULL; |
| 280 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 280 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 281 | 281 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 282 | 282 | $Marine->db = null; |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 287 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 290 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 291 | 291 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 293 | 293 | } else { |
| 294 | 294 | 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"; |
| 295 | 295 | 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"; |
| 296 | 296 | return ''; |
| 297 | 297 | } |
| 298 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
| 298 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
| 299 | 299 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 300 | 300 | return ''; |
| 301 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
| 301 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
| 302 | 302 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 303 | 303 | return ''; |
| 304 | 304 | } elseif (!isset($line['datetime'])) { |
| 305 | 305 | date_default_timezone_set('UTC'); |
| 306 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 306 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 307 | 307 | } else { |
| 308 | 308 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
| 309 | 309 | return ''; |
@@ -311,20 +311,20 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | if (isset($line['speed'])) { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2))); |
|
| 315 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 316 | 316 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 317 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 317 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 318 | 318 | if ($distance > 1000 && $distance < 10000) { |
| 319 | 319 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 320 | $speed = $speed*3.6; |
| 321 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 321 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2))); |
|
| 322 | 322 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 327 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 328 | 328 | else unset($timediff); |
| 329 | 329 | if ($this->tmd > 5 || |
| 330 | 330 | !isset($timediff) || |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | $timediff > 30 && |
| 334 | 334 | isset($this->all_tracked[$id]['latitude']) && |
| 335 | 335 | isset($this->all_tracked[$id]['longitude']) && |
| 336 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 336 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
| 337 | 337 | ) |
| 338 | 338 | ) { |
| 339 | 339 | 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'])) { |
| 340 | - 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'])) { |
|
| 340 | + 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'])) { |
|
| 341 | 341 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 342 | 342 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 343 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | $timeelapsed = microtime(true); |
| 347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | 348 | $Marine = new Marine($this->db); |
| 349 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 349 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 350 | 350 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 351 | 351 | $Marine->db = null; |
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 352 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 353 | 353 | } |
| 354 | 354 | $this->tmd = 0; |
| 355 | 355 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -358,55 +358,55 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | 360 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 361 | - 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') { |
|
| 361 | + 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') { |
|
| 362 | 362 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 363 | 363 | $dataFound = true; |
| 364 | 364 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 365 | 365 | } |
| 366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 367 | 367 | } |
| 368 | 368 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | 369 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 370 | 370 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 371 | - 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') { |
|
| 371 | + 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') { |
|
| 372 | 372 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 373 | 373 | $dataFound = true; |
| 374 | 374 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 375 | 375 | } |
| 376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } else if ($globalDebug && $timediff > 20) { |
| 380 | 380 | $this->tmd = $this->tmd + 1; |
| 381 | 381 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 382 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 383 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 382 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 383 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 384 | 384 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | 388 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 389 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 389 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 390 | 390 | } |
| 391 | 391 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 392 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 392 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 393 | 393 | } |
| 394 | 394 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 395 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 395 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 396 | 396 | } |
| 397 | 397 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 398 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 398 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 402 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 404 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 405 | 405 | //$dataFound = true; |
| 406 | 406 | } 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']) { |
| 407 | - $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']); |
|
| 408 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 407 | + $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']); |
|
| 408 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 409 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | 410 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 411 | 411 | } |
| 412 | 412 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 417 | 417 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 418 | 418 | if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
| 419 | - 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'])) { |
|
| 419 | + 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'])) { |
|
| 420 | 420 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | 422 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -425,28 +425,28 @@ discard block |
||
| 425 | 425 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
| 426 | 426 | $Marine = new Marine($this->db); |
| 427 | 427 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 429 | - $Marine->db=null; |
|
| 428 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 429 | + $Marine->db = null; |
|
| 430 | 430 | } elseif (isset($line['id'])) { |
| 431 | 431 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 432 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 433 | 433 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 434 | 434 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 435 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 436 | 436 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 437 | 437 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 438 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 439 | 439 | } else $recent_ident = ''; |
| 440 | - $MarineLive->db=null; |
|
| 440 | + $MarineLive->db = null; |
|
| 441 | 441 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 442 | 442 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 443 | 443 | } else $recent_ident = ''; |
| 444 | 444 | } else { |
| 445 | 445 | $recent_ident = ''; |
| 446 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 446 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 447 | 447 | } |
| 448 | 448 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
| 449 | - if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 449 | + if ($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | 450 | { |
| 451 | 451 | if ($globalDebug) { |
| 452 | 452 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
@@ -454,19 +454,19 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | //adds the spotter data for the archive |
| 456 | 456 | $highlight = ''; |
| 457 | - 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'))); |
|
| 457 | + 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'))); |
|
| 458 | 458 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 459 | 459 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | 460 | $timeelapsed = microtime(true); |
| 461 | 461 | $Marine = new Marine($this->db); |
| 462 | 462 | if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') { |
| 463 | - $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]['race_begin'], $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
| 463 | + $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]['race_begin'], $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'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
| 464 | 464 | } else { |
| 465 | - $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
| 465 | + $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'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
| 466 | 466 | } |
| 467 | 467 | $Marine->db = null; |
| 468 | 468 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 469 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | $Stats = new Stats($this->db); |
| 475 | 475 | if (!empty($this->stats)) { |
| 476 | 476 | if ($globalDebug) echo 'Add source stats : '; |
| 477 | - foreach($this->stats as $date => $data) { |
|
| 478 | - foreach($data as $source => $sourced) { |
|
| 477 | + foreach ($this->stats as $date => $data) { |
|
| 478 | + foreach ($data as $source => $sourced) { |
|
| 479 | 479 | //print_r($sourced); |
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 480 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
| 481 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
| 482 | 482 | if (isset($sourced['msg'])) { |
| 483 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
| 484 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 485 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 485 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
| 486 | 486 | unset($this->stats[$date][$source]['msg']); |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 507 | 507 | $MarineLive = new MarineLive($this->db); |
| 508 | 508 | $MarineLive->deleteLiveMarineData(); |
| 509 | - $MarineLive->db=null; |
|
| 509 | + $MarineLive->db = null; |
|
| 510 | 510 | if ($globalDebug) echo " Done\n"; |
| 511 | 511 | } |
| 512 | 512 | $this->last_delete = time(); |
@@ -519,13 +519,13 @@ discard block |
||
| 519 | 519 | $Marine = new Marine($this->db); |
| 520 | 520 | if (isset($globalVM) && $globalVM) { |
| 521 | 521 | if ($this->all_tracked[$id]['status'] == 'Racing') { |
| 522 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
| 522 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']); |
|
| 523 | 523 | } else { |
| 524 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
|
| 525 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
| 524 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$id]['race_begin']) + $this->all_tracked[$id]['race_time']); |
|
| 525 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']); |
|
| 526 | 526 | } |
| 527 | 527 | } else { |
| 528 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
|
| 528 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']); |
|
| 529 | 529 | } |
| 530 | 530 | $Marine->db = null; |
| 531 | 531 | } |
@@ -541,20 +541,20 @@ discard block |
||
| 541 | 541 | $ignoreImport = false; |
| 542 | 542 | if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
| 543 | 543 | if (!$ignoreImport) { |
| 544 | - 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'])) { |
|
| 544 | + 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'])) { |
|
| 545 | 545 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 546 | 546 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | 547 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 548 | 548 | $timeelapsed = microtime(true); |
| 549 | 549 | $MarineLive = new MarineLive($this->db); |
| 550 | - $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'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
| 550 | + $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'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
| 551 | 551 | $MarineLive->db = null; |
| 552 | 552 | if ($globalDebug) echo $result."\n"; |
| 553 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 553 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 557 | - $APRSMarine->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']); |
|
| 557 | + $APRSMarine->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']); |
|
| 558 | 558 | } |
| 559 | 559 | $this->all_tracked[$id]['putinarchive'] = false; |
| 560 | 560 | |
@@ -573,19 +573,19 @@ discard block |
||
| 573 | 573 | $latitude = $globalCenterLatitude; |
| 574 | 574 | $longitude = $globalCenterLongitude; |
| 575 | 575 | } |
| 576 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 576 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 577 | 577 | } else { |
| 578 | 578 | $latitude = $this->source_location[$source]['latitude']; |
| 579 | 579 | $longitude = $this->source_location[$source]['longitude']; |
| 580 | 580 | } |
| 581 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 581 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 582 | 582 | //$stats_heading = $stats_heading%22.5; |
| 583 | 583 | $stats_heading = round($stats_heading/22.5); |
| 584 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 584 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 585 | 585 | $current_date = date('Y-m-d'); |
| 586 | 586 | if ($stats_heading == 16) $stats_heading = 0; |
| 587 | 587 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | - for ($i=0;$i<=15;$i++) { |
|
| 588 | + for ($i = 0; $i <= 15; $i++) { |
|
| 589 | 589 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 590 | 590 | } |
| 591 | 591 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 601 | 601 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | 602 | end($this->stats[$current_date][$source]['hist']); |
| 603 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 603 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 604 | 604 | } else $mini = 0; |
| 605 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 605 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 606 | 606 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 607 | 607 | } |
| 608 | 608 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | |
| 615 | 615 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 616 | 616 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 617 | - } 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"; |
|
| 617 | + } 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"; |
|
| 618 | 618 | //$this->del(); |
| 619 | 619 | |
| 620 | 620 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 82 | 82 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 83 | 83 | if ($filter_query_where != '') { |
| 84 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 84 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 85 | 85 | } |
| 86 | 86 | $filter_query = $filter_query_join.$filter_query_where; |
| 87 | 87 | return $filter_query; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return Array the spotter information |
| 97 | 97 | * |
| 98 | 98 | */ |
| 99 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 99 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 100 | 100 | { |
| 101 | 101 | date_default_timezone_set('UTC'); |
| 102 | 102 | if (!is_string($query)) |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | $sth = $this->db->prepare($query.$limitQuery); |
| 117 | 117 | $sth->execute($params); |
| 118 | 118 | } catch (PDOException $e) { |
| 119 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 119 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 120 | 120 | exit(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $num_rows = 0; |
| 124 | 124 | $spotter_array = array(); |
| 125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 126 | 126 | { |
| 127 | 127 | $num_rows++; |
| 128 | 128 | $temp_array = array(); |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 166 | 166 | |
| 167 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 167 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 168 | 168 | { |
| 169 | 169 | $Image = new Image($this->db); |
| 170 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 170 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 171 | 171 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 172 | 172 | unset($Image); |
| 173 | 173 | if (count($image_array) > 0) { |
@@ -203,17 +203,17 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 205 | 205 | } else { |
| 206 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 206 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 207 | 207 | } |
| 208 | 208 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 209 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 210 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 209 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 210 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 211 | 211 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 212 | 212 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 213 | 213 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 214 | 214 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 215 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 216 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 215 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 216 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 217 | 217 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | if ($limit != "") |
| 247 | 247 | { |
| 248 | 248 | $limit_array = explode(",", $limit); |
| 249 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 250 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 249 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 250 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 251 | 251 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 252 | 252 | { |
| 253 | 253 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | } else { |
| 262 | 262 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 263 | 263 | } |
| 264 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 265 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 264 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 265 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 266 | 266 | return $spotter_array; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | if ($id == '') return array(); |
| 281 | 281 | $additional_query = "marine_output.fammarine_id = :id"; |
| 282 | 282 | $query_values = array(':id' => $id); |
| 283 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 284 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 283 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 284 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 285 | 285 | return $spotter_array; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $query_values = array(); |
| 301 | 301 | $limit_query = ''; |
| 302 | 302 | $additional_query = ''; |
| 303 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 303 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 304 | 304 | if ($ident != "") |
| 305 | 305 | { |
| 306 | 306 | if (!is_string($ident)) |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | { |
| 317 | 317 | $limit_array = explode(",", $limit); |
| 318 | 318 | |
| 319 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 320 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 319 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 320 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 321 | 321 | |
| 322 | 322 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 323 | 323 | { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $query_values = array(); |
| 357 | 357 | $limit_query = ''; |
| 358 | 358 | $additional_query = ''; |
| 359 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 359 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 360 | 360 | if (!is_string($type)) |
| 361 | 361 | { |
| 362 | 362 | return false; |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $limit_array = explode(",", $limit); |
| 371 | 371 | |
| 372 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 372 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 374 | 374 | |
| 375 | 375 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 376 | 376 | { |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | return $spotter_array; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 397 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 398 | 398 | { |
| 399 | 399 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
| 400 | 400 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $limit_query = ''; |
| 403 | 403 | $additional_query = ''; |
| 404 | 404 | |
| 405 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 405 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 406 | 406 | |
| 407 | 407 | if ($date != "") |
| 408 | 408 | { |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | { |
| 429 | 429 | $limit_array = explode(",", $limit); |
| 430 | 430 | |
| 431 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 432 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 431 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 432 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 433 | 433 | |
| 434 | 434 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 435 | 435 | { |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | $query_values = array(); |
| 465 | 465 | $limit_query = ''; |
| 466 | 466 | $additional_query = ''; |
| 467 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 468 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 467 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 468 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 469 | 469 | if ($captain != "") |
| 470 | 470 | { |
| 471 | 471 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | if ($limit != "") |
| 475 | 475 | { |
| 476 | 476 | $limit_array = explode(",", $limit); |
| 477 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 478 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 477 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 478 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 479 | 479 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 480 | 480 | { |
| 481 | 481 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | $query_values = array(); |
| 508 | 508 | $limit_query = ''; |
| 509 | 509 | $additional_query = ''; |
| 510 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 511 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 510 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 511 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 512 | 512 | if ($race != "") |
| 513 | 513 | { |
| 514 | 514 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | if ($limit != "") |
| 518 | 518 | { |
| 519 | 519 | $limit_array = explode(",", $limit); |
| 520 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 521 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 520 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 521 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 522 | 522 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 523 | 523 | { |
| 524 | 524 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -543,14 +543,14 @@ discard block |
||
| 543 | 543 | * @return String Duration of all races |
| 544 | 544 | * |
| 545 | 545 | */ |
| 546 | - public function countRacesByCaptain($captain,$filters = array()) |
|
| 546 | + public function countRacesByCaptain($captain, $filters = array()) |
|
| 547 | 547 | { |
| 548 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 549 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 550 | - $query = "SELECT COUNT(*) AS nb |
|
| 548 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 549 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 550 | + $query = "SELECT COUNT(*) AS nb |
|
| 551 | 551 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
| 552 | 552 | $query_values = array(); |
| 553 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 553 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 554 | 554 | $sth = $this->db->prepare($query); |
| 555 | 555 | $sth->execute($query_values); |
| 556 | 556 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -563,14 +563,14 @@ discard block |
||
| 563 | 563 | * @return String Duration of all races |
| 564 | 564 | * |
| 565 | 565 | */ |
| 566 | - public function countCaptainsByRace($race,$filters = array()) |
|
| 566 | + public function countCaptainsByRace($race, $filters = array()) |
|
| 567 | 567 | { |
| 568 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 569 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 570 | - $query = "SELECT COUNT(*) AS nb |
|
| 568 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 569 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 570 | + $query = "SELECT COUNT(*) AS nb |
|
| 571 | 571 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
| 572 | 572 | $query_values = array(); |
| 573 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 573 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute($query_values); |
| 576 | 576 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -583,44 +583,44 @@ discard block |
||
| 583 | 583 | * @return Array the boat list |
| 584 | 584 | * |
| 585 | 585 | */ |
| 586 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 586 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 587 | 587 | { |
| 588 | 588 | global $globalDBdriver; |
| 589 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 590 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 591 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 589 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 590 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 591 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 592 | 592 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
| 593 | 593 | $query_values = array(); |
| 594 | 594 | if ($year != '') { |
| 595 | 595 | if ($globalDBdriver == 'mysql') { |
| 596 | 596 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 597 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 597 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 598 | 598 | } else { |
| 599 | 599 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 600 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 600 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | if ($month != '') { |
| 604 | 604 | if ($globalDBdriver == 'mysql') { |
| 605 | 605 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 606 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 606 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 607 | 607 | } else { |
| 608 | 608 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 609 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 609 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | if ($day != '') { |
| 613 | 613 | if ($globalDBdriver == 'mysql') { |
| 614 | 614 | $query .= " AND DAY(marine_output.date) = :day"; |
| 615 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 615 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 616 | 616 | } else { |
| 617 | 617 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 618 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 618 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | $query .= " GROUP BY marine_output.type |
| 622 | 622 | ORDER BY type_count DESC"; |
| 623 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 623 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 624 | 624 | $sth = $this->db->prepare($query); |
| 625 | 625 | $sth->execute($query_values); |
| 626 | 626 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -632,44 +632,44 @@ discard block |
||
| 632 | 632 | * @return Array the boat list |
| 633 | 633 | * |
| 634 | 634 | */ |
| 635 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
| 635 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
| 636 | 636 | { |
| 637 | 637 | global $globalDBdriver; |
| 638 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 639 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 640 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 638 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 639 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 640 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 641 | 641 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
| 642 | 642 | $query_values = array(); |
| 643 | 643 | if ($year != '') { |
| 644 | 644 | if ($globalDBdriver == 'mysql') { |
| 645 | 645 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 646 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 646 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 647 | 647 | } else { |
| 648 | 648 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 649 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 649 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | if ($month != '') { |
| 653 | 653 | if ($globalDBdriver == 'mysql') { |
| 654 | 654 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 655 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 655 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 656 | 656 | } else { |
| 657 | 657 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 658 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 658 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | if ($day != '') { |
| 662 | 662 | if ($globalDBdriver == 'mysql') { |
| 663 | 663 | $query .= " AND DAY(marine_output.date) = :day"; |
| 664 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 664 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 665 | 665 | } else { |
| 666 | 666 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 667 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 667 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | $query .= " GROUP BY marine_output.type |
| 671 | 671 | ORDER BY type_count DESC"; |
| 672 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 672 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 673 | 673 | $sth = $this->db->prepare($query); |
| 674 | 674 | $sth->execute($query_values); |
| 675 | 675 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -681,47 +681,47 @@ discard block |
||
| 681 | 681 | * @return String Duration of all race |
| 682 | 682 | * |
| 683 | 683 | */ |
| 684 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 684 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 685 | 685 | { |
| 686 | 686 | global $globalDBdriver; |
| 687 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 688 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 689 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 687 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 688 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 689 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 690 | 690 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
| 691 | 691 | AND last_seen > date"; |
| 692 | 692 | $query_values = array(); |
| 693 | 693 | if ($year != '') { |
| 694 | 694 | if ($globalDBdriver == 'mysql') { |
| 695 | 695 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 696 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 696 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 697 | 697 | } else { |
| 698 | 698 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 699 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 699 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | if ($month != '') { |
| 703 | 703 | if ($globalDBdriver == 'mysql') { |
| 704 | 704 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 705 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 705 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 706 | 706 | } else { |
| 707 | 707 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 708 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 708 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | if ($day != '') { |
| 712 | 712 | if ($globalDBdriver == 'mysql') { |
| 713 | 713 | $query .= " AND DAY(marine_output.date) = :day"; |
| 714 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 714 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 715 | 715 | } else { |
| 716 | 716 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 717 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 717 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 720 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute($query_values); |
| 723 | 723 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 724 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 724 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 725 | 725 | else return $result[0]['duration']; |
| 726 | 726 | } |
| 727 | 727 | |
@@ -733,8 +733,8 @@ discard block |
||
| 733 | 733 | */ |
| 734 | 734 | public function getAllCaptainNames($filters = array()) |
| 735 | 735 | { |
| 736 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 737 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 736 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 737 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 738 | 738 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
| 739 | 739 | ORDER BY marine_output.captain_name ASC"; |
| 740 | 740 | |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | */ |
| 752 | 752 | public function getAllRaceNames($filters = array()) |
| 753 | 753 | { |
| 754 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 755 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 754 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 755 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 756 | 756 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
| 757 | 757 | ORDER BY marine_output.race_name ASC"; |
| 758 | 758 | |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | * @return Array list of source name |
| 769 | 769 | * |
| 770 | 770 | */ |
| 771 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 771 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 772 | 772 | { |
| 773 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 773 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 774 | 774 | $query_values = array(); |
| 775 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 775 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 776 | 776 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 777 | 777 | if ($type != '') { |
| 778 | 778 | $query_values = array(':type' => $type); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $source_array = array(); |
| 788 | 788 | $temp_array = array(); |
| 789 | 789 | |
| 790 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 790 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 791 | 791 | { |
| 792 | 792 | $temp_array['source_name'] = $row['source_name']; |
| 793 | 793 | $source_array[] = $temp_array; |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | */ |
| 805 | 805 | public function getAllIdents($filters = array()) |
| 806 | 806 | { |
| 807 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 808 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 807 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 808 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 809 | 809 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 810 | 810 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 811 | 811 | |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $ident_array = array(); |
| 816 | 816 | $temp_array = array(); |
| 817 | 817 | |
| 818 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 818 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 819 | 819 | { |
| 820 | 820 | $temp_array['ident'] = $row['ident']; |
| 821 | 821 | $ident_array[] = $temp_array; |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | public function getIdentity($mmsi) |
| 834 | 834 | { |
| 835 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 835 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | 836 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 837 | 837 | $sth = $this->db->prepare($query); |
| 838 | 838 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -845,23 +845,23 @@ discard block |
||
| 845 | 845 | * Add identity |
| 846 | 846 | * |
| 847 | 847 | */ |
| 848 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
| 848 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
| 849 | 849 | { |
| 850 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 850 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 851 | 851 | if ($mmsi != '') { |
| 852 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 853 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 854 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 855 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 852 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 853 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 854 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 855 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 856 | 856 | $identinfo = $this->getIdentity($mmsi); |
| 857 | 857 | if (empty($identinfo)) { |
| 858 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 858 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 859 | 859 | $sth = $this->db->prepare($query); |
| 860 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 860 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 861 | 861 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 862 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 862 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 863 | 863 | $sth = $this->db->prepare($query); |
| 864 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 864 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | } |
@@ -882,12 +882,12 @@ discard block |
||
| 882 | 882 | } else $offset = '+00:00'; |
| 883 | 883 | |
| 884 | 884 | if ($globalDBdriver == 'mysql') { |
| 885 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 885 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 886 | 886 | FROM marine_output |
| 887 | 887 | WHERE marine_output.date <> '' |
| 888 | 888 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 889 | 889 | } else { |
| 890 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 890 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 891 | 891 | FROM marine_output |
| 892 | 892 | WHERE marine_output.date <> '' |
| 893 | 893 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | $date_array = array(); |
| 900 | 900 | $temp_array = array(); |
| 901 | 901 | |
| 902 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 902 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 903 | 903 | { |
| 904 | 904 | $temp_array['date'] = $row['date']; |
| 905 | 905 | |
@@ -917,10 +917,10 @@ discard block |
||
| 917 | 917 | * @return String success or false |
| 918 | 918 | * |
| 919 | 919 | */ |
| 920 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 920 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 921 | 921 | { |
| 922 | 922 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 923 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 923 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 924 | 924 | try { |
| 925 | 925 | $sth = $this->db->prepare($query); |
| 926 | 926 | $sth->execute($query_values); |
@@ -938,10 +938,10 @@ discard block |
||
| 938 | 938 | * @return String success or false |
| 939 | 939 | * |
| 940 | 940 | */ |
| 941 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 941 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 942 | 942 | { |
| 943 | 943 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 944 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 944 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 945 | 945 | try { |
| 946 | 946 | $sth = $this->db->prepare($query); |
| 947 | 947 | $sth->execute($query_values); |
@@ -960,11 +960,11 @@ discard block |
||
| 960 | 960 | * @return String success or false |
| 961 | 961 | * |
| 962 | 962 | */ |
| 963 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 963 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 964 | 964 | { |
| 965 | 965 | |
| 966 | 966 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 967 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 967 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 968 | 968 | |
| 969 | 969 | try { |
| 970 | 970 | $sth = $this->db->prepare($query); |
@@ -984,17 +984,17 @@ discard block |
||
| 984 | 984 | * @return String success or false |
| 985 | 985 | * |
| 986 | 986 | */ |
| 987 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 987 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '') |
|
| 988 | 988 | { |
| 989 | 989 | if ($latitude == '') $latitude = NULL; |
| 990 | 990 | if ($longitude == '') $longitude = NULL; |
| 991 | 991 | $groundspeed = round($groundspeed); |
| 992 | 992 | if ($race_begin != '') { |
| 993 | 993 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id'; |
| 994 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin); |
|
| 994 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin); |
|
| 995 | 995 | } else { |
| 996 | 996 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id'; |
| 997 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status); |
|
| 997 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status); |
|
| 998 | 998 | } |
| 999 | 999 | try { |
| 1000 | 1000 | $sth = $this->db->prepare($query); |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | * @param String $verticalrate vertival rate of flight |
| 1034 | 1034 | * @return String success or false |
| 1035 | 1035 | */ |
| 1036 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
|
| 1036 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
| 1037 | 1037 | { |
| 1038 | 1038 | global $globalURL, $globalMarineImageFetch; |
| 1039 | 1039 | |
@@ -1105,34 +1105,34 @@ discard block |
||
| 1105 | 1105 | $date = date("Y-m-d H:i:s", time()); |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1109 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1110 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1111 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1112 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1113 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1114 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1115 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1116 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 1117 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 1118 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1121 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1122 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 1123 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 1124 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 1125 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 1126 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 1127 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 1128 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
| 1129 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1130 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1108 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1109 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1110 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1111 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1112 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1113 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1114 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1115 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1116 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 1117 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 1118 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1121 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1122 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 1123 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 1124 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 1125 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 1126 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 1127 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 1128 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
| 1129 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1130 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1131 | 1131 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 1132 | 1132 | $Image = new Image($this->db); |
| 1133 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 1133 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 1134 | 1134 | if (!isset($image_array[0]['mmsi'])) { |
| 1135 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 1135 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 1136 | 1136 | } |
| 1137 | 1137 | unset($Image); |
| 1138 | 1138 | } |
@@ -1148,10 +1148,10 @@ discard block |
||
| 1148 | 1148 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 1149 | 1149 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1150 | 1150 | if ($arrival_date == '') $arrival_date = NULL; |
| 1151 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1151 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1152 | 1152 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1153 | 1153 | |
| 1154 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 1154 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 1155 | 1155 | try { |
| 1156 | 1156 | $sth = $this->db->prepare($query); |
| 1157 | 1157 | $sth->execute($query_values); |
@@ -1175,13 +1175,13 @@ discard block |
||
| 1175 | 1175 | { |
| 1176 | 1176 | global $globalDBdriver, $globalTimezone; |
| 1177 | 1177 | if ($globalDBdriver == 'mysql') { |
| 1178 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1178 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1179 | 1179 | WHERE marine_output.ident = :ident |
| 1180 | 1180 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 1181 | 1181 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1182 | 1182 | $query_data = array(':ident' => $ident); |
| 1183 | 1183 | } else { |
| 1184 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1184 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1185 | 1185 | WHERE marine_output.ident = :ident |
| 1186 | 1186 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1187 | 1187 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | $sth = $this->db->prepare($query); |
| 1192 | 1192 | $sth->execute($query_data); |
| 1193 | - $ident_result=''; |
|
| 1194 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1193 | + $ident_result = ''; |
|
| 1194 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1195 | 1195 | { |
| 1196 | 1196 | $ident_result = $row['ident']; |
| 1197 | 1197 | } |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | return false; |
| 1218 | 1218 | } else { |
| 1219 | 1219 | $q_array = explode(" ", $q); |
| 1220 | - foreach ($q_array as $q_item){ |
|
| 1221 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1220 | + foreach ($q_array as $q_item) { |
|
| 1221 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1222 | 1222 | $additional_query .= " AND ("; |
| 1223 | 1223 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 1224 | 1224 | $additional_query .= ")"; |
@@ -1226,11 +1226,11 @@ discard block |
||
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | if ($globalDBdriver == 'mysql') { |
| 1229 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1229 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1230 | 1230 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1231 | 1231 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1232 | 1232 | } else { |
| 1233 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1233 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1234 | 1234 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1235 | 1235 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1236 | 1236 | } |
@@ -1249,16 +1249,16 @@ discard block |
||
| 1249 | 1249 | * |
| 1250 | 1250 | */ |
| 1251 | 1251 | |
| 1252 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1252 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1253 | 1253 | { |
| 1254 | 1254 | global $globalDBdriver, $globalArchive; |
| 1255 | 1255 | //$filter_query = $this->getFilter($filters,true,true); |
| 1256 | - $Connection= new Connection($this->db); |
|
| 1256 | + $Connection = new Connection($this->db); |
|
| 1257 | 1257 | if (!$Connection->tableExists('countries')) return array(); |
| 1258 | 1258 | require_once('class.SpotterLive.php'); |
| 1259 | 1259 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1260 | 1260 | $MarineLive = new MarineLive($this->db); |
| 1261 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 1261 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 1262 | 1262 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 1263 | 1263 | if ($olderthanmonths > 0) { |
| 1264 | 1264 | if ($globalDBdriver == 'mysql') { |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | } else { |
| 1279 | 1279 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 1280 | 1280 | $MarineArchive = new MarineArchive($this->db); |
| 1281 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 1281 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 1282 | 1282 | $filter_query .= " over_country <> ''"; |
| 1283 | 1283 | if ($olderthanmonths > 0) { |
| 1284 | 1284 | if ($globalDBdriver == 'mysql') { |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | $flight_array = array(); |
| 1307 | 1307 | $temp_array = array(); |
| 1308 | 1308 | |
| 1309 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1309 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1310 | 1310 | { |
| 1311 | 1311 | $temp_array['marine_count'] = $row['nb']; |
| 1312 | 1312 | $temp_array['marine_country'] = $row['name']; |
@@ -1325,11 +1325,11 @@ discard block |
||
| 1325 | 1325 | * @return Array the callsign list |
| 1326 | 1326 | * |
| 1327 | 1327 | */ |
| 1328 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 1328 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1329 | 1329 | { |
| 1330 | 1330 | global $globalDBdriver; |
| 1331 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1332 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1331 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1332 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1333 | 1333 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1334 | 1334 | if ($olderthanmonths > 0) { |
| 1335 | 1335 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1343,28 +1343,28 @@ discard block |
||
| 1343 | 1343 | if ($year != '') { |
| 1344 | 1344 | if ($globalDBdriver == 'mysql') { |
| 1345 | 1345 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1346 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1346 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1347 | 1347 | } else { |
| 1348 | 1348 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1349 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1349 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1350 | 1350 | } |
| 1351 | 1351 | } |
| 1352 | 1352 | if ($month != '') { |
| 1353 | 1353 | if ($globalDBdriver == 'mysql') { |
| 1354 | 1354 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1355 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1355 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1356 | 1356 | } else { |
| 1357 | 1357 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1358 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1358 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1359 | 1359 | } |
| 1360 | 1360 | } |
| 1361 | 1361 | if ($day != '') { |
| 1362 | 1362 | if ($globalDBdriver == 'mysql') { |
| 1363 | 1363 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1364 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1364 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1365 | 1365 | } else { |
| 1366 | 1366 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1367 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1367 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | } |
| 1370 | 1370 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | $callsign_array = array(); |
| 1377 | 1377 | $temp_array = array(); |
| 1378 | 1378 | |
| 1379 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1379 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1380 | 1380 | { |
| 1381 | 1381 | $temp_array['callsign_icao'] = $row['ident']; |
| 1382 | 1382 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | $date_array = array(); |
| 1429 | 1429 | $temp_array = array(); |
| 1430 | 1430 | |
| 1431 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1431 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1432 | 1432 | { |
| 1433 | 1433 | $temp_array['date_name'] = $row['date_name']; |
| 1434 | 1434 | $temp_array['date_count'] = $row['date_count']; |
@@ -1454,7 +1454,7 @@ discard block |
||
| 1454 | 1454 | $datetime = new DateTime(); |
| 1455 | 1455 | $offset = $datetime->format('P'); |
| 1456 | 1456 | } else $offset = '+00:00'; |
| 1457 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1457 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1458 | 1458 | if ($globalDBdriver == 'mysql') { |
| 1459 | 1459 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1460 | 1460 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1475,7 +1475,7 @@ discard block |
||
| 1475 | 1475 | $date_array = array(); |
| 1476 | 1476 | $temp_array = array(); |
| 1477 | 1477 | |
| 1478 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1478 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1479 | 1479 | { |
| 1480 | 1480 | $temp_array['date_name'] = $row['date_name']; |
| 1481 | 1481 | $temp_array['date_count'] = $row['date_count']; |
@@ -1500,7 +1500,7 @@ discard block |
||
| 1500 | 1500 | $datetime = new DateTime(); |
| 1501 | 1501 | $offset = $datetime->format('P'); |
| 1502 | 1502 | } else $offset = '+00:00'; |
| 1503 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1503 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1504 | 1504 | if ($globalDBdriver == 'mysql') { |
| 1505 | 1505 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1506 | 1506 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1521,7 +1521,7 @@ discard block |
||
| 1521 | 1521 | $date_array = array(); |
| 1522 | 1522 | $temp_array = array(); |
| 1523 | 1523 | |
| 1524 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1524 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1525 | 1525 | { |
| 1526 | 1526 | $temp_array['date_name'] = $row['date_name']; |
| 1527 | 1527 | $temp_array['date_count'] = $row['date_count']; |
@@ -1568,7 +1568,7 @@ discard block |
||
| 1568 | 1568 | $date_array = array(); |
| 1569 | 1569 | $temp_array = array(); |
| 1570 | 1570 | |
| 1571 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1571 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1572 | 1572 | { |
| 1573 | 1573 | $temp_array['month_name'] = $row['month_name']; |
| 1574 | 1574 | $temp_array['year_name'] = $row['year_name']; |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | $datetime = new DateTime(); |
| 1598 | 1598 | $offset = $datetime->format('P'); |
| 1599 | 1599 | } else $offset = '+00:00'; |
| 1600 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1600 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1601 | 1601 | if ($globalDBdriver == 'mysql') { |
| 1602 | 1602 | $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 |
| 1603 | 1603 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1618,7 +1618,7 @@ discard block |
||
| 1618 | 1618 | $date_array = array(); |
| 1619 | 1619 | $temp_array = array(); |
| 1620 | 1620 | |
| 1621 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1621 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1622 | 1622 | { |
| 1623 | 1623 | $temp_array['year_name'] = $row['year_name']; |
| 1624 | 1624 | $temp_array['month_name'] = $row['month_name']; |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | * @return Array the hour list |
| 1639 | 1639 | * |
| 1640 | 1640 | */ |
| 1641 | - public function countAllHours($orderby,$filters = array()) |
|
| 1641 | + public function countAllHours($orderby, $filters = array()) |
|
| 1642 | 1642 | { |
| 1643 | 1643 | global $globalTimezone, $globalDBdriver; |
| 1644 | 1644 | if ($globalTimezone != '') { |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | $hour_array = array(); |
| 1687 | 1687 | $temp_array = array(); |
| 1688 | 1688 | |
| 1689 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1689 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1690 | 1690 | { |
| 1691 | 1691 | $temp_array['hour_name'] = $row['hour_name']; |
| 1692 | 1692 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1708,8 +1708,8 @@ discard block |
||
| 1708 | 1708 | public function countAllHoursByDate($date, $filters = array()) |
| 1709 | 1709 | { |
| 1710 | 1710 | global $globalTimezone, $globalDBdriver; |
| 1711 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1712 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1711 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1712 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1713 | 1713 | if ($globalTimezone != '') { |
| 1714 | 1714 | date_default_timezone_set($globalTimezone); |
| 1715 | 1715 | $datetime = new DateTime($date); |
@@ -1717,12 +1717,12 @@ discard block |
||
| 1717 | 1717 | } else $offset = '+00:00'; |
| 1718 | 1718 | |
| 1719 | 1719 | if ($globalDBdriver == 'mysql') { |
| 1720 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1720 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1721 | 1721 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1722 | 1722 | GROUP BY hour_name |
| 1723 | 1723 | ORDER BY hour_name ASC"; |
| 1724 | 1724 | } else { |
| 1725 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1725 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1726 | 1726 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1727 | 1727 | GROUP BY hour_name |
| 1728 | 1728 | ORDER BY hour_name ASC"; |
@@ -1734,7 +1734,7 @@ discard block |
||
| 1734 | 1734 | $hour_array = array(); |
| 1735 | 1735 | $temp_array = array(); |
| 1736 | 1736 | |
| 1737 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1737 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1738 | 1738 | { |
| 1739 | 1739 | $temp_array['hour_name'] = $row['hour_name']; |
| 1740 | 1740 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1756,8 +1756,8 @@ discard block |
||
| 1756 | 1756 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1757 | 1757 | { |
| 1758 | 1758 | global $globalTimezone, $globalDBdriver; |
| 1759 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1760 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1759 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1760 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1761 | 1761 | if ($globalTimezone != '') { |
| 1762 | 1762 | date_default_timezone_set($globalTimezone); |
| 1763 | 1763 | $datetime = new DateTime(); |
@@ -1765,12 +1765,12 @@ discard block |
||
| 1765 | 1765 | } else $offset = '+00:00'; |
| 1766 | 1766 | |
| 1767 | 1767 | if ($globalDBdriver == 'mysql') { |
| 1768 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1768 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1769 | 1769 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1770 | 1770 | GROUP BY hour_name |
| 1771 | 1771 | ORDER BY hour_name ASC"; |
| 1772 | 1772 | } else { |
| 1773 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1773 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1774 | 1774 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1775 | 1775 | GROUP BY hour_name |
| 1776 | 1776 | ORDER BY hour_name ASC"; |
@@ -1778,12 +1778,12 @@ discard block |
||
| 1778 | 1778 | |
| 1779 | 1779 | |
| 1780 | 1780 | $sth = $this->db->prepare($query); |
| 1781 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1781 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1782 | 1782 | |
| 1783 | 1783 | $hour_array = array(); |
| 1784 | 1784 | $temp_array = array(); |
| 1785 | 1785 | |
| 1786 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1786 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1787 | 1787 | { |
| 1788 | 1788 | $temp_array['hour_name'] = $row['hour_name']; |
| 1789 | 1789 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1802,33 +1802,33 @@ discard block |
||
| 1802 | 1802 | * @return Integer the number of vessels |
| 1803 | 1803 | * |
| 1804 | 1804 | */ |
| 1805 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1805 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1806 | 1806 | { |
| 1807 | 1807 | global $globalDBdriver; |
| 1808 | 1808 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1809 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1809 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1810 | 1810 | $query_values = array(); |
| 1811 | 1811 | $query = ''; |
| 1812 | 1812 | if ($year != '') { |
| 1813 | 1813 | if ($globalDBdriver == 'mysql') { |
| 1814 | 1814 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1815 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1815 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1816 | 1816 | } else { |
| 1817 | 1817 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1818 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1818 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1819 | 1819 | } |
| 1820 | 1820 | } |
| 1821 | 1821 | if ($month != '') { |
| 1822 | 1822 | if ($globalDBdriver == 'mysql') { |
| 1823 | 1823 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1824 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1824 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1825 | 1825 | } else { |
| 1826 | 1826 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1827 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1827 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1831 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1831 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1832 | 1832 | |
| 1833 | 1833 | $sth = $this->db->prepare($queryi); |
| 1834 | 1834 | $sth->execute($query_values); |
@@ -1841,32 +1841,32 @@ discard block |
||
| 1841 | 1841 | * @return Integer the number of vessels |
| 1842 | 1842 | * |
| 1843 | 1843 | */ |
| 1844 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1844 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1845 | 1845 | { |
| 1846 | 1846 | global $globalDBdriver; |
| 1847 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1847 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1848 | 1848 | $query_values = array(); |
| 1849 | 1849 | $query = ''; |
| 1850 | 1850 | if ($year != '') { |
| 1851 | 1851 | if ($globalDBdriver == 'mysql') { |
| 1852 | 1852 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1853 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1853 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1854 | 1854 | } else { |
| 1855 | 1855 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1856 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1856 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1857 | 1857 | } |
| 1858 | 1858 | } |
| 1859 | 1859 | if ($month != '') { |
| 1860 | 1860 | if ($globalDBdriver == 'mysql') { |
| 1861 | 1861 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1862 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1862 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1863 | 1863 | } else { |
| 1864 | 1864 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1865 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1865 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1866 | 1866 | } |
| 1867 | 1867 | } |
| 1868 | 1868 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1869 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1869 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1870 | 1870 | |
| 1871 | 1871 | $sth = $this->db->prepare($queryi); |
| 1872 | 1872 | $sth->execute($query_values); |
@@ -1883,7 +1883,7 @@ discard block |
||
| 1883 | 1883 | public function countAllHoursFromToday($filters = array()) |
| 1884 | 1884 | { |
| 1885 | 1885 | global $globalTimezone, $globalDBdriver; |
| 1886 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1886 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1887 | 1887 | if ($globalTimezone != '') { |
| 1888 | 1888 | date_default_timezone_set($globalTimezone); |
| 1889 | 1889 | $datetime = new DateTime(); |
@@ -1891,12 +1891,12 @@ discard block |
||
| 1891 | 1891 | } else $offset = '+00:00'; |
| 1892 | 1892 | |
| 1893 | 1893 | if ($globalDBdriver == 'mysql') { |
| 1894 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1894 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1895 | 1895 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1896 | 1896 | GROUP BY hour_name |
| 1897 | 1897 | ORDER BY hour_name ASC"; |
| 1898 | 1898 | } else { |
| 1899 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1899 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1900 | 1900 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1901 | 1901 | GROUP BY hour_name |
| 1902 | 1902 | ORDER BY hour_name ASC"; |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | $hour_array = array(); |
| 1909 | 1909 | $temp_array = array(); |
| 1910 | 1910 | |
| 1911 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1911 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1912 | 1912 | { |
| 1913 | 1913 | $temp_array['hour_name'] = $row['hour_name']; |
| 1914 | 1914 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1927,9 +1927,9 @@ discard block |
||
| 1927 | 1927 | */ |
| 1928 | 1928 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1929 | 1929 | { |
| 1930 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1930 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1931 | 1931 | |
| 1932 | - $query = "SELECT marine_output.marine_id |
|
| 1932 | + $query = "SELECT marine_output.marine_id |
|
| 1933 | 1933 | FROM marine_output |
| 1934 | 1934 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1935 | 1935 | |
@@ -1937,7 +1937,7 @@ discard block |
||
| 1937 | 1937 | $sth = $this->db->prepare($query); |
| 1938 | 1938 | $sth->execute(); |
| 1939 | 1939 | |
| 1940 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1940 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1941 | 1941 | { |
| 1942 | 1942 | return $row['marine_id']; |
| 1943 | 1943 | } |
@@ -1962,23 +1962,23 @@ discard block |
||
| 1962 | 1962 | } |
| 1963 | 1963 | |
| 1964 | 1964 | $current_date = date("Y-m-d H:i:s"); |
| 1965 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1965 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1966 | 1966 | |
| 1967 | 1967 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1968 | 1968 | |
| 1969 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1969 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1970 | 1970 | $years = $time_array['years']; |
| 1971 | 1971 | |
| 1972 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1972 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1973 | 1973 | $months = $time_array['months']; |
| 1974 | 1974 | |
| 1975 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1975 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1976 | 1976 | $days = $time_array['days']; |
| 1977 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1977 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1978 | 1978 | $hours = $time_array['hours']; |
| 1979 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1979 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1980 | 1980 | $minutes = $time_array['minutes']; |
| 1981 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1981 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1982 | 1982 | |
| 1983 | 1983 | return $time_array; |
| 1984 | 1984 | } |
@@ -2001,63 +2001,63 @@ discard block |
||
| 2001 | 2001 | $temp_array['direction_degree'] = $direction; |
| 2002 | 2002 | $temp_array['direction_shortname'] = "N"; |
| 2003 | 2003 | $temp_array['direction_fullname'] = "North"; |
| 2004 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 2004 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 2005 | 2005 | $temp_array['direction_degree'] = $direction; |
| 2006 | 2006 | $temp_array['direction_shortname'] = "NNE"; |
| 2007 | 2007 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 2008 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 2008 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 2009 | 2009 | $temp_array['direction_degree'] = $direction; |
| 2010 | 2010 | $temp_array['direction_shortname'] = "NE"; |
| 2011 | 2011 | $temp_array['direction_fullname'] = "Northeast"; |
| 2012 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 2012 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 2013 | 2013 | $temp_array['direction_degree'] = $direction; |
| 2014 | 2014 | $temp_array['direction_shortname'] = "ENE"; |
| 2015 | 2015 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 2016 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 2016 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 2017 | 2017 | $temp_array['direction_degree'] = $direction; |
| 2018 | 2018 | $temp_array['direction_shortname'] = "E"; |
| 2019 | 2019 | $temp_array['direction_fullname'] = "East"; |
| 2020 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 2020 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 2021 | 2021 | $temp_array['direction_degree'] = $direction; |
| 2022 | 2022 | $temp_array['direction_shortname'] = "ESE"; |
| 2023 | 2023 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 2024 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 2024 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 2025 | 2025 | $temp_array['direction_degree'] = $direction; |
| 2026 | 2026 | $temp_array['direction_shortname'] = "SE"; |
| 2027 | 2027 | $temp_array['direction_fullname'] = "Southeast"; |
| 2028 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 2028 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 2029 | 2029 | $temp_array['direction_degree'] = $direction; |
| 2030 | 2030 | $temp_array['direction_shortname'] = "SSE"; |
| 2031 | 2031 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 2032 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 2032 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 2033 | 2033 | $temp_array['direction_degree'] = $direction; |
| 2034 | 2034 | $temp_array['direction_shortname'] = "S"; |
| 2035 | 2035 | $temp_array['direction_fullname'] = "South"; |
| 2036 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 2036 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 2037 | 2037 | $temp_array['direction_degree'] = $direction; |
| 2038 | 2038 | $temp_array['direction_shortname'] = "SSW"; |
| 2039 | 2039 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 2040 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 2040 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 2041 | 2041 | $temp_array['direction_degree'] = $direction; |
| 2042 | 2042 | $temp_array['direction_shortname'] = "SW"; |
| 2043 | 2043 | $temp_array['direction_fullname'] = "Southwest"; |
| 2044 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 2044 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 2045 | 2045 | $temp_array['direction_degree'] = $direction; |
| 2046 | 2046 | $temp_array['direction_shortname'] = "WSW"; |
| 2047 | 2047 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 2048 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 2048 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 2049 | 2049 | $temp_array['direction_degree'] = $direction; |
| 2050 | 2050 | $temp_array['direction_shortname'] = "W"; |
| 2051 | 2051 | $temp_array['direction_fullname'] = "West"; |
| 2052 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 2052 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 2053 | 2053 | $temp_array['direction_degree'] = $direction; |
| 2054 | 2054 | $temp_array['direction_shortname'] = "WNW"; |
| 2055 | 2055 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 2056 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 2056 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 2057 | 2057 | $temp_array['direction_degree'] = $direction; |
| 2058 | 2058 | $temp_array['direction_shortname'] = "NW"; |
| 2059 | 2059 | $temp_array['direction_fullname'] = "Northwest"; |
| 2060 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 2060 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 2061 | 2061 | $temp_array['direction_degree'] = $direction; |
| 2062 | 2062 | $temp_array['direction_shortname'] = "NNW"; |
| 2063 | 2063 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2074,11 +2074,11 @@ discard block |
||
| 2074 | 2074 | * @param Float $longitude longitute of the flight |
| 2075 | 2075 | * @return String the countrie |
| 2076 | 2076 | */ |
| 2077 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 2077 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 2078 | 2078 | { |
| 2079 | 2079 | global $globalDBdriver, $globalDebug; |
| 2080 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2081 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2080 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2081 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2082 | 2082 | |
| 2083 | 2083 | $Connection = new Connection($this->db); |
| 2084 | 2084 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2118,7 +2118,7 @@ discard block |
||
| 2118 | 2118 | public function getCountryFromISO2($iso2) |
| 2119 | 2119 | { |
| 2120 | 2120 | global $globalDBdriver, $globalDebug; |
| 2121 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 2121 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 2122 | 2122 | |
| 2123 | 2123 | $Connection = new Connection($this->db); |
| 2124 | 2124 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2166,7 +2166,7 @@ discard block |
||
| 2166 | 2166 | |
| 2167 | 2167 | $bitly_data = json_decode($bitly_data); |
| 2168 | 2168 | $bitly_url = ''; |
| 2169 | - if ($bitly_data->status_txt = "OK"){ |
|
| 2169 | + if ($bitly_data->status_txt = "OK") { |
|
| 2170 | 2170 | $bitly_url = $bitly_data->data->url; |
| 2171 | 2171 | } |
| 2172 | 2172 | |
@@ -2180,11 +2180,11 @@ discard block |
||
| 2180 | 2180 | * @return Array the vessel type list |
| 2181 | 2181 | * |
| 2182 | 2182 | */ |
| 2183 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 2183 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 2184 | 2184 | { |
| 2185 | 2185 | global $globalDBdriver; |
| 2186 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2187 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2186 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2187 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2188 | 2188 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
| 2189 | 2189 | if ($olderthanmonths > 0) { |
| 2190 | 2190 | if ($globalDBdriver == 'mysql') { |
@@ -2204,28 +2204,28 @@ discard block |
||
| 2204 | 2204 | if ($year != '') { |
| 2205 | 2205 | if ($globalDBdriver == 'mysql') { |
| 2206 | 2206 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2207 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2207 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2208 | 2208 | } else { |
| 2209 | 2209 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2210 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2210 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2211 | 2211 | } |
| 2212 | 2212 | } |
| 2213 | 2213 | if ($month != '') { |
| 2214 | 2214 | if ($globalDBdriver == 'mysql') { |
| 2215 | 2215 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2216 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2216 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2217 | 2217 | } else { |
| 2218 | 2218 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2219 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2219 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2220 | 2220 | } |
| 2221 | 2221 | } |
| 2222 | 2222 | if ($day != '') { |
| 2223 | 2223 | if ($globalDBdriver == 'mysql') { |
| 2224 | 2224 | $query .= " AND DAY(marine_output.date) = :day"; |
| 2225 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2225 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2226 | 2226 | } else { |
| 2227 | 2227 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 2228 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2228 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2229 | 2229 | } |
| 2230 | 2230 | } |
| 2231 | 2231 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2234,7 +2234,7 @@ discard block |
||
| 2234 | 2234 | $sth->execute($query_values); |
| 2235 | 2235 | $marine_array = array(); |
| 2236 | 2236 | $temp_array = array(); |
| 2237 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2237 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2238 | 2238 | { |
| 2239 | 2239 | $temp_array['marine_type'] = $row['marine_type']; |
| 2240 | 2240 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -2250,13 +2250,13 @@ discard block |
||
| 2250 | 2250 | * @return Array the tracker information |
| 2251 | 2251 | * |
| 2252 | 2252 | */ |
| 2253 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
| 2253 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 2254 | 2254 | { |
| 2255 | 2255 | global $globalTimezone, $globalDBdriver; |
| 2256 | 2256 | date_default_timezone_set('UTC'); |
| 2257 | 2257 | $query_values = array(); |
| 2258 | 2258 | $additional_query = ''; |
| 2259 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2259 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2260 | 2260 | if ($q != "") |
| 2261 | 2261 | { |
| 2262 | 2262 | if (!is_string($q)) |
@@ -2264,8 +2264,8 @@ discard block |
||
| 2264 | 2264 | return false; |
| 2265 | 2265 | } else { |
| 2266 | 2266 | $q_array = explode(" ", $q); |
| 2267 | - foreach ($q_array as $q_item){ |
|
| 2268 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 2267 | + foreach ($q_array as $q_item) { |
|
| 2268 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 2269 | 2269 | $additional_query .= " AND ("; |
| 2270 | 2270 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 2271 | 2271 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2277,42 +2277,42 @@ discard block |
||
| 2277 | 2277 | } |
| 2278 | 2278 | if ($callsign != "") |
| 2279 | 2279 | { |
| 2280 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2280 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2281 | 2281 | if (!is_string($callsign)) |
| 2282 | 2282 | { |
| 2283 | 2283 | return false; |
| 2284 | 2284 | } else { |
| 2285 | 2285 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 2286 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 2286 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 2287 | 2287 | } |
| 2288 | 2288 | } |
| 2289 | 2289 | if ($mmsi != "") |
| 2290 | 2290 | { |
| 2291 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 2291 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 2292 | 2292 | if (!is_numeric($mmsi)) |
| 2293 | 2293 | { |
| 2294 | 2294 | return false; |
| 2295 | 2295 | } else { |
| 2296 | 2296 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 2297 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 2297 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 2298 | 2298 | } |
| 2299 | 2299 | } |
| 2300 | 2300 | if ($imo != "") |
| 2301 | 2301 | { |
| 2302 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 2302 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 2303 | 2303 | if (!is_numeric($imo)) |
| 2304 | 2304 | { |
| 2305 | 2305 | return false; |
| 2306 | 2306 | } else { |
| 2307 | 2307 | $additional_query .= " AND marine_output.imo = :imo"; |
| 2308 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 2308 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | } |
| 2311 | 2311 | if ($date_posted != "") |
| 2312 | 2312 | { |
| 2313 | 2313 | $date_array = explode(",", $date_posted); |
| 2314 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 2315 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 2314 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 2315 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 2316 | 2316 | if ($globalTimezone != '') { |
| 2317 | 2317 | date_default_timezone_set($globalTimezone); |
| 2318 | 2318 | $datetime = new DateTime(); |
@@ -2339,8 +2339,8 @@ discard block |
||
| 2339 | 2339 | if ($limit != "") |
| 2340 | 2340 | { |
| 2341 | 2341 | $limit_array = explode(",", $limit); |
| 2342 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 2343 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 2342 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 2343 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 2344 | 2344 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2345 | 2345 | { |
| 2346 | 2346 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2358,22 +2358,22 @@ discard block |
||
| 2358 | 2358 | } |
| 2359 | 2359 | } |
| 2360 | 2360 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 2361 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 2361 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 2362 | 2362 | if ($globalDBdriver == 'mysql') { |
| 2363 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2363 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2364 | 2364 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2365 | 2365 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 2366 | 2366 | } else { |
| 2367 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2367 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2368 | 2368 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2369 | 2369 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
| 2370 | 2370 | } |
| 2371 | 2371 | } else { |
| 2372 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2372 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2373 | 2373 | ".$additional_query." |
| 2374 | 2374 | ".$orderby_query; |
| 2375 | 2375 | } |
| 2376 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 2376 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 2377 | 2377 | return $marine_array; |
| 2378 | 2378 | } |
| 2379 | 2379 | |
@@ -2386,12 +2386,12 @@ discard block |
||
| 2386 | 2386 | public function checkId($id) |
| 2387 | 2387 | { |
| 2388 | 2388 | global $globalDBdriver, $globalTimezone; |
| 2389 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2389 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2390 | 2390 | $query_data = array(':id' => $id); |
| 2391 | 2391 | $sth = $this->db->prepare($query); |
| 2392 | 2392 | $sth->execute($query_data); |
| 2393 | - $ident_result=''; |
|
| 2394 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2393 | + $ident_result = ''; |
|
| 2394 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2395 | 2395 | { |
| 2396 | 2396 | $ident_result = $row['fammarine_id']; |
| 2397 | 2397 | } |
@@ -2400,7 +2400,7 @@ discard block |
||
| 2400 | 2400 | |
| 2401 | 2401 | public function getOrderBy() |
| 2402 | 2402 | { |
| 2403 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 2403 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 2404 | 2404 | |
| 2405 | 2405 | return $orderby; |
| 2406 | 2406 | |