@@ -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; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
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' => '')); |
|
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' => '')); |
|
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']; |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | 150 | } |
151 | 151 | //print_r($identity); |
152 | 152 | unset($Marine); |
153 | 153 | //$dataFound = true; |
154 | - } |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //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'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
184 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
@@ -190,20 +190,20 @@ discard block |
||
190 | 190 | $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']); |
191 | 191 | $Marine->db = null; |
192 | 192 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
193 | - } |
|
193 | + } |
|
194 | 194 | } |
195 | - } |
|
196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
195 | + } |
|
196 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
200 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
200 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
201 | 201 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
202 | - } else { |
|
202 | + } else { |
|
203 | 203 | 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"; |
204 | 204 | 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"; |
205 | 205 | return ''; |
206 | - } |
|
206 | + } |
|
207 | 207 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
208 | 208 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
209 | 209 | return ''; |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | if (isset($line['speed'])) { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
225 | 225 | } 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'])) { |
226 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
227 | - if ($distance > 1000 && $distance < 10000) { |
|
226 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
227 | + if ($distance > 1000 && $distance < 10000) { |
|
228 | 228 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
229 | 229 | $speed = $speed*3.6; |
230 | 230 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
231 | 231 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
232 | - } |
|
232 | + } |
|
233 | 233 | } |
234 | 234 | |
235 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
237 | - else unset($timediff); |
|
238 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
235 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
236 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
237 | + else unset($timediff); |
|
238 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
239 | 239 | 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'])) { |
240 | - 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'])) { |
|
240 | + 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'])) { |
|
241 | 241 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
242 | 242 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
243 | 243 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -245,211 +245,211 @@ discard block |
||
245 | 245 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
248 | - $Marine = new Marine($this->db); |
|
249 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
250 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
251 | - $Marine->db = null; |
|
252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
248 | + $Marine = new Marine($this->db); |
|
249 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
250 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
251 | + $Marine->db = null; |
|
252 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
253 | 253 | } |
254 | 254 | $this->tmd = 0; |
255 | 255 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
256 | - } |
|
256 | + } |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
260 | 260 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
261 | 261 | 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') { |
262 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
263 | - $dataFound = true; |
|
264 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
262 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
263 | + $dataFound = true; |
|
264 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
265 | 265 | } |
266 | 266 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
267 | 267 | } |
268 | 268 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
269 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
270 | 270 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
271 | 271 | 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') { |
272 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
273 | - $dataFound = true; |
|
274 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
272 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
273 | + $dataFound = true; |
|
274 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
275 | 275 | } |
276 | 276 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
277 | 277 | } |
278 | 278 | |
279 | - } else if ($globalDebug && $timediff > 20) { |
|
279 | + } else if ($globalDebug && $timediff > 20) { |
|
280 | 280 | $this->tmd = $this->tmd + 1; |
281 | 281 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
282 | 282 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
283 | 283 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
284 | 284 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
285 | - } |
|
285 | + } |
|
286 | 286 | } |
287 | 287 | if (isset($line['last_update']) && $line['last_update'] != '') { |
288 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
289 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
288 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
289 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
290 | 290 | } |
291 | 291 | if (isset($line['format_source']) && $line['format_source'] != '') { |
292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
293 | 293 | } |
294 | 294 | if (isset($line['source_name']) && $line['source_name'] != '') { |
295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
296 | 296 | } |
297 | 297 | if (isset($line['status']) && $line['status'] != '') { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
299 | 299 | } |
300 | 300 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
302 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
302 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
303 | 303 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
304 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
304 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
305 | 305 | $Marine = new Marine($this->db); |
306 | 306 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
307 | 307 | unset($Marine); |
308 | - } |
|
308 | + } |
|
309 | + } |
|
309 | 310 | } |
310 | - } |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if (isset($line['heading']) && $line['heading'] != '') { |
318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
321 | - //$dataFound = true; |
|
318 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
321 | + //$dataFound = true; |
|
322 | 322 | } 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']) { |
323 | - $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']); |
|
324 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
323 | + $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']); |
|
324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
327 | 327 | } |
328 | 328 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
329 | 329 | |
330 | 330 | |
331 | 331 | |
332 | 332 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
333 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
334 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
335 | - 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'])) { |
|
336 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
333 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
334 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
335 | + 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'])) { |
|
336 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
337 | 337 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
338 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
339 | - $timeelapsed = microtime(true); |
|
340 | - $MarineLive = new MarineLive($this->db); |
|
341 | - if (isset($line['id'])) { |
|
338 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
339 | + $timeelapsed = microtime(true); |
|
340 | + $MarineLive = new MarineLive($this->db); |
|
341 | + if (isset($line['id'])) { |
|
342 | 342 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
343 | 343 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
344 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
344 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
345 | 345 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
346 | 346 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
347 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
347 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
348 | 348 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
349 | 349 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
350 | - } else $recent_ident = ''; |
|
351 | - $MarineLive->db=null; |
|
352 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
353 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
350 | + } else $recent_ident = ''; |
|
351 | + $MarineLive->db=null; |
|
352 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
353 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
354 | 354 | } else $recent_ident = ''; |
355 | - } else { |
|
355 | + } else { |
|
356 | 356 | $recent_ident = ''; |
357 | 357 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
358 | - } |
|
359 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
360 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | - { |
|
358 | + } |
|
359 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
360 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | + { |
|
362 | 362 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
363 | 363 | //adds the spotter data for the archive |
364 | - $highlight = ''; |
|
365 | - 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'))); |
|
366 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
364 | + $highlight = ''; |
|
365 | + 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'))); |
|
366 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
367 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
368 | - $timeelapsed = microtime(true); |
|
369 | - $Marine = new Marine($this->db); |
|
370 | - $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']); |
|
371 | - $Marine->db = null; |
|
372 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
368 | + $timeelapsed = microtime(true); |
|
369 | + $Marine = new Marine($this->db); |
|
370 | + $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']); |
|
371 | + $Marine->db = null; |
|
372 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
373 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
376 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
377 | 377 | // Add source stat in DB |
378 | 378 | $Stats = new Stats($this->db); |
379 | 379 | if (!empty($this->stats)) { |
380 | - if ($globalDebug) echo 'Add source stats : '; |
|
381 | - foreach($this->stats as $date => $data) { |
|
380 | + if ($globalDebug) echo 'Add source stats : '; |
|
381 | + foreach($this->stats as $date => $data) { |
|
382 | 382 | foreach($data as $source => $sourced) { |
383 | - //print_r($sourced); |
|
384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
386 | - if (isset($sourced['msg'])) { |
|
387 | - if (time() - $sourced['msg']['date'] > 10) { |
|
388 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
389 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
390 | - unset($this->stats[$date][$source]['msg']); |
|
391 | - } |
|
392 | - } |
|
393 | - } |
|
394 | - if ($date != date('Y-m-d')) { |
|
395 | - unset($this->stats[$date]); |
|
396 | - } |
|
397 | - } |
|
398 | - if ($globalDebug) echo 'Done'."\n"; |
|
383 | + //print_r($sourced); |
|
384 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
386 | + if (isset($sourced['msg'])) { |
|
387 | + if (time() - $sourced['msg']['date'] > 10) { |
|
388 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
389 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
390 | + unset($this->stats[$date][$source]['msg']); |
|
391 | + } |
|
392 | + } |
|
393 | + } |
|
394 | + if ($date != date('Y-m-d')) { |
|
395 | + unset($this->stats[$date]); |
|
396 | + } |
|
397 | + } |
|
398 | + if ($globalDebug) echo 'Done'."\n"; |
|
399 | 399 | } |
400 | 400 | $Stats->db = null; |
401 | - } |
|
401 | + } |
|
402 | 402 | |
403 | - $this->del(); |
|
403 | + $this->del(); |
|
404 | 404 | //$ignoreImport = false; |
405 | 405 | $this->all_tracked[$id]['addedMarine'] = 1; |
406 | 406 | //print_r($this->all_tracked[$id]); |
407 | 407 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
408 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
409 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
410 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
408 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
409 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
410 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
411 | 411 | $MarineLive = new MarineLive($this->db); |
412 | 412 | $MarineLive->deleteLiveMarineData(); |
413 | 413 | $MarineLive->db=null; |
414 | 414 | if ($globalDebug) echo " Done\n"; |
415 | - } |
|
416 | - $this->last_delete = time(); |
|
415 | + } |
|
416 | + $this->last_delete = time(); |
|
417 | 417 | } |
418 | - } elseif ($recent_ident != '') { |
|
418 | + } elseif ($recent_ident != '') { |
|
419 | 419 | $this->all_tracked[$id]['id'] = $recent_ident; |
420 | 420 | $this->all_tracked[$id]['addedMarine'] = 1; |
421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
422 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
422 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
423 | 423 | $Marine = new Marine($this->db); |
424 | 424 | $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']); |
425 | 425 | $Marine->db = null; |
426 | - } |
|
426 | + } |
|
427 | 427 | } |
428 | 428 | |
429 | - } |
|
429 | + } |
|
430 | + } |
|
430 | 431 | } |
431 | - } |
|
432 | - //adds the spotter LIVE data |
|
433 | - if ($globalDebug) { |
|
432 | + //adds the spotter LIVE data |
|
433 | + if ($globalDebug) { |
|
434 | 434 | 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"; |
435 | - } |
|
436 | - $ignoreImport = false; |
|
435 | + } |
|
436 | + $ignoreImport = false; |
|
437 | 437 | |
438 | - if (!$ignoreImport) { |
|
438 | + if (!$ignoreImport) { |
|
439 | 439 | 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'])) { |
440 | 440 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
441 | 441 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
442 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
443 | 443 | $timeelapsed = microtime(true); |
444 | 444 | $MarineLive = new MarineLive($this->db); |
445 | 445 | $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']); |
446 | 446 | $MarineLive->db = null; |
447 | 447 | if ($globalDebug) echo $result."\n"; |
448 | 448 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
449 | - } |
|
449 | + } |
|
450 | 450 | } |
451 | 451 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
452 | - $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']); |
|
452 | + $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']); |
|
453 | 453 | } |
454 | 454 | $this->all_tracked[$id]['putinarchive'] = false; |
455 | 455 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if ($stats_heading == 16) $stats_heading = 0; |
482 | 482 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
483 | 483 | for ($i=0;$i<=15;$i++) { |
484 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
484 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
485 | 485 | } |
486 | 486 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
487 | 487 | } else { |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | //var_dump($this->stats); |
495 | 495 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
496 | 496 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
497 | - end($this->stats[$current_date][$source]['hist']); |
|
498 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
497 | + end($this->stats[$current_date][$source]['hist']); |
|
498 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
499 | 499 | } else $mini = 0; |
500 | 500 | for ($i=$mini;$i<=$distance;$i+=10) { |
501 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
501 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
502 | 502 | } |
503 | 503 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
504 | 504 | } else { |
@@ -514,24 +514,24 @@ discard block |
||
514 | 514 | |
515 | 515 | |
516 | 516 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
517 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
517 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
518 | 518 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
519 | 519 | $MarineLive = new MarineLive($this->db); |
520 | 520 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
521 | 521 | $MarineLive->db = null; |
522 | 522 | //MarineLive->deleteLiveMarineData(); |
523 | 523 | if ($globalDebug) echo " Done\n"; |
524 | - } |
|
525 | - $this->last_delete_hourly = time(); |
|
524 | + } |
|
525 | + $this->last_delete_hourly = time(); |
|
526 | 526 | } |
527 | 527 | |
528 | - } |
|
529 | - //$ignoreImport = false; |
|
528 | + } |
|
529 | + //$ignoreImport = false; |
|
530 | 530 | } |
531 | 531 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
532 | 532 | if ($send) return $this->all_tracked[$id]; |
533 | - } |
|
533 | + } |
|
534 | + } |
|
534 | 535 | } |
535 | - } |
|
536 | 536 | } |
537 | 537 | ?> |
@@ -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; |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Executes the SQL statements to get the spotter information |
|
86 | - * |
|
87 | - * @param String $query the SQL query |
|
88 | - * @param Array $params parameter of the query |
|
89 | - * @param String $limitQuery the limit query |
|
90 | - * @return Array the spotter information |
|
91 | - * |
|
92 | - */ |
|
85 | + * Executes the SQL statements to get the spotter information |
|
86 | + * |
|
87 | + * @param String $query the SQL query |
|
88 | + * @param Array $params parameter of the query |
|
89 | + * @param String $limitQuery the limit query |
|
90 | + * @return Array the spotter information |
|
91 | + * |
|
92 | + */ |
|
93 | 93 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | /** |
220 | - * Gets all the spotter information based on the latest data entry |
|
221 | - * |
|
222 | - * @return Array the spotter information |
|
223 | - * |
|
224 | - */ |
|
220 | + * Gets all the spotter information based on the latest data entry |
|
221 | + * |
|
222 | + * @return Array the spotter information |
|
223 | + * |
|
224 | + */ |
|
225 | 225 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
226 | 226 | { |
227 | 227 | global $global_query; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Gets all the spotter information based on the callsign |
|
274 | - * |
|
275 | - * @return Array the spotter information |
|
276 | - * |
|
277 | - */ |
|
273 | + * Gets all the spotter information based on the callsign |
|
274 | + * |
|
275 | + * @return Array the spotter information |
|
276 | + * |
|
277 | + */ |
|
278 | 278 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
279 | 279 | { |
280 | 280 | global $global_query; |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | |
386 | 386 | |
387 | 387 | /** |
388 | - * Gets all source name |
|
389 | - * |
|
390 | - * @param String type format of source |
|
391 | - * @return Array list of source name |
|
392 | - * |
|
393 | - */ |
|
388 | + * Gets all source name |
|
389 | + * |
|
390 | + * @param String type format of source |
|
391 | + * @return Array list of source name |
|
392 | + * |
|
393 | + */ |
|
394 | 394 | public function getAllSourceName($type = '',$filters = array()) |
395 | 395 | { |
396 | 396 | $filter_query = $this->getFilter($filters,true,true); |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | |
421 | 421 | |
422 | 422 | /** |
423 | - * Gets a list of all idents/callsigns |
|
424 | - * |
|
425 | - * @return Array list of ident/callsign names |
|
426 | - * |
|
427 | - */ |
|
423 | + * Gets a list of all idents/callsigns |
|
424 | + * |
|
425 | + * @return Array list of ident/callsign names |
|
426 | + * |
|
427 | + */ |
|
428 | 428 | public function getAllIdents($filters = array()) |
429 | 429 | { |
430 | 430 | $filter_query = $this->getFilter($filters,true,true); |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
451 | - * Gets all info from a mmsi |
|
452 | - * |
|
453 | - * @return Array list of mmsi info |
|
454 | - * |
|
455 | - */ |
|
451 | + * Gets all info from a mmsi |
|
452 | + * |
|
453 | + * @return Array list of mmsi info |
|
454 | + * |
|
455 | + */ |
|
456 | 456 | public function getIdentity($mmsi) |
457 | 457 | { |
458 | 458 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
468 | - * Add identity |
|
469 | - * |
|
470 | - */ |
|
468 | + * Add identity |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
472 | 472 | { |
473 | 473 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
529 | - * Update ident tracker data |
|
530 | - * |
|
531 | - * @param String $fammarine_id the ID |
|
532 | - * @param String $ident the marine ident |
|
533 | - * @return String success or false |
|
534 | - * |
|
535 | - */ |
|
529 | + * Update ident tracker data |
|
530 | + * |
|
531 | + * @param String $fammarine_id the ID |
|
532 | + * @param String $ident the marine ident |
|
533 | + * @return String success or false |
|
534 | + * |
|
535 | + */ |
|
536 | 536 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
537 | 537 | { |
538 | 538 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -547,19 +547,19 @@ discard block |
||
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
550 | - * Update Status data |
|
551 | - * |
|
552 | - * @param String $fammarine_id the ID |
|
553 | - * @param String $status_id the marine status id |
|
554 | - * @param String $status the marine status |
|
555 | - * @return String success or false |
|
556 | - * |
|
557 | - */ |
|
550 | + * Update Status data |
|
551 | + * |
|
552 | + * @param String $fammarine_id the ID |
|
553 | + * @param String $status_id the marine status id |
|
554 | + * @param String $status the marine status |
|
555 | + * @return String success or false |
|
556 | + * |
|
557 | + */ |
|
558 | 558 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
559 | 559 | { |
560 | 560 | |
561 | 561 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
562 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
562 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
563 | 563 | |
564 | 564 | try { |
565 | 565 | $sth = $this->db->prepare($query); |
@@ -572,17 +572,17 @@ discard block |
||
572 | 572 | |
573 | 573 | } |
574 | 574 | /** |
575 | - * Update latest marine data |
|
576 | - * |
|
577 | - * @param String $fammarine_id the ID |
|
578 | - * @param String $ident the marine ident |
|
579 | - * @return String success or false |
|
580 | - * |
|
581 | - */ |
|
575 | + * Update latest marine data |
|
576 | + * |
|
577 | + * @param String $fammarine_id the ID |
|
578 | + * @param String $ident the marine ident |
|
579 | + * @return String success or false |
|
580 | + * |
|
581 | + */ |
|
582 | 582 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
583 | 583 | { |
584 | 584 | $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'; |
585 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
585 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
586 | 586 | |
587 | 587 | try { |
588 | 588 | $sth = $this->db->prepare($query); |
@@ -596,30 +596,30 @@ discard block |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
599 | - * Adds a new spotter data |
|
600 | - * |
|
601 | - * @param String $fammarine_id the ID |
|
602 | - * @param String $ident the marine ident |
|
603 | - * @param String $departure_airport_icao the departure airport |
|
604 | - * @param String $arrival_airport_icao the arrival airport |
|
605 | - * @param String $latitude latitude of flight |
|
606 | - * @param String $longitude latitude of flight |
|
607 | - * @param String $waypoints waypoints of flight |
|
608 | - * @param String $heading heading of flight |
|
609 | - * @param String $groundspeed speed of flight |
|
610 | - * @param String $date date of flight |
|
611 | - * @param String $departure_airport_time departure time of flight |
|
612 | - * @param String $arrival_airport_time arrival time of flight |
|
613 | - * @param String $squawk squawk code of flight |
|
614 | - * @param String $route_stop route stop of flight |
|
615 | - * @param String $highlight highlight or not |
|
616 | - * @param String $ModeS ModesS code of flight |
|
617 | - * @param String $registration registration code of flight |
|
618 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
619 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
620 | - * @param String $verticalrate vertival rate of flight |
|
621 | - * @return String success or false |
|
622 | - */ |
|
599 | + * Adds a new spotter data |
|
600 | + * |
|
601 | + * @param String $fammarine_id the ID |
|
602 | + * @param String $ident the marine ident |
|
603 | + * @param String $departure_airport_icao the departure airport |
|
604 | + * @param String $arrival_airport_icao the arrival airport |
|
605 | + * @param String $latitude latitude of flight |
|
606 | + * @param String $longitude latitude of flight |
|
607 | + * @param String $waypoints waypoints of flight |
|
608 | + * @param String $heading heading of flight |
|
609 | + * @param String $groundspeed speed of flight |
|
610 | + * @param String $date date of flight |
|
611 | + * @param String $departure_airport_time departure time of flight |
|
612 | + * @param String $arrival_airport_time arrival time of flight |
|
613 | + * @param String $squawk squawk code of flight |
|
614 | + * @param String $route_stop route stop of flight |
|
615 | + * @param String $highlight highlight or not |
|
616 | + * @param String $ModeS ModesS code of flight |
|
617 | + * @param String $registration registration code of flight |
|
618 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
619 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
620 | + * @param String $verticalrate vertival rate of flight |
|
621 | + * @return String success or false |
|
622 | + */ |
|
623 | 623 | 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 = '') |
624 | 624 | { |
625 | 625 | global $globalURL, $globalMarineImageFetch; |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | unset($Image); |
717 | 717 | } |
718 | 718 | |
719 | - if ($latitude == '' && $longitude == '') { |
|
720 | - $latitude = 0; |
|
721 | - $longitude = 0; |
|
722 | - } |
|
723 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
724 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
725 | - if ($arrival_date == '') $arrival_date = NULL; |
|
719 | + if ($latitude == '' && $longitude == '') { |
|
720 | + $latitude = 0; |
|
721 | + $longitude = 0; |
|
722 | + } |
|
723 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
724 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
725 | + if ($arrival_date == '') $arrival_date = NULL; |
|
726 | 726 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
727 | 727 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
728 | 728 | |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $sth->execute($query_values); |
734 | 734 | $this->db = null; |
735 | 735 | } catch (PDOException $e) { |
736 | - return "error : ".$e->getMessage(); |
|
736 | + return "error : ".$e->getMessage(); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | return "success"; |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | |
743 | 743 | |
744 | 744 | /** |
745 | - * Gets the aircraft ident within the last hour |
|
746 | - * |
|
747 | - * @return String the ident |
|
748 | - * |
|
749 | - */ |
|
745 | + * Gets the aircraft ident within the last hour |
|
746 | + * |
|
747 | + * @return String the ident |
|
748 | + * |
|
749 | + */ |
|
750 | 750 | public function getIdentFromLastHour($ident) |
751 | 751 | { |
752 | 752 | global $globalDBdriver, $globalTimezone; |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
763 | 763 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
764 | 764 | $query_data = array(':ident' => $ident); |
765 | - } |
|
765 | + } |
|
766 | 766 | |
767 | 767 | $sth = $this->db->prepare($query); |
768 | 768 | $sth->execute($query_data); |
769 | - $ident_result=''; |
|
769 | + $ident_result=''; |
|
770 | 770 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
771 | 771 | { |
772 | 772 | $ident_result = $row['ident']; |
@@ -777,11 +777,11 @@ discard block |
||
777 | 777 | |
778 | 778 | |
779 | 779 | /** |
780 | - * Gets the aircraft data from the last 20 seconds |
|
781 | - * |
|
782 | - * @return Array the spotter data |
|
783 | - * |
|
784 | - */ |
|
780 | + * Gets the aircraft data from the last 20 seconds |
|
781 | + * |
|
782 | + * @return Array the spotter data |
|
783 | + * |
|
784 | + */ |
|
785 | 785 | public function getRealTimeData($q = '') |
786 | 786 | { |
787 | 787 | global $globalDBdriver; |
@@ -819,11 +819,11 @@ discard block |
||
819 | 819 | |
820 | 820 | |
821 | 821 | /** |
822 | - * Gets all number of flight over countries |
|
823 | - * |
|
824 | - * @return Array the airline country list |
|
825 | - * |
|
826 | - */ |
|
822 | + * Gets all number of flight over countries |
|
823 | + * |
|
824 | + * @return Array the airline country list |
|
825 | + * |
|
826 | + */ |
|
827 | 827 | |
828 | 828 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
829 | 829 | { |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | |
897 | 897 | |
898 | 898 | /** |
899 | - * Gets all callsigns that have flown over |
|
900 | - * |
|
901 | - * @return Array the callsign list |
|
902 | - * |
|
903 | - */ |
|
899 | + * Gets all callsigns that have flown over |
|
900 | + * |
|
901 | + * @return Array the callsign list |
|
902 | + * |
|
903 | + */ |
|
904 | 904 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
905 | 905 | { |
906 | 906 | global $globalDBdriver; |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | |
968 | 968 | |
969 | 969 | /** |
970 | - * Counts all dates |
|
971 | - * |
|
972 | - * @return Array the date list |
|
973 | - * |
|
974 | - */ |
|
970 | + * Counts all dates |
|
971 | + * |
|
972 | + * @return Array the date list |
|
973 | + * |
|
974 | + */ |
|
975 | 975 | public function countAllDates($filters = array()) |
976 | 976 | { |
977 | 977 | global $globalTimezone, $globalDBdriver; |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | /** |
1020 | - * Counts all dates during the last 7 days |
|
1021 | - * |
|
1022 | - * @return Array the date list |
|
1023 | - * |
|
1024 | - */ |
|
1020 | + * Counts all dates during the last 7 days |
|
1021 | + * |
|
1022 | + * @return Array the date list |
|
1023 | + * |
|
1024 | + */ |
|
1025 | 1025 | public function countAllDatesLast7Days($filters = array()) |
1026 | 1026 | { |
1027 | 1027 | global $globalTimezone, $globalDBdriver; |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $query .= " GROUP BY date_name |
1044 | 1044 | ORDER BY date_name ASC"; |
1045 | 1045 | $query_data = array(':offset' => $offset); |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute($query_data); |
@@ -1063,11 +1063,11 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | /** |
1066 | - * Counts all dates during the last month |
|
1067 | - * |
|
1068 | - * @return Array the date list |
|
1069 | - * |
|
1070 | - */ |
|
1066 | + * Counts all dates during the last month |
|
1067 | + * |
|
1068 | + * @return Array the date list |
|
1069 | + * |
|
1070 | + */ |
|
1071 | 1071 | public function countAllDatesLastMonth($filters = array()) |
1072 | 1072 | { |
1073 | 1073 | global $globalTimezone, $globalDBdriver; |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | $query .= " GROUP BY date_name |
1090 | 1090 | ORDER BY date_name ASC"; |
1091 | 1091 | $query_data = array(':offset' => $offset); |
1092 | - } |
|
1092 | + } |
|
1093 | 1093 | |
1094 | 1094 | $sth = $this->db->prepare($query); |
1095 | 1095 | $sth->execute($query_data); |
@@ -1111,11 +1111,11 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | /** |
1114 | - * Counts all month |
|
1115 | - * |
|
1116 | - * @return Array the month list |
|
1117 | - * |
|
1118 | - */ |
|
1114 | + * Counts all month |
|
1115 | + * |
|
1116 | + * @return Array the month list |
|
1117 | + * |
|
1118 | + */ |
|
1119 | 1119 | public function countAllMonths($filters = array()) |
1120 | 1120 | { |
1121 | 1121 | global $globalTimezone, $globalDBdriver; |
@@ -1160,11 +1160,11 @@ discard block |
||
1160 | 1160 | |
1161 | 1161 | |
1162 | 1162 | /** |
1163 | - * Counts all dates during the last year |
|
1164 | - * |
|
1165 | - * @return Array the date list |
|
1166 | - * |
|
1167 | - */ |
|
1163 | + * Counts all dates during the last year |
|
1164 | + * |
|
1165 | + * @return Array the date list |
|
1166 | + * |
|
1167 | + */ |
|
1168 | 1168 | public function countAllMonthsLastYear($filters) |
1169 | 1169 | { |
1170 | 1170 | global $globalTimezone, $globalDBdriver; |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $query .= " GROUP BY year_name, month_name |
1187 | 1187 | ORDER BY year_name, month_name ASC"; |
1188 | 1188 | $query_data = array(':offset' => $offset); |
1189 | - } |
|
1189 | + } |
|
1190 | 1190 | |
1191 | 1191 | $sth = $this->db->prepare($query); |
1192 | 1192 | $sth->execute($query_data); |
@@ -1209,11 +1209,11 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | |
1211 | 1211 | /** |
1212 | - * Counts all hours |
|
1213 | - * |
|
1214 | - * @return Array the hour list |
|
1215 | - * |
|
1216 | - */ |
|
1212 | + * Counts all hours |
|
1213 | + * |
|
1214 | + * @return Array the hour list |
|
1215 | + * |
|
1216 | + */ |
|
1217 | 1217 | public function countAllHours($orderby,$filters = array()) |
1218 | 1218 | { |
1219 | 1219 | global $globalTimezone, $globalDBdriver; |
@@ -1276,11 +1276,11 @@ discard block |
||
1276 | 1276 | |
1277 | 1277 | |
1278 | 1278 | /** |
1279 | - * Counts all hours by date |
|
1280 | - * |
|
1281 | - * @return Array the hour list |
|
1282 | - * |
|
1283 | - */ |
|
1279 | + * Counts all hours by date |
|
1280 | + * |
|
1281 | + * @return Array the hour list |
|
1282 | + * |
|
1283 | + */ |
|
1284 | 1284 | public function countAllHoursByDate($date, $filters = array()) |
1285 | 1285 | { |
1286 | 1286 | global $globalTimezone, $globalDBdriver; |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | |
1325 | 1325 | |
1326 | 1326 | /** |
1327 | - * Counts all hours by a ident/callsign |
|
1328 | - * |
|
1329 | - * @return Array the hour list |
|
1330 | - * |
|
1331 | - */ |
|
1327 | + * Counts all hours by a ident/callsign |
|
1328 | + * |
|
1329 | + * @return Array the hour list |
|
1330 | + * |
|
1331 | + */ |
|
1332 | 1332 | public function countAllHoursByIdent($ident, $filters = array()) |
1333 | 1333 | { |
1334 | 1334 | global $globalTimezone, $globalDBdriver; |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | |
1374 | 1374 | |
1375 | 1375 | /** |
1376 | - * Counts all vessels |
|
1377 | - * |
|
1378 | - * @return Integer the number of vessels |
|
1379 | - * |
|
1380 | - */ |
|
1376 | + * Counts all vessels |
|
1377 | + * |
|
1378 | + * @return Integer the number of vessels |
|
1379 | + * |
|
1380 | + */ |
|
1381 | 1381 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1382 | 1382 | { |
1383 | 1383 | global $globalDBdriver; |
@@ -1412,11 +1412,11 @@ discard block |
||
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
1415 | - * Counts all vessel type |
|
1416 | - * |
|
1417 | - * @return Integer the number of vessels |
|
1418 | - * |
|
1419 | - */ |
|
1415 | + * Counts all vessel type |
|
1416 | + * |
|
1417 | + * @return Integer the number of vessels |
|
1418 | + * |
|
1419 | + */ |
|
1420 | 1420 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1421 | 1421 | { |
1422 | 1422 | global $globalDBdriver; |
@@ -1451,11 +1451,11 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | |
1453 | 1453 | /** |
1454 | - * Counts all hours of today |
|
1455 | - * |
|
1456 | - * @return Array the hour list |
|
1457 | - * |
|
1458 | - */ |
|
1454 | + * Counts all hours of today |
|
1455 | + * |
|
1456 | + * @return Array the hour list |
|
1457 | + * |
|
1458 | + */ |
|
1459 | 1459 | public function countAllHoursFromToday($filters = array()) |
1460 | 1460 | { |
1461 | 1461 | global $globalTimezone, $globalDBdriver; |
@@ -1495,12 +1495,12 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | |
1498 | - /** |
|
1499 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1500 | - * |
|
1501 | - * @return Integer the Barrie Spotter ID |
|
1498 | + /** |
|
1499 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1500 | + * |
|
1501 | + * @return Integer the Barrie Spotter ID |
|
1502 | 1502 | q * |
1503 | - */ |
|
1503 | + */ |
|
1504 | 1504 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1505 | 1505 | { |
1506 | 1506 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1521,13 +1521,13 @@ discard block |
||
1521 | 1521 | |
1522 | 1522 | |
1523 | 1523 | /** |
1524 | - * Parses a date string |
|
1525 | - * |
|
1526 | - * @param String $dateString the date string |
|
1527 | - * @param String $timezone the timezone of a user |
|
1528 | - * @return Array the time information |
|
1529 | - * |
|
1530 | - */ |
|
1524 | + * Parses a date string |
|
1525 | + * |
|
1526 | + * @param String $dateString the date string |
|
1527 | + * @param String $timezone the timezone of a user |
|
1528 | + * @return Array the time information |
|
1529 | + * |
|
1530 | + */ |
|
1531 | 1531 | public function parseDateString($dateString, $timezone = '') |
1532 | 1532 | { |
1533 | 1533 | $time_array = array(); |
@@ -1560,12 +1560,12 @@ discard block |
||
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | /** |
1563 | - * Parses the direction degrees to working |
|
1564 | - * |
|
1565 | - * @param Float $direction the direction in degrees |
|
1566 | - * @return Array the direction information |
|
1567 | - * |
|
1568 | - */ |
|
1563 | + * Parses the direction degrees to working |
|
1564 | + * |
|
1565 | + * @param Float $direction the direction in degrees |
|
1566 | + * @return Array the direction information |
|
1567 | + * |
|
1568 | + */ |
|
1569 | 1569 | public function parseDirection($direction = 0) |
1570 | 1570 | { |
1571 | 1571 | if ($direction == '') $direction = 0; |
@@ -1644,12 +1644,12 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | |
1646 | 1646 | /** |
1647 | - * Gets Country from latitude/longitude |
|
1648 | - * |
|
1649 | - * @param Float $latitude latitute of the flight |
|
1650 | - * @param Float $longitude longitute of the flight |
|
1651 | - * @return String the countrie |
|
1652 | - */ |
|
1647 | + * Gets Country from latitude/longitude |
|
1648 | + * |
|
1649 | + * @param Float $latitude latitute of the flight |
|
1650 | + * @param Float $longitude longitute of the flight |
|
1651 | + * @return String the countrie |
|
1652 | + */ |
|
1653 | 1653 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1654 | 1654 | { |
1655 | 1655 | global $globalDBdriver, $globalDebug; |
@@ -1686,11 +1686,11 @@ discard block |
||
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | /** |
1689 | - * Gets Country from iso2 |
|
1690 | - * |
|
1691 | - * @param String $iso2 ISO2 country code |
|
1692 | - * @return String the countrie |
|
1693 | - */ |
|
1689 | + * Gets Country from iso2 |
|
1690 | + * |
|
1691 | + * @param String $iso2 ISO2 country code |
|
1692 | + * @return String the countrie |
|
1693 | + */ |
|
1694 | 1694 | public function getCountryFromISO2($iso2) |
1695 | 1695 | { |
1696 | 1696 | global $globalDBdriver, $globalDebug; |
@@ -1719,12 +1719,12 @@ discard block |
||
1719 | 1719 | |
1720 | 1720 | |
1721 | 1721 | /** |
1722 | - * Gets the short url from bit.ly |
|
1723 | - * |
|
1724 | - * @param String $url the full url |
|
1725 | - * @return String the bit.ly url |
|
1726 | - * |
|
1727 | - */ |
|
1722 | + * Gets the short url from bit.ly |
|
1723 | + * |
|
1724 | + * @param String $url the full url |
|
1725 | + * @return String the bit.ly url |
|
1726 | + * |
|
1727 | + */ |
|
1728 | 1728 | public function getBitlyURL($url) |
1729 | 1729 | { |
1730 | 1730 | global $globalBitlyAccessToken; |
@@ -1751,11 +1751,11 @@ discard block |
||
1751 | 1751 | |
1752 | 1752 | |
1753 | 1753 | /** |
1754 | - * Gets all vessels types that have flown over |
|
1755 | - * |
|
1756 | - * @return Array the vessel type list |
|
1757 | - * |
|
1758 | - */ |
|
1754 | + * Gets all vessels types that have flown over |
|
1755 | + * |
|
1756 | + * @return Array the vessel type list |
|
1757 | + * |
|
1758 | + */ |
|
1759 | 1759 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1760 | 1760 | { |
1761 | 1761 | global $globalDBdriver; |
@@ -1820,11 +1820,11 @@ discard block |
||
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | /** |
1823 | - * Gets all the tracker information |
|
1824 | - * |
|
1825 | - * @return Array the tracker information |
|
1826 | - * |
|
1827 | - */ |
|
1823 | + * Gets all the tracker information |
|
1824 | + * |
|
1825 | + * @return Array the tracker information |
|
1826 | + * |
|
1827 | + */ |
|
1828 | 1828 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1829 | 1829 | { |
1830 | 1830 | global $globalTimezone, $globalDBdriver; |