@@ -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,57 +46,57 @@ 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 | - $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']); |
|
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 | + $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']); |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | } |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $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']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,106 +105,106 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $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)); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $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)); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
154 | 154 | //$dataFound = true; |
155 | - } |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
166 | 166 | } |
167 | 167 | if (isset($line['status']) && $line['status'] != '') { |
168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
169 | 169 | } |
170 | 170 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
171 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
172 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
171 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
172 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
173 | 173 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
174 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
174 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
175 | 175 | $Marine = new Marine($this->db); |
176 | 176 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
177 | 177 | unset($Marine); |
178 | - } |
|
178 | + } |
|
179 | + } |
|
179 | 180 | } |
180 | - } |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
185 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
185 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
186 | 186 | } |
187 | 187 | if (isset($line['imo']) && $line['imo'] != '') { |
188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
189 | 189 | } |
190 | 190 | if (isset($line['callsign']) && $line['callsign'] != '') { |
191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
192 | 192 | } |
193 | 193 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
194 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
195 | 195 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
196 | 196 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
197 | 197 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
198 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
199 | 199 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
200 | - $Marine = new Marine($this->db); |
|
201 | - $fromsource = NULL; |
|
202 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
203 | - $Marine->db = null; |
|
200 | + $Marine = new Marine($this->db); |
|
201 | + $fromsource = NULL; |
|
202 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
203 | + $Marine->db = null; |
|
204 | + } |
|
204 | 205 | } |
205 | - } |
|
206 | 206 | } |
207 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
207 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
208 | 208 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
209 | 209 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
210 | 210 | if (!isset($line['id'])) { |
@@ -212,47 +212,47 @@ discard block |
||
212 | 212 | $this->all_tracked[$id]['forcenew'] = 1; |
213 | 213 | $this->all_tracked[$id]['addedMarine'] = 0; |
214 | 214 | } |
215 | - } |
|
215 | + } |
|
216 | 216 | } |
217 | 217 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
218 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
219 | 219 | } |
220 | 220 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
222 | 222 | } |
223 | 223 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
225 | 225 | } |
226 | 226 | if (isset($line['race_id']) && $line['race_id'] != '') { |
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['race_name']) && $line['race_name'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['race_time']) && $line['race_time'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['distance']) && $line['distance'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //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'])) { |
243 | 243 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
244 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
244 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
245 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
246 | - $timeelapsed = microtime(true); |
|
247 | - $Marine = new Marine($this->db); |
|
248 | - $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']); |
|
249 | - $Marine->db = null; |
|
246 | + $timeelapsed = microtime(true); |
|
247 | + $Marine = new Marine($this->db); |
|
248 | + $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']); |
|
249 | + $Marine->db = null; |
|
250 | + } |
|
250 | 251 | } |
251 | - } |
|
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
253 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
253 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
254 | 254 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
255 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
255 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
256 | 256 | $timeelapsed = microtime(true); |
257 | 257 | $Marine = new Marine($this->db); |
258 | 258 | $fromsource = NULL; |
@@ -260,20 +260,20 @@ discard block |
||
260 | 260 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
261 | 261 | $Marine->db = null; |
262 | 262 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
263 | - } |
|
263 | + } |
|
264 | + } |
|
264 | 265 | } |
265 | - } |
|
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
266 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
270 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
270 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
271 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
272 | - } else { |
|
272 | + } else { |
|
273 | 273 | 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"; |
274 | 274 | 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"; |
275 | 275 | return ''; |
276 | - } |
|
276 | + } |
|
277 | 277 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
278 | 278 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
279 | 279 | return ''; |
@@ -290,33 +290,33 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | if (isset($line['speed'])) { |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
295 | 295 | } 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'])) { |
296 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
297 | - if ($distance > 1000 && $distance < 10000) { |
|
296 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
297 | + if ($distance > 1000 && $distance < 10000) { |
|
298 | 298 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 299 | $speed = $speed*3.6; |
300 | 300 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
301 | 301 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
302 | - } |
|
302 | + } |
|
303 | 303 | } |
304 | 304 | |
305 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | - else unset($timediff); |
|
308 | - if ($this->tmd > 5 || |
|
309 | - !isset($timediff) || |
|
310 | - $timediff > $globalLiveInterval || |
|
311 | - ( |
|
312 | - $timediff > 30 && |
|
313 | - isset($this->all_tracked[$id]['latitude']) && |
|
314 | - isset($this->all_tracked[$id]['longitude']) && |
|
315 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
316 | - ) |
|
317 | - ) { |
|
305 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
306 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | + else unset($timediff); |
|
308 | + if ($this->tmd > 5 || |
|
309 | + !isset($timediff) || |
|
310 | + $timediff > $globalLiveInterval || |
|
311 | + ( |
|
312 | + $timediff > 30 && |
|
313 | + isset($this->all_tracked[$id]['latitude']) && |
|
314 | + isset($this->all_tracked[$id]['longitude']) && |
|
315 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
316 | + ) |
|
317 | + ) { |
|
318 | 318 | 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'])) { |
319 | - 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'])) { |
|
319 | + 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'])) { |
|
320 | 320 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
321 | 321 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 322 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -324,200 +324,200 @@ discard block |
||
324 | 324 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
325 | 325 | $timeelapsed = microtime(true); |
326 | 326 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | - $Marine = new Marine($this->db); |
|
328 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
329 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
330 | - $Marine->db = null; |
|
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
327 | + $Marine = new Marine($this->db); |
|
328 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
329 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
330 | + $Marine->db = null; |
|
331 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
332 | 332 | } |
333 | 333 | $this->tmd = 0; |
334 | 334 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
335 | - } |
|
335 | + } |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | 339 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
340 | 340 | 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') { |
341 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
342 | - $dataFound = true; |
|
343 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
341 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
342 | + $dataFound = true; |
|
343 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
344 | 344 | } |
345 | 345 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
346 | 346 | } |
347 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
348 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
349 | 349 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
350 | 350 | 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') { |
351 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
352 | - $dataFound = true; |
|
353 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
351 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
352 | + $dataFound = true; |
|
353 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
354 | 354 | } |
355 | 355 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
356 | 356 | } |
357 | 357 | |
358 | - } else if ($globalDebug && $timediff > 20) { |
|
358 | + } else if ($globalDebug && $timediff > 20) { |
|
359 | 359 | $this->tmd = $this->tmd + 1; |
360 | 360 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
361 | 361 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
362 | 362 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
363 | 363 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
368 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
367 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
368 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
369 | 369 | } |
370 | 370 | if (isset($line['format_source']) && $line['format_source'] != '') { |
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
372 | 372 | } |
373 | 373 | if (isset($line['source_name']) && $line['source_name'] != '') { |
374 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
374 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
375 | 375 | } |
376 | 376 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
377 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
377 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
384 | - //$dataFound = true; |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
384 | + //$dataFound = true; |
|
385 | 385 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
386 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
386 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
390 | 390 | } |
391 | 391 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
392 | 392 | |
393 | 393 | |
394 | 394 | |
395 | 395 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
396 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
397 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
398 | - 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'])) { |
|
399 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
396 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
397 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
398 | + 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'])) { |
|
399 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
402 | - $timeelapsed = microtime(true); |
|
403 | - $MarineLive = new MarineLive($this->db); |
|
404 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
401 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
402 | + $timeelapsed = microtime(true); |
|
403 | + $MarineLive = new MarineLive($this->db); |
|
404 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
405 | 405 | $Marine = new Marine($this->db); |
406 | 406 | $recent_ident = $Marine->checkId($line['id']); |
407 | 407 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
408 | 408 | $Marine->db=null; |
409 | - } elseif (isset($line['id'])) { |
|
409 | + } elseif (isset($line['id'])) { |
|
410 | 410 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | 411 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
412 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
412 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
413 | 413 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | 414 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
415 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
415 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
416 | 416 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | 417 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
418 | - } else $recent_ident = ''; |
|
419 | - $MarineLive->db=null; |
|
420 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
418 | + } else $recent_ident = ''; |
|
419 | + $MarineLive->db=null; |
|
420 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
422 | 422 | } else $recent_ident = ''; |
423 | - } else { |
|
423 | + } else { |
|
424 | 424 | $recent_ident = ''; |
425 | 425 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
426 | - } |
|
427 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
428 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | - { |
|
426 | + } |
|
427 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
428 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | + { |
|
430 | 430 | if ($globalDebug) { |
431 | 431 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
432 | 432 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
433 | 433 | } |
434 | 434 | //adds the spotter data for the archive |
435 | - $highlight = ''; |
|
436 | - 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'))); |
|
437 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
435 | + $highlight = ''; |
|
436 | + 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'))); |
|
437 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
438 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | - $timeelapsed = microtime(true); |
|
440 | - $Marine = new Marine($this->db); |
|
441 | - $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']); |
|
442 | - $Marine->db = null; |
|
443 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
439 | + $timeelapsed = microtime(true); |
|
440 | + $Marine = new Marine($this->db); |
|
441 | + $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']); |
|
442 | + $Marine->db = null; |
|
443 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
445 | + } |
|
445 | 446 | } |
446 | - } |
|
447 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
447 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
448 | 448 | // Add source stat in DB |
449 | 449 | $Stats = new Stats($this->db); |
450 | 450 | if (!empty($this->stats)) { |
451 | - if ($globalDebug) echo 'Add source stats : '; |
|
452 | - foreach($this->stats as $date => $data) { |
|
451 | + if ($globalDebug) echo 'Add source stats : '; |
|
452 | + foreach($this->stats as $date => $data) { |
|
453 | 453 | foreach($data as $source => $sourced) { |
454 | - //print_r($sourced); |
|
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
457 | - if (isset($sourced['msg'])) { |
|
458 | - if (time() - $sourced['msg']['date'] > 10) { |
|
459 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
460 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
461 | - unset($this->stats[$date][$source]['msg']); |
|
462 | - } |
|
463 | - } |
|
464 | - } |
|
465 | - if ($date != date('Y-m-d')) { |
|
466 | - unset($this->stats[$date]); |
|
467 | - } |
|
468 | - } |
|
469 | - if ($globalDebug) echo 'Done'."\n"; |
|
454 | + //print_r($sourced); |
|
455 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
457 | + if (isset($sourced['msg'])) { |
|
458 | + if (time() - $sourced['msg']['date'] > 10) { |
|
459 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
460 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
461 | + unset($this->stats[$date][$source]['msg']); |
|
462 | + } |
|
463 | + } |
|
464 | + } |
|
465 | + if ($date != date('Y-m-d')) { |
|
466 | + unset($this->stats[$date]); |
|
467 | + } |
|
468 | + } |
|
469 | + if ($globalDebug) echo 'Done'."\n"; |
|
470 | 470 | } |
471 | 471 | $Stats->db = null; |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - $this->del(); |
|
474 | + $this->del(); |
|
475 | 475 | //$ignoreImport = false; |
476 | 476 | $this->all_tracked[$id]['addedMarine'] = 1; |
477 | 477 | //print_r($this->all_tracked[$id]); |
478 | 478 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
479 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
480 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
481 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
479 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
480 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
481 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
482 | 482 | $MarineLive = new MarineLive($this->db); |
483 | 483 | $MarineLive->deleteLiveMarineData(); |
484 | 484 | $MarineLive->db=null; |
485 | 485 | if ($globalDebug) echo " Done\n"; |
486 | - } |
|
487 | - $this->last_delete = time(); |
|
486 | + } |
|
487 | + $this->last_delete = time(); |
|
488 | 488 | } |
489 | - } elseif ($recent_ident != '') { |
|
489 | + } elseif ($recent_ident != '') { |
|
490 | 490 | $this->all_tracked[$id]['id'] = $recent_ident; |
491 | 491 | $this->all_tracked[$id]['addedMarine'] = 1; |
492 | 492 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
493 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
493 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
494 | 494 | $Marine = new Marine($this->db); |
495 | 495 | $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']); |
496 | 496 | $Marine->db = null; |
497 | - } |
|
497 | + } |
|
498 | 498 | } |
499 | 499 | |
500 | - } |
|
500 | + } |
|
501 | 501 | } |
502 | - } |
|
503 | - //adds the spotter LIVE data |
|
504 | - if ($globalDebug) { |
|
502 | + } |
|
503 | + //adds the spotter LIVE data |
|
504 | + if ($globalDebug) { |
|
505 | 505 | 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"; |
506 | - } |
|
507 | - $ignoreImport = false; |
|
506 | + } |
|
507 | + $ignoreImport = false; |
|
508 | 508 | |
509 | - if (!$ignoreImport) { |
|
509 | + if (!$ignoreImport) { |
|
510 | 510 | 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'])) { |
511 | 511 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
512 | 512 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
513 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
514 | 514 | $timeelapsed = microtime(true); |
515 | 515 | $MarineLive = new MarineLive($this->db); |
516 | 516 | $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']); |
517 | 517 | $MarineLive->db = null; |
518 | 518 | if ($globalDebug) echo $result."\n"; |
519 | 519 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
520 | - } |
|
520 | + } |
|
521 | 521 | } |
522 | 522 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
523 | 523 | $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']); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | if ($stats_heading == 16) $stats_heading = 0; |
553 | 553 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | 554 | for ($i=0;$i<=15;$i++) { |
555 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
555 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
556 | 556 | } |
557 | 557 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
558 | 558 | } else { |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | //var_dump($this->stats); |
566 | 566 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
567 | 567 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | - end($this->stats[$current_date][$source]['hist']); |
|
569 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
568 | + end($this->stats[$current_date][$source]['hist']); |
|
569 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
570 | 570 | } else $mini = 0; |
571 | 571 | for ($i=$mini;$i<=$distance;$i+=10) { |
572 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
572 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
573 | 573 | } |
574 | 574 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
575 | 575 | } else { |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | |
586 | 586 | |
587 | 587 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
588 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
588 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
589 | 589 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
590 | 590 | $MarineLive = new MarineLive($this->db); |
591 | 591 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
592 | 592 | $MarineLive->db = null; |
593 | 593 | //MarineLive->deleteLiveMarineData(); |
594 | 594 | if ($globalDebug) echo " Done\n"; |
595 | - } |
|
596 | - $this->last_delete_hourly = time(); |
|
595 | + } |
|
596 | + $this->last_delete_hourly = time(); |
|
597 | 597 | } |
598 | 598 | |
599 | - } |
|
600 | - //$ignoreImport = false; |
|
599 | + } |
|
600 | + //$ignoreImport = false; |
|
601 | 601 | } |
602 | 602 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
603 | 603 | if ($send) return $this->all_tracked[$id]; |
604 | - } |
|
604 | + } |
|
605 | + } |
|
605 | 606 | } |
606 | - } |
|
607 | 607 | } |
608 | 608 | ?> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $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']); |
|
62 | + $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']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $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']); |
|
86 | + $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']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
107 | + if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi']) || isset($line['id'])) { |
110 | 110 | |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $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)); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $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)); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | 148 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
149 | 149 | $this->all_tracked[$id]['type'] = $identity['type']; |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
166 | 166 | } |
167 | 167 | if (isset($line['status']) && $line['status'] != '') { |
168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
169 | 169 | } |
170 | 170 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
171 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
171 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
172 | 172 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
173 | 173 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
174 | 174 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
175 | 175 | $Marine = new Marine($this->db); |
176 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
176 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
177 | 177 | unset($Marine); |
178 | 178 | } |
179 | 179 | } |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
185 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
185 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
186 | 186 | } |
187 | 187 | if (isset($line['imo']) && $line['imo'] != '') { |
188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
189 | 189 | } |
190 | 190 | if (isset($line['callsign']) && $line['callsign'] != '') { |
191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
192 | 192 | } |
193 | 193 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | 194 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
195 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
195 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
196 | 196 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
197 | 197 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | 198 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
199 | 199 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
200 | 200 | $Marine = new Marine($this->db); |
201 | 201 | $fromsource = NULL; |
202 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
202 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
203 | 203 | $Marine->db = null; |
204 | 204 | } |
205 | 205 | } |
@@ -215,28 +215,28 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
218 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
219 | 219 | } |
220 | 220 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
222 | 222 | } |
223 | 223 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
225 | 225 | } |
226 | 226 | if (isset($line['race_id']) && $line['race_id'] != '') { |
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['race_name']) && $line['race_name'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['race_time']) && $line['race_time'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['distance']) && $line['distance'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance'])); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //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'])) { |
@@ -245,44 +245,44 @@ discard block |
||
245 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | $Marine = new Marine($this->db); |
248 | - $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']); |
|
248 | + $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']); |
|
249 | 249 | $Marine->db = null; |
250 | 250 | } |
251 | 251 | } |
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
253 | 253 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
254 | 254 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
255 | 255 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
256 | 256 | $timeelapsed = microtime(true); |
257 | 257 | $Marine = new Marine($this->db); |
258 | 258 | $fromsource = NULL; |
259 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
259 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
260 | 260 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
261 | 261 | $Marine->db = null; |
262 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
262 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
266 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
267 | 267 | } |
268 | 268 | |
269 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
269 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
270 | 270 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
272 | 272 | } else { |
273 | 273 | 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"; |
274 | 274 | 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"; |
275 | 275 | return ''; |
276 | 276 | } |
277 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
277 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
278 | 278 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
279 | 279 | return ''; |
280 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
280 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
281 | 281 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
282 | 282 | return ''; |
283 | 283 | } elseif (!isset($line['datetime'])) { |
284 | 284 | date_default_timezone_set('UTC'); |
285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
286 | 286 | } else { |
287 | 287 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
288 | 288 | return ''; |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | if (isset($line['speed'])) { |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2))); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
295 | 295 | } 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'])) { |
296 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
296 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
297 | 297 | if ($distance > 1000 && $distance < 10000) { |
298 | 298 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 299 | $speed = $speed*3.6; |
300 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
300 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2))); |
|
301 | 301 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | 305 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
306 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
307 | 307 | else unset($timediff); |
308 | 308 | if ($this->tmd > 5 || |
309 | 309 | !isset($timediff) || |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | $timediff > 30 && |
313 | 313 | isset($this->all_tracked[$id]['latitude']) && |
314 | 314 | isset($this->all_tracked[$id]['longitude']) && |
315 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
315 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
316 | 316 | ) |
317 | 317 | ) { |
318 | 318 | 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'])) { |
319 | - 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'])) { |
|
319 | + 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'])) { |
|
320 | 320 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
321 | 321 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 322 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | $timeelapsed = microtime(true); |
326 | 326 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | 327 | $Marine = new Marine($this->db); |
328 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
328 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
329 | 329 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
330 | 330 | $Marine->db = null; |
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
331 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
332 | 332 | } |
333 | 333 | $this->tmd = 0; |
334 | 334 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -337,55 +337,55 @@ discard block |
||
337 | 337 | |
338 | 338 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | 339 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
340 | - 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') { |
|
340 | + 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') { |
|
341 | 341 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
342 | 342 | $dataFound = true; |
343 | 343 | $this->all_tracked[$id]['time_last_coord'] = time(); |
344 | 344 | } |
345 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
345 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
346 | 346 | } |
347 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | 348 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
349 | 349 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
350 | - 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') { |
|
350 | + 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') { |
|
351 | 351 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
352 | 352 | $dataFound = true; |
353 | 353 | $this->all_tracked[$id]['time_last_coord'] = time(); |
354 | 354 | } |
355 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
355 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } else if ($globalDebug && $timediff > 20) { |
359 | 359 | $this->tmd = $this->tmd + 1; |
360 | 360 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
361 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
362 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
361 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
362 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
363 | 363 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
364 | 364 | } |
365 | 365 | } |
366 | 366 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | 367 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
368 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
368 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
369 | 369 | } |
370 | 370 | if (isset($line['format_source']) && $line['format_source'] != '') { |
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
372 | 372 | } |
373 | 373 | if (isset($line['source_name']) && $line['source_name'] != '') { |
374 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
374 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
375 | 375 | } |
376 | 376 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
377 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
377 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
383 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
384 | 384 | //$dataFound = true; |
385 | 385 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
386 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
386 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
387 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
388 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | 389 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
390 | 390 | } |
391 | 391 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
396 | 396 | $this->all_tracked[$id]['lastupdate'] = time(); |
397 | 397 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
398 | - 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'])) { |
|
398 | + 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'])) { |
|
399 | 399 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | 401 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -404,28 +404,28 @@ discard block |
||
404 | 404 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
405 | 405 | $Marine = new Marine($this->db); |
406 | 406 | $recent_ident = $Marine->checkId($line['id']); |
407 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
408 | - $Marine->db=null; |
|
407 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
408 | + $Marine->db = null; |
|
409 | 409 | } elseif (isset($line['id'])) { |
410 | 410 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
411 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
412 | 412 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
413 | 413 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
415 | 415 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
416 | 416 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
418 | 418 | } else $recent_ident = ''; |
419 | - $MarineLive->db=null; |
|
419 | + $MarineLive->db = null; |
|
420 | 420 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
421 | 421 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
422 | 422 | } else $recent_ident = ''; |
423 | 423 | } else { |
424 | 424 | $recent_ident = ''; |
425 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
425 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
426 | 426 | } |
427 | 427 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
428 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
428 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | 429 | { |
430 | 430 | if ($globalDebug) { |
431 | 431 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | } |
434 | 434 | //adds the spotter data for the archive |
435 | 435 | $highlight = ''; |
436 | - 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'))); |
|
436 | + 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'))); |
|
437 | 437 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
438 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | 439 | $timeelapsed = microtime(true); |
440 | 440 | $Marine = new Marine($this->db); |
441 | - $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']); |
|
441 | + $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']); |
|
442 | 442 | $Marine->db = null; |
443 | 443 | if ($globalDebug && isset($result)) echo $result."\n"; |
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | $Stats = new Stats($this->db); |
450 | 450 | if (!empty($this->stats)) { |
451 | 451 | if ($globalDebug) echo 'Add source stats : '; |
452 | - foreach($this->stats as $date => $data) { |
|
453 | - foreach($data as $source => $sourced) { |
|
452 | + foreach ($this->stats as $date => $data) { |
|
453 | + foreach ($data as $source => $sourced) { |
|
454 | 454 | //print_r($sourced); |
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
455 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
456 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
457 | 457 | if (isset($sourced['msg'])) { |
458 | 458 | if (time() - $sourced['msg']['date'] > 10) { |
459 | 459 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
460 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
460 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
461 | 461 | unset($this->stats[$date][$source]['msg']); |
462 | 462 | } |
463 | 463 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
482 | 482 | $MarineLive = new MarineLive($this->db); |
483 | 483 | $MarineLive->deleteLiveMarineData(); |
484 | - $MarineLive->db=null; |
|
484 | + $MarineLive->db = null; |
|
485 | 485 | if ($globalDebug) echo " Done\n"; |
486 | 486 | } |
487 | 487 | $this->last_delete = time(); |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
493 | 493 | if (isset($globalDaemon) && !$globalDaemon) { |
494 | 494 | $Marine = new Marine($this->db); |
495 | - $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']); |
|
495 | + $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']); |
|
496 | 496 | $Marine->db = null; |
497 | 497 | } |
498 | 498 | } |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | $ignoreImport = false; |
508 | 508 | |
509 | 509 | if (!$ignoreImport) { |
510 | - 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'])) { |
|
510 | + 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'])) { |
|
511 | 511 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
512 | 512 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | 513 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
514 | 514 | $timeelapsed = microtime(true); |
515 | 515 | $MarineLive = new MarineLive($this->db); |
516 | - $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']); |
|
516 | + $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']); |
|
517 | 517 | $MarineLive->db = null; |
518 | 518 | if ($globalDebug) echo $result."\n"; |
519 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
519 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
523 | - $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']); |
|
523 | + $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']); |
|
524 | 524 | } |
525 | 525 | $this->all_tracked[$id]['putinarchive'] = false; |
526 | 526 | |
@@ -539,19 +539,19 @@ discard block |
||
539 | 539 | $latitude = $globalCenterLatitude; |
540 | 540 | $longitude = $globalCenterLongitude; |
541 | 541 | } |
542 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
542 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
543 | 543 | } else { |
544 | 544 | $latitude = $this->source_location[$source]['latitude']; |
545 | 545 | $longitude = $this->source_location[$source]['longitude']; |
546 | 546 | } |
547 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
547 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
548 | 548 | //$stats_heading = $stats_heading%22.5; |
549 | 549 | $stats_heading = round($stats_heading/22.5); |
550 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
550 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
551 | 551 | $current_date = date('Y-m-d'); |
552 | 552 | if ($stats_heading == 16) $stats_heading = 0; |
553 | 553 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | - for ($i=0;$i<=15;$i++) { |
|
554 | + for ($i = 0; $i <= 15; $i++) { |
|
555 | 555 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
556 | 556 | } |
557 | 557 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
567 | 567 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | 568 | end($this->stats[$current_date][$source]['hist']); |
569 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
569 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
570 | 570 | } else $mini = 0; |
571 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
571 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
572 | 572 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
573 | 573 | } |
574 | 574 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | $this->all_tracked[$id]['lastupdate'] = time(); |
582 | 582 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
583 | - } 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"; |
|
583 | + } 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"; |
|
584 | 584 | //$this->del(); |
585 | 585 | |
586 | 586 |
@@ -54,7 +54,9 @@ discard block |
||
54 | 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"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $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']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $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)); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -193,7 +219,9 @@ discard block |
||
193 | 219 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | 220 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
195 | 221 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
196 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
224 | + } |
|
197 | 225 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | 226 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
199 | 227 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -206,7 +234,9 @@ discard block |
||
206 | 234 | } |
207 | 235 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
208 | 236 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
209 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + if ($globalDebug) { |
|
238 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
239 | + } |
|
210 | 240 | if (!isset($line['id'])) { |
211 | 241 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
212 | 242 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -215,7 +245,9 @@ discard block |
||
215 | 245 | } |
216 | 246 | } |
217 | 247 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + if (strtotime($line['arrival_date']) > time()) { |
|
249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
250 | + } |
|
219 | 251 | } |
220 | 252 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | 253 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -257,34 +289,49 @@ discard block |
||
257 | 289 | $Marine = new Marine($this->db); |
258 | 290 | $fromsource = NULL; |
259 | 291 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
260 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
292 | + if ($globalDebug && $result != 'success') { |
|
293 | + echo '!!! ERROR : '.$result."\n"; |
|
294 | + } |
|
261 | 295 | $Marine->db = null; |
262 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
296 | + if ($globalDebugTimeElapsed) { |
|
297 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
298 | + } |
|
263 | 299 | } |
264 | 300 | } |
265 | 301 | } |
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
303 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
304 | + } |
|
267 | 305 | } |
268 | 306 | |
269 | 307 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
270 | 308 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
271 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
272 | 310 | } else { |
273 | - 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"; |
|
274 | - 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"; |
|
311 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
312 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
313 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
314 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
315 | + } |
|
275 | 316 | return ''; |
276 | 317 | } |
277 | 318 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
278 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
319 | + if ($globalDebug) { |
|
320 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
321 | + } |
|
279 | 322 | return ''; |
280 | 323 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
281 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
324 | + if ($globalDebug) { |
|
325 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
326 | + } |
|
282 | 327 | return ''; |
283 | 328 | } elseif (!isset($line['datetime'])) { |
284 | 329 | date_default_timezone_set('UTC'); |
285 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
286 | 331 | } else { |
287 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
332 | + if ($globalDebug) { |
|
333 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
334 | + } |
|
288 | 335 | return ''; |
289 | 336 | } |
290 | 337 | |
@@ -297,14 +344,21 @@ discard block |
||
297 | 344 | if ($distance > 1000 && $distance < 10000) { |
298 | 345 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 346 | $speed = $speed*3.6; |
300 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
301 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
347 | + if ($speed < 1000) { |
|
348 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
349 | + } |
|
350 | + if ($globalDebug) { |
|
351 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
352 | + } |
|
302 | 353 | } |
303 | 354 | } |
304 | 355 | |
305 | 356 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | - else unset($timediff); |
|
357 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
358 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
359 | + } else { |
|
360 | + unset($timediff); |
|
361 | + } |
|
308 | 362 | if ($this->tmd > 5 || |
309 | 363 | !isset($timediff) || |
310 | 364 | $timediff > $globalLiveInterval || |
@@ -321,22 +375,32 @@ discard block |
||
321 | 375 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 376 | $this->all_tracked[$id]['putinarchive'] = true; |
323 | 377 | |
324 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
378 | + if ($globalDebug) { |
|
379 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
380 | + } |
|
325 | 381 | $timeelapsed = microtime(true); |
326 | 382 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | 383 | $Marine = new Marine($this->db); |
328 | 384 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
329 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
385 | + if (!empty($all_country)) { |
|
386 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
387 | + } |
|
330 | 388 | $Marine->db = null; |
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
389 | + if ($globalDebugTimeElapsed) { |
|
390 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
391 | + } |
|
332 | 392 | } |
333 | 393 | $this->tmd = 0; |
334 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
394 | + if ($globalDebug) { |
|
395 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
396 | + } |
|
335 | 397 | } |
336 | 398 | } |
337 | 399 | |
338 | 400 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
401 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
402 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
403 | + } |
|
340 | 404 | 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') { |
341 | 405 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
342 | 406 | $dataFound = true; |
@@ -345,8 +409,12 @@ discard block |
||
345 | 409 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
346 | 410 | } |
347 | 411 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
349 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
412 | + if ($line['longitude'] > 180) { |
|
413 | + $line['longitude'] = $line['longitude'] - 360; |
|
414 | + } |
|
415 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
416 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
417 | + } |
|
350 | 418 | 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') { |
351 | 419 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
352 | 420 | $dataFound = true; |
@@ -364,7 +432,9 @@ discard block |
||
364 | 432 | } |
365 | 433 | } |
366 | 434 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
435 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
436 | + $dataFound = true; |
|
437 | + } |
|
368 | 438 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
369 | 439 | } |
370 | 440 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -378,15 +448,21 @@ discard block |
||
378 | 448 | } |
379 | 449 | |
380 | 450 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
451 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
452 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
453 | + } |
|
382 | 454 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
383 | 455 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
384 | 456 | //$dataFound = true; |
385 | 457 | } 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']) { |
386 | 458 | $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']); |
387 | 459 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
460 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
461 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
462 | + } |
|
463 | + if ($globalDebug) { |
|
464 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
465 | + } |
|
390 | 466 | } |
391 | 467 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
392 | 468 | |
@@ -398,28 +474,45 @@ discard block |
||
398 | 474 | 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'])) { |
399 | 475 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
400 | 476 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
477 | + if ($globalDebug) { |
|
478 | + echo "Check if vessel is already in DB..."; |
|
479 | + } |
|
402 | 480 | $timeelapsed = microtime(true); |
403 | 481 | $MarineLive = new MarineLive($this->db); |
404 | 482 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
405 | 483 | $Marine = new Marine($this->db); |
406 | 484 | $recent_ident = $Marine->checkId($line['id']); |
407 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
485 | + if ($globalDebugTimeElapsed) { |
|
486 | + echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
487 | + } |
|
408 | 488 | $Marine->db=null; |
409 | 489 | } elseif (isset($line['id'])) { |
410 | 490 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
491 | + if ($globalDebugTimeElapsed) { |
|
492 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
493 | + } |
|
412 | 494 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
413 | 495 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
496 | + if ($globalDebugTimeElapsed) { |
|
497 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
498 | + } |
|
415 | 499 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
416 | 500 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
418 | - } else $recent_ident = ''; |
|
501 | + if ($globalDebugTimeElapsed) { |
|
502 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
503 | + } |
|
504 | + } else { |
|
505 | + $recent_ident = ''; |
|
506 | + } |
|
419 | 507 | $MarineLive->db=null; |
420 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
422 | - } else $recent_ident = ''; |
|
508 | + if ($globalDebug && $recent_ident == '') { |
|
509 | + echo " Not in DB.\n"; |
|
510 | + } elseif ($globalDebug && $recent_ident != '') { |
|
511 | + echo " Already in DB.\n"; |
|
512 | + } |
|
513 | + } else { |
|
514 | + $recent_ident = ''; |
|
515 | + } |
|
423 | 516 | } else { |
424 | 517 | $recent_ident = ''; |
425 | 518 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -428,32 +521,47 @@ discard block |
||
428 | 521 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
429 | 522 | { |
430 | 523 | if ($globalDebug) { |
431 | - if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
432 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
524 | + if ($this->all_tracked[$id]['mmsi'] == '') { |
|
525 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
526 | + } else { |
|
527 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
528 | + } |
|
433 | 529 | } |
434 | 530 | //adds the spotter data for the archive |
435 | 531 | $highlight = ''; |
436 | - 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'))); |
|
532 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
533 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
534 | + } |
|
437 | 535 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
438 | 536 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | 537 | $timeelapsed = microtime(true); |
440 | 538 | $Marine = new Marine($this->db); |
441 | 539 | $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']); |
442 | 540 | $Marine->db = null; |
443 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
541 | + if ($globalDebug && isset($result)) { |
|
542 | + echo $result."\n"; |
|
543 | + } |
|
544 | + if ($globalDebugTimeElapsed) { |
|
545 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
546 | + } |
|
445 | 547 | } |
446 | 548 | } |
447 | 549 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
448 | 550 | // Add source stat in DB |
449 | 551 | $Stats = new Stats($this->db); |
450 | 552 | if (!empty($this->stats)) { |
451 | - if ($globalDebug) echo 'Add source stats : '; |
|
553 | + if ($globalDebug) { |
|
554 | + echo 'Add source stats : '; |
|
555 | + } |
|
452 | 556 | foreach($this->stats as $date => $data) { |
453 | 557 | foreach($data as $source => $sourced) { |
454 | 558 | //print_r($sourced); |
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
559 | + if (isset($sourced['polar'])) { |
|
560 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
561 | + } |
|
562 | + if (isset($sourced['hist'])) { |
|
563 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
564 | + } |
|
457 | 565 | if (isset($sourced['msg'])) { |
458 | 566 | if (time() - $sourced['msg']['date'] > 10) { |
459 | 567 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -466,7 +574,9 @@ discard block |
||
466 | 574 | unset($this->stats[$date]); |
467 | 575 | } |
468 | 576 | } |
469 | - if ($globalDebug) echo 'Done'."\n"; |
|
577 | + if ($globalDebug) { |
|
578 | + echo 'Done'."\n"; |
|
579 | + } |
|
470 | 580 | } |
471 | 581 | $Stats->db = null; |
472 | 582 | } |
@@ -476,13 +586,17 @@ discard block |
||
476 | 586 | $this->all_tracked[$id]['addedMarine'] = 1; |
477 | 587 | //print_r($this->all_tracked[$id]); |
478 | 588 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
479 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
589 | + if ($globalDebug) { |
|
590 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
591 | + } |
|
480 | 592 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
481 | 593 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
482 | 594 | $MarineLive = new MarineLive($this->db); |
483 | 595 | $MarineLive->deleteLiveMarineData(); |
484 | 596 | $MarineLive->db=null; |
485 | - if ($globalDebug) echo " Done\n"; |
|
597 | + if ($globalDebug) { |
|
598 | + echo " Done\n"; |
|
599 | + } |
|
486 | 600 | } |
487 | 601 | $this->last_delete = time(); |
488 | 602 | } |
@@ -508,15 +622,21 @@ discard block |
||
508 | 622 | |
509 | 623 | if (!$ignoreImport) { |
510 | 624 | 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'])) { |
511 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
625 | + if ($globalDebug) { |
|
626 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
627 | + } |
|
512 | 628 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | 629 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
514 | 630 | $timeelapsed = microtime(true); |
515 | 631 | $MarineLive = new MarineLive($this->db); |
516 | 632 | $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']); |
517 | 633 | $MarineLive->db = null; |
518 | - if ($globalDebug) echo $result."\n"; |
|
519 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
634 | + if ($globalDebug) { |
|
635 | + echo $result."\n"; |
|
636 | + } |
|
637 | + if ($globalDebugTimeElapsed) { |
|
638 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
639 | + } |
|
520 | 640 | } |
521 | 641 | } |
522 | 642 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -528,7 +648,9 @@ discard block |
||
528 | 648 | |
529 | 649 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
530 | 650 | $source = $this->all_tracked[$id]['source_name']; |
531 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
651 | + if ($source == '') { |
|
652 | + $source = $this->all_tracked[$id]['format_source']; |
|
653 | + } |
|
532 | 654 | if (!isset($this->source_location[$source])) { |
533 | 655 | $Location = new Source($this->db); |
534 | 656 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -549,7 +671,9 @@ discard block |
||
549 | 671 | $stats_heading = round($stats_heading/22.5); |
550 | 672 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
551 | 673 | $current_date = date('Y-m-d'); |
552 | - if ($stats_heading == 16) $stats_heading = 0; |
|
674 | + if ($stats_heading == 16) { |
|
675 | + $stats_heading = 0; |
|
676 | + } |
|
553 | 677 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | 678 | for ($i=0;$i<=15;$i++) { |
555 | 679 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -567,7 +691,9 @@ discard block |
||
567 | 691 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | 692 | end($this->stats[$current_date][$source]['hist']); |
569 | 693 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
570 | - } else $mini = 0; |
|
694 | + } else { |
|
695 | + $mini = 0; |
|
696 | + } |
|
571 | 697 | for ($i=$mini;$i<=$distance;$i+=10) { |
572 | 698 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
573 | 699 | } |
@@ -579,19 +705,27 @@ discard block |
||
579 | 705 | |
580 | 706 | |
581 | 707 | $this->all_tracked[$id]['lastupdate'] = time(); |
582 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
583 | - } 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"; |
|
708 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
709 | + $send = true; |
|
710 | + } |
|
711 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
712 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
713 | + } |
|
584 | 714 | //$this->del(); |
585 | 715 | |
586 | 716 | |
587 | 717 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
588 | 718 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
589 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
719 | + if ($globalDebug) { |
|
720 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
721 | + } |
|
590 | 722 | $MarineLive = new MarineLive($this->db); |
591 | 723 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
592 | 724 | $MarineLive->db = null; |
593 | 725 | //MarineLive->deleteLiveMarineData(); |
594 | - if ($globalDebug) echo " Done\n"; |
|
726 | + if ($globalDebug) { |
|
727 | + echo " Done\n"; |
|
728 | + } |
|
595 | 729 | } |
596 | 730 | $this->last_delete_hourly = time(); |
597 | 731 | } |
@@ -600,7 +734,9 @@ discard block |
||
600 | 734 | //$ignoreImport = false; |
601 | 735 | } |
602 | 736 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
603 | - if ($send) return $this->all_tracked[$id]; |
|
737 | + if ($send) { |
|
738 | + return $this->all_tracked[$id]; |
|
739 | + } |
|
604 | 740 | } |
605 | 741 | } |
606 | 742 | } |