@@ -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']); |
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; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,104 +105,104 @@ 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' => '')); |
|
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' => '')); |
|
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 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
170 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
172 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
173 | 173 | $Marine = new Marine($this->db); |
174 | 174 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
175 | 175 | unset($Marine); |
176 | - } |
|
176 | + } |
|
177 | + } |
|
177 | 178 | } |
178 | - } |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
192 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
193 | 193 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
196 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | - $Marine = new Marine($this->db); |
|
199 | - $fromsource = NULL; |
|
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | - $Marine->db = null; |
|
198 | + $Marine = new Marine($this->db); |
|
199 | + $fromsource = NULL; |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
201 | + $Marine->db = null; |
|
202 | + } |
|
202 | 203 | } |
203 | - } |
|
204 | 204 | } |
205 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
205 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
206 | 206 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | 207 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
208 | 208 | if (!isset($line['id'])) { |
@@ -210,38 +210,38 @@ discard block |
||
210 | 210 | $this->all_tracked[$id]['forcenew'] = 1; |
211 | 211 | $this->all_tracked[$id]['addedMarine'] = 0; |
212 | 212 | } |
213 | - } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
220 | 220 | } |
221 | 221 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
223 | 223 | } |
224 | 224 | if (isset($line['race_id']) && $line['race_id'] != '') { |
225 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
225 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
226 | 226 | } |
227 | 227 | if (isset($line['race_name']) && $line['race_name'] != '') { |
228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | //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'])) { |
232 | 232 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
233 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
233 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
234 | 234 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
235 | - $timeelapsed = microtime(true); |
|
236 | - $Marine = new Marine($this->db); |
|
237 | - $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']); |
|
238 | - $Marine->db = null; |
|
235 | + $timeelapsed = microtime(true); |
|
236 | + $Marine = new Marine($this->db); |
|
237 | + $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']); |
|
238 | + $Marine->db = null; |
|
239 | + } |
|
239 | 240 | } |
240 | - } |
|
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
242 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
242 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
243 | 243 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
244 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
244 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | $Marine = new Marine($this->db); |
247 | 247 | $fromsource = NULL; |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
250 | 250 | $Marine->db = null; |
251 | 251 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
252 | - } |
|
252 | + } |
|
253 | + } |
|
253 | 254 | } |
254 | - } |
|
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
255 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
259 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
259 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
260 | 260 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
261 | - } else { |
|
261 | + } else { |
|
262 | 262 | 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"; |
263 | 263 | 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"; |
264 | 264 | return ''; |
265 | - } |
|
265 | + } |
|
266 | 266 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
267 | 267 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
268 | 268 | return ''; |
@@ -279,33 +279,33 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | if (isset($line['speed'])) { |
282 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
283 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
282 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
283 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
284 | 284 | } 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'])) { |
285 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
286 | - if ($distance > 1000 && $distance < 10000) { |
|
285 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
286 | + if ($distance > 1000 && $distance < 10000) { |
|
287 | 287 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 288 | $speed = $speed*3.6; |
289 | 289 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
290 | 290 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
291 | - } |
|
291 | + } |
|
292 | 292 | } |
293 | 293 | |
294 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | - else unset($timediff); |
|
297 | - if ($this->tmd > 5 || |
|
298 | - !isset($timediff) || |
|
299 | - $timediff > $globalLiveInterval || |
|
300 | - ( |
|
301 | - $timediff > 30 && |
|
302 | - isset($this->all_tracked[$id]['latitude']) && |
|
303 | - isset($this->all_tracked[$id]['longitude']) && |
|
304 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
305 | - ) |
|
306 | - ) { |
|
294 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
295 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | + else unset($timediff); |
|
297 | + if ($this->tmd > 5 || |
|
298 | + !isset($timediff) || |
|
299 | + $timediff > $globalLiveInterval || |
|
300 | + ( |
|
301 | + $timediff > 30 && |
|
302 | + isset($this->all_tracked[$id]['latitude']) && |
|
303 | + isset($this->all_tracked[$id]['longitude']) && |
|
304 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
305 | + ) |
|
306 | + ) { |
|
307 | 307 | 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'])) { |
308 | - 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'])) { |
|
308 | + 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'])) { |
|
309 | 309 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
310 | 310 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 311 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -313,195 +313,195 @@ discard block |
||
313 | 313 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
314 | 314 | $timeelapsed = microtime(true); |
315 | 315 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | - $Marine = new Marine($this->db); |
|
317 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
318 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
319 | - $Marine->db = null; |
|
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
316 | + $Marine = new Marine($this->db); |
|
317 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
318 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
319 | + $Marine->db = null; |
|
320 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
321 | 321 | } |
322 | 322 | $this->tmd = 0; |
323 | 323 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
324 | - } |
|
324 | + } |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | 328 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
329 | 329 | 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') { |
330 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
331 | - $dataFound = true; |
|
332 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
330 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
331 | + $dataFound = true; |
|
332 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
333 | 333 | } |
334 | 334 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
335 | 335 | } |
336 | 336 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
337 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
338 | 338 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
339 | 339 | 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') { |
340 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
341 | - $dataFound = true; |
|
342 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
340 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
341 | + $dataFound = true; |
|
342 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
343 | 343 | } |
344 | 344 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
345 | 345 | } |
346 | 346 | |
347 | - } else if ($globalDebug && $timediff > 20) { |
|
347 | + } else if ($globalDebug && $timediff > 20) { |
|
348 | 348 | $this->tmd = $this->tmd + 1; |
349 | 349 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
350 | 350 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
351 | 351 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
352 | 352 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
353 | - } |
|
353 | + } |
|
354 | 354 | } |
355 | 355 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
356 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['format_source']) && $line['format_source'] != '') { |
360 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
360 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
361 | 361 | } |
362 | 362 | if (isset($line['source_name']) && $line['source_name'] != '') { |
363 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
363 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
373 | - //$dataFound = true; |
|
370 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
373 | + //$dataFound = true; |
|
374 | 374 | } 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']) { |
375 | - $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']); |
|
376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
375 | + $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']); |
|
376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
379 | 379 | } |
380 | 380 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
381 | 381 | |
382 | 382 | |
383 | 383 | |
384 | 384 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
385 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
386 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
387 | - 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'])) { |
|
388 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
385 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
386 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
387 | + 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'])) { |
|
388 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
389 | 389 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
391 | - $timeelapsed = microtime(true); |
|
392 | - $MarineLive = new MarineLive($this->db); |
|
393 | - if (isset($line['id'])) { |
|
390 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
391 | + $timeelapsed = microtime(true); |
|
392 | + $MarineLive = new MarineLive($this->db); |
|
393 | + if (isset($line['id'])) { |
|
394 | 394 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | 395 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
396 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
396 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
397 | 397 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | 398 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
399 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
399 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
400 | 400 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | 401 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
402 | - } else $recent_ident = ''; |
|
403 | - $MarineLive->db=null; |
|
404 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
402 | + } else $recent_ident = ''; |
|
403 | + $MarineLive->db=null; |
|
404 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
406 | 406 | } else $recent_ident = ''; |
407 | - } else { |
|
407 | + } else { |
|
408 | 408 | $recent_ident = ''; |
409 | 409 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
410 | - } |
|
411 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
412 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | - { |
|
410 | + } |
|
411 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
412 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | + { |
|
414 | 414 | if ($globalDebug) { |
415 | 415 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
416 | 416 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
417 | 417 | } |
418 | 418 | //adds the spotter data for the archive |
419 | - $highlight = ''; |
|
420 | - 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'))); |
|
421 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
419 | + $highlight = ''; |
|
420 | + 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'))); |
|
421 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
422 | 422 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
423 | - $timeelapsed = microtime(true); |
|
424 | - $Marine = new Marine($this->db); |
|
425 | - $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']); |
|
426 | - $Marine->db = null; |
|
427 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
423 | + $timeelapsed = microtime(true); |
|
424 | + $Marine = new Marine($this->db); |
|
425 | + $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']); |
|
426 | + $Marine->db = null; |
|
427 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
428 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
431 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
432 | 432 | // Add source stat in DB |
433 | 433 | $Stats = new Stats($this->db); |
434 | 434 | if (!empty($this->stats)) { |
435 | - if ($globalDebug) echo 'Add source stats : '; |
|
436 | - foreach($this->stats as $date => $data) { |
|
435 | + if ($globalDebug) echo 'Add source stats : '; |
|
436 | + foreach($this->stats as $date => $data) { |
|
437 | 437 | foreach($data as $source => $sourced) { |
438 | - //print_r($sourced); |
|
439 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
440 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
441 | - if (isset($sourced['msg'])) { |
|
442 | - if (time() - $sourced['msg']['date'] > 10) { |
|
443 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
444 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
445 | - unset($this->stats[$date][$source]['msg']); |
|
446 | - } |
|
447 | - } |
|
448 | - } |
|
449 | - if ($date != date('Y-m-d')) { |
|
450 | - unset($this->stats[$date]); |
|
451 | - } |
|
452 | - } |
|
453 | - if ($globalDebug) echo 'Done'."\n"; |
|
438 | + //print_r($sourced); |
|
439 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
440 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
441 | + if (isset($sourced['msg'])) { |
|
442 | + if (time() - $sourced['msg']['date'] > 10) { |
|
443 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
444 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
445 | + unset($this->stats[$date][$source]['msg']); |
|
446 | + } |
|
447 | + } |
|
448 | + } |
|
449 | + if ($date != date('Y-m-d')) { |
|
450 | + unset($this->stats[$date]); |
|
451 | + } |
|
452 | + } |
|
453 | + if ($globalDebug) echo 'Done'."\n"; |
|
454 | 454 | } |
455 | 455 | $Stats->db = null; |
456 | - } |
|
456 | + } |
|
457 | 457 | |
458 | - $this->del(); |
|
458 | + $this->del(); |
|
459 | 459 | //$ignoreImport = false; |
460 | 460 | $this->all_tracked[$id]['addedMarine'] = 1; |
461 | 461 | //print_r($this->all_tracked[$id]); |
462 | 462 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
463 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
464 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
465 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
463 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
464 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
465 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
466 | 466 | $MarineLive = new MarineLive($this->db); |
467 | 467 | $MarineLive->deleteLiveMarineData(); |
468 | 468 | $MarineLive->db=null; |
469 | 469 | if ($globalDebug) echo " Done\n"; |
470 | - } |
|
471 | - $this->last_delete = time(); |
|
470 | + } |
|
471 | + $this->last_delete = time(); |
|
472 | 472 | } |
473 | - } elseif ($recent_ident != '') { |
|
473 | + } elseif ($recent_ident != '') { |
|
474 | 474 | $this->all_tracked[$id]['id'] = $recent_ident; |
475 | 475 | $this->all_tracked[$id]['addedMarine'] = 1; |
476 | 476 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
477 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
477 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
478 | 478 | $Marine = new Marine($this->db); |
479 | 479 | $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']); |
480 | 480 | $Marine->db = null; |
481 | - } |
|
481 | + } |
|
482 | 482 | } |
483 | 483 | |
484 | - } |
|
484 | + } |
|
485 | 485 | } |
486 | - } |
|
487 | - //adds the spotter LIVE data |
|
488 | - if ($globalDebug) { |
|
486 | + } |
|
487 | + //adds the spotter LIVE data |
|
488 | + if ($globalDebug) { |
|
489 | 489 | 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"; |
490 | - } |
|
491 | - $ignoreImport = false; |
|
490 | + } |
|
491 | + $ignoreImport = false; |
|
492 | 492 | |
493 | - if (!$ignoreImport) { |
|
493 | + if (!$ignoreImport) { |
|
494 | 494 | 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'])) { |
495 | 495 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
496 | 496 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
497 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
497 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
498 | 498 | $timeelapsed = microtime(true); |
499 | 499 | $MarineLive = new MarineLive($this->db); |
500 | 500 | $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']); |
501 | 501 | $MarineLive->db = null; |
502 | 502 | if ($globalDebug) echo $result."\n"; |
503 | 503 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
504 | - } |
|
504 | + } |
|
505 | 505 | } |
506 | 506 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
507 | 507 | $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']); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | if ($stats_heading == 16) $stats_heading = 0; |
537 | 537 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
538 | 538 | for ($i=0;$i<=15;$i++) { |
539 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
539 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
540 | 540 | } |
541 | 541 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
542 | 542 | } else { |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | //var_dump($this->stats); |
550 | 550 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
551 | 551 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
552 | - end($this->stats[$current_date][$source]['hist']); |
|
553 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
552 | + end($this->stats[$current_date][$source]['hist']); |
|
553 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
554 | 554 | } else $mini = 0; |
555 | 555 | for ($i=$mini;$i<=$distance;$i+=10) { |
556 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
556 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
557 | 557 | } |
558 | 558 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
559 | 559 | } else { |
@@ -569,24 +569,24 @@ discard block |
||
569 | 569 | |
570 | 570 | |
571 | 571 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
572 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
572 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
573 | 573 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
574 | 574 | $MarineLive = new MarineLive($this->db); |
575 | 575 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
576 | 576 | $MarineLive->db = null; |
577 | 577 | //MarineLive->deleteLiveMarineData(); |
578 | 578 | if ($globalDebug) echo " Done\n"; |
579 | - } |
|
580 | - $this->last_delete_hourly = time(); |
|
579 | + } |
|
580 | + $this->last_delete_hourly = time(); |
|
581 | 581 | } |
582 | 582 | |
583 | - } |
|
584 | - //$ignoreImport = false; |
|
583 | + } |
|
584 | + //$ignoreImport = false; |
|
585 | 585 | } |
586 | 586 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
587 | 587 | if ($send) return $this->all_tracked[$id]; |
588 | - } |
|
588 | + } |
|
589 | + } |
|
589 | 590 | } |
590 | - } |
|
591 | 591 | } |
592 | 592 | ?> |
@@ -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']); |
|
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']); |
|
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; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval; |
|
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' => '')); |
|
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' => '')); |
|
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,23 +155,23 @@ 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 | } |
165 | 165 | if (isset($line['status']) && $line['status'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
170 | 170 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
171 | 171 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
172 | 172 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
173 | 173 | $Marine = new Marine($this->db); |
174 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
174 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
175 | 175 | unset($Marine); |
176 | 176 | } |
177 | 177 | } |
@@ -180,24 +180,24 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
184 | 184 | } |
185 | 185 | if (isset($line['imo']) && $line['imo'] != '') { |
186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
187 | 187 | } |
188 | 188 | if (isset($line['callsign']) && $line['callsign'] != '') { |
189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
190 | 190 | } |
191 | 191 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 192 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
193 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
194 | 194 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
195 | 195 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 196 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 197 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
198 | 198 | $Marine = new Marine($this->db); |
199 | 199 | $fromsource = NULL; |
200 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
200 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
201 | 201 | $Marine->db = null; |
202 | 202 | } |
203 | 203 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
216 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
217 | 217 | } |
218 | 218 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
220 | 220 | } |
221 | 221 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
223 | 223 | } |
224 | 224 | if (isset($line['race_id']) && $line['race_id'] != '') { |
225 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
225 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
226 | 226 | } |
227 | 227 | if (isset($line['race_name']) && $line['race_name'] != '') { |
228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | //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'])) { |
@@ -234,44 +234,44 @@ discard block |
||
234 | 234 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
235 | 235 | $timeelapsed = microtime(true); |
236 | 236 | $Marine = new Marine($this->db); |
237 | - $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']); |
|
237 | + $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']); |
|
238 | 238 | $Marine->db = null; |
239 | 239 | } |
240 | 240 | } |
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
242 | 242 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
243 | 243 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
244 | 244 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | $Marine = new Marine($this->db); |
247 | 247 | $fromsource = NULL; |
248 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
248 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
249 | 249 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
250 | 250 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
255 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
256 | 256 | } |
257 | 257 | |
258 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
258 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
259 | 259 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
261 | 261 | } else { |
262 | 262 | 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"; |
263 | 263 | 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"; |
264 | 264 | return ''; |
265 | 265 | } |
266 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
266 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
267 | 267 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
268 | 268 | return ''; |
269 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
269 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
270 | 270 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
271 | 271 | return ''; |
272 | 272 | } elseif (!isset($line['datetime'])) { |
273 | 273 | date_default_timezone_set('UTC'); |
274 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
274 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
275 | 275 | } else { |
276 | 276 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
277 | 277 | return ''; |
@@ -279,20 +279,20 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | if (isset($line['speed'])) { |
282 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
283 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
282 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2))); |
|
283 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
284 | 284 | } 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'])) { |
285 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
285 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
286 | 286 | if ($distance > 1000 && $distance < 10000) { |
287 | 287 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 288 | $speed = $speed*3.6; |
289 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
289 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2))); |
|
290 | 290 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | 294 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
295 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
296 | 296 | else unset($timediff); |
297 | 297 | if ($this->tmd > 5 || |
298 | 298 | !isset($timediff) || |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | $timediff > 30 && |
302 | 302 | isset($this->all_tracked[$id]['latitude']) && |
303 | 303 | isset($this->all_tracked[$id]['longitude']) && |
304 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
304 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
305 | 305 | ) |
306 | 306 | ) { |
307 | 307 | 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'])) { |
308 | - 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'])) { |
|
308 | + 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'])) { |
|
309 | 309 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
310 | 310 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 311 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | $timeelapsed = microtime(true); |
315 | 315 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | 316 | $Marine = new Marine($this->db); |
317 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
317 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
318 | 318 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
319 | 319 | $Marine->db = null; |
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
320 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
321 | 321 | } |
322 | 322 | $this->tmd = 0; |
323 | 323 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -326,55 +326,55 @@ discard block |
||
326 | 326 | |
327 | 327 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | 328 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
329 | - 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') { |
|
329 | + 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') { |
|
330 | 330 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
331 | 331 | $dataFound = true; |
332 | 332 | $this->all_tracked[$id]['time_last_coord'] = time(); |
333 | 333 | } |
334 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
334 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
335 | 335 | } |
336 | 336 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | 337 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
338 | 338 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
339 | - 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') { |
|
339 | + 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') { |
|
340 | 340 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
341 | 341 | $dataFound = true; |
342 | 342 | $this->all_tracked[$id]['time_last_coord'] = time(); |
343 | 343 | } |
344 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
344 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | } else if ($globalDebug && $timediff > 20) { |
348 | 348 | $this->tmd = $this->tmd + 1; |
349 | 349 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
350 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
351 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
350 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
351 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
352 | 352 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | 356 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['format_source']) && $line['format_source'] != '') { |
360 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
360 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
361 | 361 | } |
362 | 362 | if (isset($line['source_name']) && $line['source_name'] != '') { |
363 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
363 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
372 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
370 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
372 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
373 | 373 | //$dataFound = true; |
374 | 374 | } 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']) { |
375 | - $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']); |
|
376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
375 | + $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']); |
|
376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
377 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | 378 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
379 | 379 | } |
380 | 380 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
385 | 385 | $this->all_tracked[$id]['lastupdate'] = time(); |
386 | 386 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
387 | - 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'])) { |
|
387 | + 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'])) { |
|
388 | 388 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
389 | 389 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | 390 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -392,24 +392,24 @@ discard block |
||
392 | 392 | $MarineLive = new MarineLive($this->db); |
393 | 393 | if (isset($line['id'])) { |
394 | 394 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
395 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
396 | 396 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
397 | 397 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
398 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
399 | 399 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
400 | 400 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
401 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
402 | 402 | } else $recent_ident = ''; |
403 | - $MarineLive->db=null; |
|
403 | + $MarineLive->db = null; |
|
404 | 404 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
405 | 405 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
406 | 406 | } else $recent_ident = ''; |
407 | 407 | } else { |
408 | 408 | $recent_ident = ''; |
409 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
409 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
410 | 410 | } |
411 | 411 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
412 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
412 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
413 | 413 | { |
414 | 414 | if ($globalDebug) { |
415 | 415 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
@@ -417,15 +417,15 @@ discard block |
||
417 | 417 | } |
418 | 418 | //adds the spotter data for the archive |
419 | 419 | $highlight = ''; |
420 | - 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'))); |
|
420 | + 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'))); |
|
421 | 421 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
422 | 422 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
423 | 423 | $timeelapsed = microtime(true); |
424 | 424 | $Marine = new Marine($this->db); |
425 | - $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']); |
|
425 | + $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']); |
|
426 | 426 | $Marine->db = null; |
427 | 427 | if ($globalDebug && isset($result)) echo $result."\n"; |
428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
428 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | $Stats = new Stats($this->db); |
434 | 434 | if (!empty($this->stats)) { |
435 | 435 | if ($globalDebug) echo 'Add source stats : '; |
436 | - foreach($this->stats as $date => $data) { |
|
437 | - foreach($data as $source => $sourced) { |
|
436 | + foreach ($this->stats as $date => $data) { |
|
437 | + foreach ($data as $source => $sourced) { |
|
438 | 438 | //print_r($sourced); |
439 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
440 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
439 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
440 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
441 | 441 | if (isset($sourced['msg'])) { |
442 | 442 | if (time() - $sourced['msg']['date'] > 10) { |
443 | 443 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
444 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
444 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
445 | 445 | unset($this->stats[$date][$source]['msg']); |
446 | 446 | } |
447 | 447 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
466 | 466 | $MarineLive = new MarineLive($this->db); |
467 | 467 | $MarineLive->deleteLiveMarineData(); |
468 | - $MarineLive->db=null; |
|
468 | + $MarineLive->db = null; |
|
469 | 469 | if ($globalDebug) echo " Done\n"; |
470 | 470 | } |
471 | 471 | $this->last_delete = time(); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
477 | 477 | if (isset($globalDaemon) && !$globalDaemon) { |
478 | 478 | $Marine = new Marine($this->db); |
479 | - $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']); |
|
479 | + $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']); |
|
480 | 480 | $Marine->db = null; |
481 | 481 | } |
482 | 482 | } |
@@ -491,20 +491,20 @@ discard block |
||
491 | 491 | $ignoreImport = false; |
492 | 492 | |
493 | 493 | if (!$ignoreImport) { |
494 | - 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'])) { |
|
494 | + 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'])) { |
|
495 | 495 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
496 | 496 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
497 | 497 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
498 | 498 | $timeelapsed = microtime(true); |
499 | 499 | $MarineLive = new MarineLive($this->db); |
500 | - $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']); |
|
500 | + $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']); |
|
501 | 501 | $MarineLive->db = null; |
502 | 502 | if ($globalDebug) echo $result."\n"; |
503 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
503 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
504 | 504 | } |
505 | 505 | } |
506 | 506 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
507 | - $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']); |
|
507 | + $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']); |
|
508 | 508 | } |
509 | 509 | $this->all_tracked[$id]['putinarchive'] = false; |
510 | 510 | |
@@ -523,19 +523,19 @@ discard block |
||
523 | 523 | $latitude = $globalCenterLatitude; |
524 | 524 | $longitude = $globalCenterLongitude; |
525 | 525 | } |
526 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
526 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
527 | 527 | } else { |
528 | 528 | $latitude = $this->source_location[$source]['latitude']; |
529 | 529 | $longitude = $this->source_location[$source]['longitude']; |
530 | 530 | } |
531 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
531 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
532 | 532 | //$stats_heading = $stats_heading%22.5; |
533 | 533 | $stats_heading = round($stats_heading/22.5); |
534 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
534 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
535 | 535 | $current_date = date('Y-m-d'); |
536 | 536 | if ($stats_heading == 16) $stats_heading = 0; |
537 | 537 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
538 | - for ($i=0;$i<=15;$i++) { |
|
538 | + for ($i = 0; $i <= 15; $i++) { |
|
539 | 539 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
540 | 540 | } |
541 | 541 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
551 | 551 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
552 | 552 | end($this->stats[$current_date][$source]['hist']); |
553 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
553 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
554 | 554 | } else $mini = 0; |
555 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
555 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
556 | 556 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
557 | 557 | } |
558 | 558 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | |
565 | 565 | $this->all_tracked[$id]['lastupdate'] = time(); |
566 | 566 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
567 | - } 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"; |
|
567 | + } 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"; |
|
568 | 568 | //$this->del(); |
569 | 569 | |
570 | 570 |
@@ -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']); |
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; |
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' => '')); |
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']) { |
@@ -191,7 +217,9 @@ discard block |
||
191 | 217 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 218 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | 219 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + } |
|
195 | 223 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 224 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 225 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -204,7 +232,9 @@ discard block |
||
204 | 232 | } |
205 | 233 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
206 | 234 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + } |
|
208 | 238 | if (!isset($line['id'])) { |
209 | 239 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
210 | 240 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -213,7 +243,9 @@ discard block |
||
213 | 243 | } |
214 | 244 | } |
215 | 245 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
246 | + if (strtotime($line['arrival_date']) > time()) { |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + } |
|
217 | 249 | } |
218 | 250 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
219 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -246,34 +278,49 @@ discard block |
||
246 | 278 | $Marine = new Marine($this->db); |
247 | 279 | $fromsource = NULL; |
248 | 280 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
249 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
281 | + if ($globalDebug && $result != 'success') { |
|
282 | + echo '!!! ERROR : '.$result."\n"; |
|
283 | + } |
|
250 | 284 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + if ($globalDebugTimeElapsed) { |
|
286 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | + } |
|
252 | 288 | } |
253 | 289 | } |
254 | 290 | } |
255 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
291 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
293 | + } |
|
256 | 294 | } |
257 | 295 | |
258 | 296 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
259 | 297 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
260 | 298 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
261 | 299 | } else { |
262 | - 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"; |
|
263 | - 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"; |
|
300 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
301 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
302 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
303 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
304 | + } |
|
264 | 305 | return ''; |
265 | 306 | } |
266 | 307 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
267 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
310 | + } |
|
268 | 311 | return ''; |
269 | 312 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
270 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
313 | + if ($globalDebug) { |
|
314 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
315 | + } |
|
271 | 316 | return ''; |
272 | 317 | } elseif (!isset($line['datetime'])) { |
273 | 318 | date_default_timezone_set('UTC'); |
274 | 319 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
275 | 320 | } else { |
276 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
321 | + if ($globalDebug) { |
|
322 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
323 | + } |
|
277 | 324 | return ''; |
278 | 325 | } |
279 | 326 | |
@@ -286,14 +333,21 @@ discard block |
||
286 | 333 | if ($distance > 1000 && $distance < 10000) { |
287 | 334 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
288 | 335 | $speed = $speed*3.6; |
289 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
290 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
336 | + if ($speed < 1000) { |
|
337 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
341 | + } |
|
291 | 342 | } |
292 | 343 | } |
293 | 344 | |
294 | 345 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
295 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
296 | - else unset($timediff); |
|
346 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
347 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
348 | + } else { |
|
349 | + unset($timediff); |
|
350 | + } |
|
297 | 351 | if ($this->tmd > 5 || |
298 | 352 | !isset($timediff) || |
299 | 353 | $timediff > $globalLiveInterval || |
@@ -310,22 +364,32 @@ discard block |
||
310 | 364 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
311 | 365 | $this->all_tracked[$id]['putinarchive'] = true; |
312 | 366 | |
313 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
367 | + if ($globalDebug) { |
|
368 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
369 | + } |
|
314 | 370 | $timeelapsed = microtime(true); |
315 | 371 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
316 | 372 | $Marine = new Marine($this->db); |
317 | 373 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
318 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
374 | + if (!empty($all_country)) { |
|
375 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
376 | + } |
|
319 | 377 | $Marine->db = null; |
320 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
378 | + if ($globalDebugTimeElapsed) { |
|
379 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + } |
|
321 | 381 | } |
322 | 382 | $this->tmd = 0; |
323 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
383 | + if ($globalDebug) { |
|
384 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
385 | + } |
|
324 | 386 | } |
325 | 387 | } |
326 | 388 | |
327 | 389 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
328 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
390 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
391 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
392 | + } |
|
329 | 393 | 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') { |
330 | 394 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
331 | 395 | $dataFound = true; |
@@ -334,8 +398,12 @@ discard block |
||
334 | 398 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
335 | 399 | } |
336 | 400 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
337 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
338 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
401 | + if ($line['longitude'] > 180) { |
|
402 | + $line['longitude'] = $line['longitude'] - 360; |
|
403 | + } |
|
404 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
405 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
406 | + } |
|
339 | 407 | 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') { |
340 | 408 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
341 | 409 | $dataFound = true; |
@@ -353,7 +421,9 @@ discard block |
||
353 | 421 | } |
354 | 422 | } |
355 | 423 | if (isset($line['last_update']) && $line['last_update'] != '') { |
356 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
424 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
425 | + $dataFound = true; |
|
426 | + } |
|
357 | 427 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
358 | 428 | } |
359 | 429 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -367,15 +437,21 @@ discard block |
||
367 | 437 | } |
368 | 438 | |
369 | 439 | if (isset($line['heading']) && $line['heading'] != '') { |
370 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
440 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
441 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
442 | + } |
|
371 | 443 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
372 | 444 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
373 | 445 | //$dataFound = true; |
374 | 446 | } 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']) { |
375 | 447 | $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']); |
376 | 448 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
377 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
378 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
449 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
450 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
451 | + } |
|
452 | + if ($globalDebug) { |
|
453 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
454 | + } |
|
379 | 455 | } |
380 | 456 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
381 | 457 | |
@@ -387,23 +463,38 @@ discard block |
||
387 | 463 | 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'])) { |
388 | 464 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
389 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
390 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
466 | + if ($globalDebug) { |
|
467 | + echo "Check if vessel is already in DB..."; |
|
468 | + } |
|
391 | 469 | $timeelapsed = microtime(true); |
392 | 470 | $MarineLive = new MarineLive($this->db); |
393 | 471 | if (isset($line['id'])) { |
394 | 472 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
395 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
473 | + if ($globalDebugTimeElapsed) { |
|
474 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + } |
|
396 | 476 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
397 | 477 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
398 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
478 | + if ($globalDebugTimeElapsed) { |
|
479 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
480 | + } |
|
399 | 481 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
400 | 482 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
401 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
402 | - } else $recent_ident = ''; |
|
483 | + if ($globalDebugTimeElapsed) { |
|
484 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
485 | + } |
|
486 | + } else { |
|
487 | + $recent_ident = ''; |
|
488 | + } |
|
403 | 489 | $MarineLive->db=null; |
404 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
405 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
406 | - } else $recent_ident = ''; |
|
490 | + if ($globalDebug && $recent_ident == '') { |
|
491 | + echo " Not in DB.\n"; |
|
492 | + } elseif ($globalDebug && $recent_ident != '') { |
|
493 | + echo " Already in DB.\n"; |
|
494 | + } |
|
495 | + } else { |
|
496 | + $recent_ident = ''; |
|
497 | + } |
|
407 | 498 | } else { |
408 | 499 | $recent_ident = ''; |
409 | 500 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -412,32 +503,47 @@ discard block |
||
412 | 503 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
413 | 504 | { |
414 | 505 | if ($globalDebug) { |
415 | - if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
416 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
506 | + if ($this->all_tracked[$id]['mmsi'] == '') { |
|
507 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
508 | + } else { |
|
509 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
510 | + } |
|
417 | 511 | } |
418 | 512 | //adds the spotter data for the archive |
419 | 513 | $highlight = ''; |
420 | - 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'))); |
|
514 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
515 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
516 | + } |
|
421 | 517 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
422 | 518 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
423 | 519 | $timeelapsed = microtime(true); |
424 | 520 | $Marine = new Marine($this->db); |
425 | 521 | $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']); |
426 | 522 | $Marine->db = null; |
427 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
523 | + if ($globalDebug && isset($result)) { |
|
524 | + echo $result."\n"; |
|
525 | + } |
|
526 | + if ($globalDebugTimeElapsed) { |
|
527 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
528 | + } |
|
429 | 529 | } |
430 | 530 | } |
431 | 531 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
432 | 532 | // Add source stat in DB |
433 | 533 | $Stats = new Stats($this->db); |
434 | 534 | if (!empty($this->stats)) { |
435 | - if ($globalDebug) echo 'Add source stats : '; |
|
535 | + if ($globalDebug) { |
|
536 | + echo 'Add source stats : '; |
|
537 | + } |
|
436 | 538 | foreach($this->stats as $date => $data) { |
437 | 539 | foreach($data as $source => $sourced) { |
438 | 540 | //print_r($sourced); |
439 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
440 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
541 | + if (isset($sourced['polar'])) { |
|
542 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
543 | + } |
|
544 | + if (isset($sourced['hist'])) { |
|
545 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
546 | + } |
|
441 | 547 | if (isset($sourced['msg'])) { |
442 | 548 | if (time() - $sourced['msg']['date'] > 10) { |
443 | 549 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -450,7 +556,9 @@ discard block |
||
450 | 556 | unset($this->stats[$date]); |
451 | 557 | } |
452 | 558 | } |
453 | - if ($globalDebug) echo 'Done'."\n"; |
|
559 | + if ($globalDebug) { |
|
560 | + echo 'Done'."\n"; |
|
561 | + } |
|
454 | 562 | } |
455 | 563 | $Stats->db = null; |
456 | 564 | } |
@@ -460,13 +568,17 @@ discard block |
||
460 | 568 | $this->all_tracked[$id]['addedMarine'] = 1; |
461 | 569 | //print_r($this->all_tracked[$id]); |
462 | 570 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
463 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
571 | + if ($globalDebug) { |
|
572 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
573 | + } |
|
464 | 574 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
465 | 575 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
466 | 576 | $MarineLive = new MarineLive($this->db); |
467 | 577 | $MarineLive->deleteLiveMarineData(); |
468 | 578 | $MarineLive->db=null; |
469 | - if ($globalDebug) echo " Done\n"; |
|
579 | + if ($globalDebug) { |
|
580 | + echo " Done\n"; |
|
581 | + } |
|
470 | 582 | } |
471 | 583 | $this->last_delete = time(); |
472 | 584 | } |
@@ -492,15 +604,21 @@ discard block |
||
492 | 604 | |
493 | 605 | if (!$ignoreImport) { |
494 | 606 | 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'])) { |
495 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
607 | + if ($globalDebug) { |
|
608 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
609 | + } |
|
496 | 610 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
497 | 611 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
498 | 612 | $timeelapsed = microtime(true); |
499 | 613 | $MarineLive = new MarineLive($this->db); |
500 | 614 | $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']); |
501 | 615 | $MarineLive->db = null; |
502 | - if ($globalDebug) echo $result."\n"; |
|
503 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
616 | + if ($globalDebug) { |
|
617 | + echo $result."\n"; |
|
618 | + } |
|
619 | + if ($globalDebugTimeElapsed) { |
|
620 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
621 | + } |
|
504 | 622 | } |
505 | 623 | } |
506 | 624 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -512,7 +630,9 @@ discard block |
||
512 | 630 | |
513 | 631 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
514 | 632 | $source = $this->all_tracked[$id]['source_name']; |
515 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
633 | + if ($source == '') { |
|
634 | + $source = $this->all_tracked[$id]['format_source']; |
|
635 | + } |
|
516 | 636 | if (!isset($this->source_location[$source])) { |
517 | 637 | $Location = new Source($this->db); |
518 | 638 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -533,7 +653,9 @@ discard block |
||
533 | 653 | $stats_heading = round($stats_heading/22.5); |
534 | 654 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
535 | 655 | $current_date = date('Y-m-d'); |
536 | - if ($stats_heading == 16) $stats_heading = 0; |
|
656 | + if ($stats_heading == 16) { |
|
657 | + $stats_heading = 0; |
|
658 | + } |
|
537 | 659 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
538 | 660 | for ($i=0;$i<=15;$i++) { |
539 | 661 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -551,7 +673,9 @@ discard block |
||
551 | 673 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
552 | 674 | end($this->stats[$current_date][$source]['hist']); |
553 | 675 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
554 | - } else $mini = 0; |
|
676 | + } else { |
|
677 | + $mini = 0; |
|
678 | + } |
|
555 | 679 | for ($i=$mini;$i<=$distance;$i+=10) { |
556 | 680 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
557 | 681 | } |
@@ -563,19 +687,27 @@ discard block |
||
563 | 687 | |
564 | 688 | |
565 | 689 | $this->all_tracked[$id]['lastupdate'] = time(); |
566 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
567 | - } 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"; |
|
690 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
691 | + $send = true; |
|
692 | + } |
|
693 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
694 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
695 | + } |
|
568 | 696 | //$this->del(); |
569 | 697 | |
570 | 698 | |
571 | 699 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
572 | 700 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
573 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
701 | + if ($globalDebug) { |
|
702 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
703 | + } |
|
574 | 704 | $MarineLive = new MarineLive($this->db); |
575 | 705 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
576 | 706 | $MarineLive->db = null; |
577 | 707 | //MarineLive->deleteLiveMarineData(); |
578 | - if ($globalDebug) echo " Done\n"; |
|
708 | + if ($globalDebug) { |
|
709 | + echo " Done\n"; |
|
710 | + } |
|
579 | 711 | } |
580 | 712 | $this->last_delete_hourly = time(); |
581 | 713 | } |
@@ -584,7 +716,9 @@ discard block |
||
584 | 716 | //$ignoreImport = false; |
585 | 717 | } |
586 | 718 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
587 | - if ($send) return $this->all_tracked[$id]; |
|
719 | + if ($send) { |
|
720 | + return $this->all_tracked[$id]; |
|
721 | + } |
|
588 | 722 | } |
589 | 723 | } |
590 | 724 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | - * Executes the SQL statements to get the spotter information |
|
92 | - * |
|
93 | - * @param String $query the SQL query |
|
94 | - * @param Array $params parameter of the query |
|
95 | - * @param String $limitQuery the limit query |
|
96 | - * @return Array the spotter information |
|
97 | - * |
|
98 | - */ |
|
91 | + * Executes the SQL statements to get the spotter information |
|
92 | + * |
|
93 | + * @param String $query the SQL query |
|
94 | + * @param Array $params parameter of the query |
|
95 | + * @param String $limitQuery the limit query |
|
96 | + * @return Array the spotter information |
|
97 | + * |
|
98 | + */ |
|
99 | 99 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
100 | 100 | { |
101 | 101 | date_default_timezone_set('UTC'); |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets all the spotter information based on the latest data entry |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets all the spotter information based on the latest data entry |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
239 | 239 | { |
240 | 240 | global $global_query; |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Gets all the spotter information based on the callsign |
|
287 | - * |
|
288 | - * @return Array the spotter information |
|
289 | - * |
|
290 | - */ |
|
286 | + * Gets all the spotter information based on the callsign |
|
287 | + * |
|
288 | + * @return Array the spotter information |
|
289 | + * |
|
290 | + */ |
|
291 | 291 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
292 | 292 | { |
293 | 293 | global $global_query; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Gets all the marine information based on the type |
|
343 | - * |
|
344 | - * @return Array the marine information |
|
345 | - * |
|
346 | - */ |
|
342 | + * Gets all the marine information based on the type |
|
343 | + * |
|
344 | + * @return Array the marine information |
|
345 | + * |
|
346 | + */ |
|
347 | 347 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
348 | 348 | { |
349 | 349 | global $global_query; |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | |
452 | 452 | |
453 | 453 | /** |
454 | - * Gets all source name |
|
455 | - * |
|
456 | - * @param String type format of source |
|
457 | - * @return Array list of source name |
|
458 | - * |
|
459 | - */ |
|
454 | + * Gets all source name |
|
455 | + * |
|
456 | + * @param String type format of source |
|
457 | + * @return Array list of source name |
|
458 | + * |
|
459 | + */ |
|
460 | 460 | public function getAllSourceName($type = '',$filters = array()) |
461 | 461 | { |
462 | 462 | $filter_query = $this->getFilter($filters,true,true); |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | |
487 | 487 | |
488 | 488 | /** |
489 | - * Gets a list of all idents/callsigns |
|
490 | - * |
|
491 | - * @return Array list of ident/callsign names |
|
492 | - * |
|
493 | - */ |
|
489 | + * Gets a list of all idents/callsigns |
|
490 | + * |
|
491 | + * @return Array list of ident/callsign names |
|
492 | + * |
|
493 | + */ |
|
494 | 494 | public function getAllIdents($filters = array()) |
495 | 495 | { |
496 | 496 | $filter_query = $this->getFilter($filters,true,true); |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | - * Gets all info from a mmsi |
|
518 | - * |
|
519 | - * @return Array ident |
|
520 | - * |
|
521 | - */ |
|
517 | + * Gets all info from a mmsi |
|
518 | + * |
|
519 | + * @return Array ident |
|
520 | + * |
|
521 | + */ |
|
522 | 522 | public function getIdentity($mmsi) |
523 | 523 | { |
524 | 524 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -531,9 +531,9 @@ discard block |
||
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | - * Add identity |
|
535 | - * |
|
536 | - */ |
|
534 | + * Add identity |
|
535 | + * |
|
536 | + */ |
|
537 | 537 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
538 | 538 | { |
539 | 539 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
602 | - * Update ident tracker data |
|
603 | - * |
|
604 | - * @param String $fammarine_id the ID |
|
605 | - * @param String $ident the marine ident |
|
606 | - * @return String success or false |
|
607 | - * |
|
608 | - */ |
|
602 | + * Update ident tracker data |
|
603 | + * |
|
604 | + * @param String $fammarine_id the ID |
|
605 | + * @param String $ident the marine ident |
|
606 | + * @return String success or false |
|
607 | + * |
|
608 | + */ |
|
609 | 609 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
610 | 610 | { |
611 | 611 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | - * Update arrival marine data |
|
624 | - * |
|
625 | - * @param String $fammarine_id the ID |
|
626 | - * @param String $arrival_code the marine ident |
|
627 | - * @return String success or false |
|
628 | - * |
|
629 | - */ |
|
623 | + * Update arrival marine data |
|
624 | + * |
|
625 | + * @param String $fammarine_id the ID |
|
626 | + * @param String $arrival_code the marine ident |
|
627 | + * @return String success or false |
|
628 | + * |
|
629 | + */ |
|
630 | 630 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
631 | 631 | { |
632 | 632 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -641,19 +641,19 @@ discard block |
||
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
644 | - * Update Status data |
|
645 | - * |
|
646 | - * @param String $fammarine_id the ID |
|
647 | - * @param String $status_id the marine status id |
|
648 | - * @param String $status the marine status |
|
649 | - * @return String success or false |
|
650 | - * |
|
651 | - */ |
|
644 | + * Update Status data |
|
645 | + * |
|
646 | + * @param String $fammarine_id the ID |
|
647 | + * @param String $status_id the marine status id |
|
648 | + * @param String $status the marine status |
|
649 | + * @return String success or false |
|
650 | + * |
|
651 | + */ |
|
652 | 652 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
653 | 653 | { |
654 | 654 | |
655 | 655 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
656 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
656 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
657 | 657 | |
658 | 658 | try { |
659 | 659 | $sth = $this->db->prepare($query); |
@@ -666,17 +666,17 @@ discard block |
||
666 | 666 | |
667 | 667 | } |
668 | 668 | /** |
669 | - * Update latest marine data |
|
670 | - * |
|
671 | - * @param String $fammarine_id the ID |
|
672 | - * @param String $ident the marine ident |
|
673 | - * @return String success or false |
|
674 | - * |
|
675 | - */ |
|
669 | + * Update latest marine data |
|
670 | + * |
|
671 | + * @param String $fammarine_id the ID |
|
672 | + * @param String $ident the marine ident |
|
673 | + * @return String success or false |
|
674 | + * |
|
675 | + */ |
|
676 | 676 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
677 | 677 | { |
678 | 678 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
679 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
679 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
680 | 680 | |
681 | 681 | try { |
682 | 682 | $sth = $this->db->prepare($query); |
@@ -690,30 +690,30 @@ discard block |
||
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
693 | - * Adds a new spotter data |
|
694 | - * |
|
695 | - * @param String $fammarine_id the ID |
|
696 | - * @param String $ident the marine ident |
|
697 | - * @param String $departure_airport_icao the departure airport |
|
698 | - * @param String $arrival_airport_icao the arrival airport |
|
699 | - * @param String $latitude latitude of flight |
|
700 | - * @param String $longitude latitude of flight |
|
701 | - * @param String $waypoints waypoints of flight |
|
702 | - * @param String $heading heading of flight |
|
703 | - * @param String $groundspeed speed of flight |
|
704 | - * @param String $date date of flight |
|
705 | - * @param String $departure_airport_time departure time of flight |
|
706 | - * @param String $arrival_airport_time arrival time of flight |
|
707 | - * @param String $squawk squawk code of flight |
|
708 | - * @param String $route_stop route stop of flight |
|
709 | - * @param String $highlight highlight or not |
|
710 | - * @param String $ModeS ModesS code of flight |
|
711 | - * @param String $registration registration code of flight |
|
712 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
713 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
714 | - * @param String $verticalrate vertival rate of flight |
|
715 | - * @return String success or false |
|
716 | - */ |
|
693 | + * Adds a new spotter data |
|
694 | + * |
|
695 | + * @param String $fammarine_id the ID |
|
696 | + * @param String $ident the marine ident |
|
697 | + * @param String $departure_airport_icao the departure airport |
|
698 | + * @param String $arrival_airport_icao the arrival airport |
|
699 | + * @param String $latitude latitude of flight |
|
700 | + * @param String $longitude latitude of flight |
|
701 | + * @param String $waypoints waypoints of flight |
|
702 | + * @param String $heading heading of flight |
|
703 | + * @param String $groundspeed speed of flight |
|
704 | + * @param String $date date of flight |
|
705 | + * @param String $departure_airport_time departure time of flight |
|
706 | + * @param String $arrival_airport_time arrival time of flight |
|
707 | + * @param String $squawk squawk code of flight |
|
708 | + * @param String $route_stop route stop of flight |
|
709 | + * @param String $highlight highlight or not |
|
710 | + * @param String $ModeS ModesS code of flight |
|
711 | + * @param String $registration registration code of flight |
|
712 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
713 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
714 | + * @param String $verticalrate vertival rate of flight |
|
715 | + * @return String success or false |
|
716 | + */ |
|
717 | 717 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '') |
718 | 718 | { |
719 | 719 | global $globalURL, $globalMarineImageFetch; |
@@ -841,11 +841,11 @@ discard block |
||
841 | 841 | |
842 | 842 | |
843 | 843 | /** |
844 | - * Gets the aircraft ident within the last hour |
|
845 | - * |
|
846 | - * @return String the ident |
|
847 | - * |
|
848 | - */ |
|
844 | + * Gets the aircraft ident within the last hour |
|
845 | + * |
|
846 | + * @return String the ident |
|
847 | + * |
|
848 | + */ |
|
849 | 849 | public function getIdentFromLastHour($ident) |
850 | 850 | { |
851 | 851 | global $globalDBdriver, $globalTimezone; |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
862 | 862 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
863 | 863 | $query_data = array(':ident' => $ident); |
864 | - } |
|
864 | + } |
|
865 | 865 | |
866 | 866 | $sth = $this->db->prepare($query); |
867 | 867 | $sth->execute($query_data); |
868 | - $ident_result=''; |
|
868 | + $ident_result=''; |
|
869 | 869 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
870 | 870 | { |
871 | 871 | $ident_result = $row['ident']; |
@@ -876,11 +876,11 @@ discard block |
||
876 | 876 | |
877 | 877 | |
878 | 878 | /** |
879 | - * Gets the aircraft data from the last 20 seconds |
|
880 | - * |
|
881 | - * @return Array the spotter data |
|
882 | - * |
|
883 | - */ |
|
879 | + * Gets the aircraft data from the last 20 seconds |
|
880 | + * |
|
881 | + * @return Array the spotter data |
|
882 | + * |
|
883 | + */ |
|
884 | 884 | public function getRealTimeData($q = '') |
885 | 885 | { |
886 | 886 | global $globalDBdriver; |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | |
919 | 919 | |
920 | 920 | /** |
921 | - * Gets all number of flight over countries |
|
922 | - * |
|
923 | - * @return Array the airline country list |
|
924 | - * |
|
925 | - */ |
|
921 | + * Gets all number of flight over countries |
|
922 | + * |
|
923 | + * @return Array the airline country list |
|
924 | + * |
|
925 | + */ |
|
926 | 926 | |
927 | 927 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
928 | 928 | { |
@@ -995,11 +995,11 @@ discard block |
||
995 | 995 | |
996 | 996 | |
997 | 997 | /** |
998 | - * Gets all callsigns that have flown over |
|
999 | - * |
|
1000 | - * @return Array the callsign list |
|
1001 | - * |
|
1002 | - */ |
|
998 | + * Gets all callsigns that have flown over |
|
999 | + * |
|
1000 | + * @return Array the callsign list |
|
1001 | + * |
|
1002 | + */ |
|
1003 | 1003 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
1004 | 1004 | { |
1005 | 1005 | global $globalDBdriver; |
@@ -1066,11 +1066,11 @@ discard block |
||
1066 | 1066 | |
1067 | 1067 | |
1068 | 1068 | /** |
1069 | - * Counts all dates |
|
1070 | - * |
|
1071 | - * @return Array the date list |
|
1072 | - * |
|
1073 | - */ |
|
1069 | + * Counts all dates |
|
1070 | + * |
|
1071 | + * @return Array the date list |
|
1072 | + * |
|
1073 | + */ |
|
1074 | 1074 | public function countAllDates($filters = array()) |
1075 | 1075 | { |
1076 | 1076 | global $globalTimezone, $globalDBdriver; |
@@ -1116,11 +1116,11 @@ discard block |
||
1116 | 1116 | |
1117 | 1117 | |
1118 | 1118 | /** |
1119 | - * Counts all dates during the last 7 days |
|
1120 | - * |
|
1121 | - * @return Array the date list |
|
1122 | - * |
|
1123 | - */ |
|
1119 | + * Counts all dates during the last 7 days |
|
1120 | + * |
|
1121 | + * @return Array the date list |
|
1122 | + * |
|
1123 | + */ |
|
1124 | 1124 | public function countAllDatesLast7Days($filters = array()) |
1125 | 1125 | { |
1126 | 1126 | global $globalTimezone, $globalDBdriver; |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | $query .= " GROUP BY date_name |
1143 | 1143 | ORDER BY date_name ASC"; |
1144 | 1144 | $query_data = array(':offset' => $offset); |
1145 | - } |
|
1145 | + } |
|
1146 | 1146 | |
1147 | 1147 | $sth = $this->db->prepare($query); |
1148 | 1148 | $sth->execute($query_data); |
@@ -1162,11 +1162,11 @@ discard block |
||
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
1165 | - * Counts all dates during the last month |
|
1166 | - * |
|
1167 | - * @return Array the date list |
|
1168 | - * |
|
1169 | - */ |
|
1165 | + * Counts all dates during the last month |
|
1166 | + * |
|
1167 | + * @return Array the date list |
|
1168 | + * |
|
1169 | + */ |
|
1170 | 1170 | public function countAllDatesLastMonth($filters = array()) |
1171 | 1171 | { |
1172 | 1172 | global $globalTimezone, $globalDBdriver; |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | $query .= " GROUP BY date_name |
1189 | 1189 | ORDER BY date_name ASC"; |
1190 | 1190 | $query_data = array(':offset' => $offset); |
1191 | - } |
|
1191 | + } |
|
1192 | 1192 | |
1193 | 1193 | $sth = $this->db->prepare($query); |
1194 | 1194 | $sth->execute($query_data); |
@@ -1210,11 +1210,11 @@ discard block |
||
1210 | 1210 | |
1211 | 1211 | |
1212 | 1212 | /** |
1213 | - * Counts all month |
|
1214 | - * |
|
1215 | - * @return Array the month list |
|
1216 | - * |
|
1217 | - */ |
|
1213 | + * Counts all month |
|
1214 | + * |
|
1215 | + * @return Array the month list |
|
1216 | + * |
|
1217 | + */ |
|
1218 | 1218 | public function countAllMonths($filters = array()) |
1219 | 1219 | { |
1220 | 1220 | global $globalTimezone, $globalDBdriver; |
@@ -1259,11 +1259,11 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | |
1261 | 1261 | /** |
1262 | - * Counts all dates during the last year |
|
1263 | - * |
|
1264 | - * @return Array the date list |
|
1265 | - * |
|
1266 | - */ |
|
1262 | + * Counts all dates during the last year |
|
1263 | + * |
|
1264 | + * @return Array the date list |
|
1265 | + * |
|
1266 | + */ |
|
1267 | 1267 | public function countAllMonthsLastYear($filters) |
1268 | 1268 | { |
1269 | 1269 | global $globalTimezone, $globalDBdriver; |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | $query .= " GROUP BY year_name, month_name |
1286 | 1286 | ORDER BY year_name, month_name ASC"; |
1287 | 1287 | $query_data = array(':offset' => $offset); |
1288 | - } |
|
1288 | + } |
|
1289 | 1289 | |
1290 | 1290 | $sth = $this->db->prepare($query); |
1291 | 1291 | $sth->execute($query_data); |
@@ -1308,11 +1308,11 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | |
1310 | 1310 | /** |
1311 | - * Counts all hours |
|
1312 | - * |
|
1313 | - * @return Array the hour list |
|
1314 | - * |
|
1315 | - */ |
|
1311 | + * Counts all hours |
|
1312 | + * |
|
1313 | + * @return Array the hour list |
|
1314 | + * |
|
1315 | + */ |
|
1316 | 1316 | public function countAllHours($orderby,$filters = array()) |
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
@@ -1375,11 +1375,11 @@ discard block |
||
1375 | 1375 | |
1376 | 1376 | |
1377 | 1377 | /** |
1378 | - * Counts all hours by date |
|
1379 | - * |
|
1380 | - * @return Array the hour list |
|
1381 | - * |
|
1382 | - */ |
|
1378 | + * Counts all hours by date |
|
1379 | + * |
|
1380 | + * @return Array the hour list |
|
1381 | + * |
|
1382 | + */ |
|
1383 | 1383 | public function countAllHoursByDate($date, $filters = array()) |
1384 | 1384 | { |
1385 | 1385 | global $globalTimezone, $globalDBdriver; |
@@ -1423,11 +1423,11 @@ discard block |
||
1423 | 1423 | |
1424 | 1424 | |
1425 | 1425 | /** |
1426 | - * Counts all hours by a ident/callsign |
|
1427 | - * |
|
1428 | - * @return Array the hour list |
|
1429 | - * |
|
1430 | - */ |
|
1426 | + * Counts all hours by a ident/callsign |
|
1427 | + * |
|
1428 | + * @return Array the hour list |
|
1429 | + * |
|
1430 | + */ |
|
1431 | 1431 | public function countAllHoursByIdent($ident, $filters = array()) |
1432 | 1432 | { |
1433 | 1433 | global $globalTimezone, $globalDBdriver; |
@@ -1472,11 +1472,11 @@ discard block |
||
1472 | 1472 | |
1473 | 1473 | |
1474 | 1474 | /** |
1475 | - * Counts all vessels |
|
1476 | - * |
|
1477 | - * @return Integer the number of vessels |
|
1478 | - * |
|
1479 | - */ |
|
1475 | + * Counts all vessels |
|
1476 | + * |
|
1477 | + * @return Integer the number of vessels |
|
1478 | + * |
|
1479 | + */ |
|
1480 | 1480 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1481 | 1481 | { |
1482 | 1482 | global $globalDBdriver; |
@@ -1511,11 +1511,11 @@ discard block |
||
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | /** |
1514 | - * Counts all vessel type |
|
1515 | - * |
|
1516 | - * @return Integer the number of vessels |
|
1517 | - * |
|
1518 | - */ |
|
1514 | + * Counts all vessel type |
|
1515 | + * |
|
1516 | + * @return Integer the number of vessels |
|
1517 | + * |
|
1518 | + */ |
|
1519 | 1519 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1520 | 1520 | { |
1521 | 1521 | global $globalDBdriver; |
@@ -1550,11 +1550,11 @@ discard block |
||
1550 | 1550 | |
1551 | 1551 | |
1552 | 1552 | /** |
1553 | - * Counts all hours of today |
|
1554 | - * |
|
1555 | - * @return Array the hour list |
|
1556 | - * |
|
1557 | - */ |
|
1553 | + * Counts all hours of today |
|
1554 | + * |
|
1555 | + * @return Array the hour list |
|
1556 | + * |
|
1557 | + */ |
|
1558 | 1558 | public function countAllHoursFromToday($filters = array()) |
1559 | 1559 | { |
1560 | 1560 | global $globalTimezone, $globalDBdriver; |
@@ -1594,12 +1594,12 @@ discard block |
||
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | |
1597 | - /** |
|
1598 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1599 | - * |
|
1600 | - * @return Integer the Barrie Spotter ID |
|
1597 | + /** |
|
1598 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1599 | + * |
|
1600 | + * @return Integer the Barrie Spotter ID |
|
1601 | 1601 | q * |
1602 | - */ |
|
1602 | + */ |
|
1603 | 1603 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1604 | 1604 | { |
1605 | 1605 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1620,13 +1620,13 @@ discard block |
||
1620 | 1620 | |
1621 | 1621 | |
1622 | 1622 | /** |
1623 | - * Parses a date string |
|
1624 | - * |
|
1625 | - * @param String $dateString the date string |
|
1626 | - * @param String $timezone the timezone of a user |
|
1627 | - * @return Array the time information |
|
1628 | - * |
|
1629 | - */ |
|
1623 | + * Parses a date string |
|
1624 | + * |
|
1625 | + * @param String $dateString the date string |
|
1626 | + * @param String $timezone the timezone of a user |
|
1627 | + * @return Array the time information |
|
1628 | + * |
|
1629 | + */ |
|
1630 | 1630 | public function parseDateString($dateString, $timezone = '') |
1631 | 1631 | { |
1632 | 1632 | $time_array = array(); |
@@ -1659,12 +1659,12 @@ discard block |
||
1659 | 1659 | } |
1660 | 1660 | |
1661 | 1661 | /** |
1662 | - * Parses the direction degrees to working |
|
1663 | - * |
|
1664 | - * @param Float $direction the direction in degrees |
|
1665 | - * @return Array the direction information |
|
1666 | - * |
|
1667 | - */ |
|
1662 | + * Parses the direction degrees to working |
|
1663 | + * |
|
1664 | + * @param Float $direction the direction in degrees |
|
1665 | + * @return Array the direction information |
|
1666 | + * |
|
1667 | + */ |
|
1668 | 1668 | public function parseDirection($direction = 0) |
1669 | 1669 | { |
1670 | 1670 | if ($direction == '') $direction = 0; |
@@ -1743,12 +1743,12 @@ discard block |
||
1743 | 1743 | |
1744 | 1744 | |
1745 | 1745 | /** |
1746 | - * Gets Country from latitude/longitude |
|
1747 | - * |
|
1748 | - * @param Float $latitude latitute of the flight |
|
1749 | - * @param Float $longitude longitute of the flight |
|
1750 | - * @return String the countrie |
|
1751 | - */ |
|
1746 | + * Gets Country from latitude/longitude |
|
1747 | + * |
|
1748 | + * @param Float $latitude latitute of the flight |
|
1749 | + * @param Float $longitude longitute of the flight |
|
1750 | + * @return String the countrie |
|
1751 | + */ |
|
1752 | 1752 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1753 | 1753 | { |
1754 | 1754 | global $globalDBdriver, $globalDebug; |
@@ -1785,11 +1785,11 @@ discard block |
||
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | /** |
1788 | - * Gets Country from iso2 |
|
1789 | - * |
|
1790 | - * @param String $iso2 ISO2 country code |
|
1791 | - * @return String the countrie |
|
1792 | - */ |
|
1788 | + * Gets Country from iso2 |
|
1789 | + * |
|
1790 | + * @param String $iso2 ISO2 country code |
|
1791 | + * @return String the countrie |
|
1792 | + */ |
|
1793 | 1793 | public function getCountryFromISO2($iso2) |
1794 | 1794 | { |
1795 | 1795 | global $globalDBdriver, $globalDebug; |
@@ -1818,12 +1818,12 @@ discard block |
||
1818 | 1818 | |
1819 | 1819 | |
1820 | 1820 | /** |
1821 | - * Gets the short url from bit.ly |
|
1822 | - * |
|
1823 | - * @param String $url the full url |
|
1824 | - * @return String the bit.ly url |
|
1825 | - * |
|
1826 | - */ |
|
1821 | + * Gets the short url from bit.ly |
|
1822 | + * |
|
1823 | + * @param String $url the full url |
|
1824 | + * @return String the bit.ly url |
|
1825 | + * |
|
1826 | + */ |
|
1827 | 1827 | public function getBitlyURL($url) |
1828 | 1828 | { |
1829 | 1829 | global $globalBitlyAccessToken; |
@@ -1850,11 +1850,11 @@ discard block |
||
1850 | 1850 | |
1851 | 1851 | |
1852 | 1852 | /** |
1853 | - * Gets all vessels types that have flown over |
|
1854 | - * |
|
1855 | - * @return Array the vessel type list |
|
1856 | - * |
|
1857 | - */ |
|
1853 | + * Gets all vessels types that have flown over |
|
1854 | + * |
|
1855 | + * @return Array the vessel type list |
|
1856 | + * |
|
1857 | + */ |
|
1858 | 1858 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1859 | 1859 | { |
1860 | 1860 | global $globalDBdriver; |
@@ -1920,11 +1920,11 @@ discard block |
||
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | /** |
1923 | - * Gets all the tracker information |
|
1924 | - * |
|
1925 | - * @return Array the tracker information |
|
1926 | - * |
|
1927 | - */ |
|
1923 | + * Gets all the tracker information |
|
1924 | + * |
|
1925 | + * @return Array the tracker information |
|
1926 | + * |
|
1927 | + */ |
|
1928 | 1928 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1929 | 1929 | { |
1930 | 1930 | global $globalTimezone, $globalDBdriver; |