@@ -5,7 +5,9 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Route by Airport"); |
7 | 7 | require_once('header.php'); |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | include('statistics-sub-menu.php'); |
10 | 12 | |
11 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -72,8 +72,11 @@ discard block |
||
72 | 72 | $globalDBSname = $globalDBname; |
73 | 73 | $globalDBSuser = $globalDBuser; |
74 | 74 | $globalDBSpass = $globalDBpass; |
75 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
76 | - else $globalDBSport = $globalDBport; |
|
75 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
76 | + $globalDBSport = 3306; |
|
77 | + } else { |
|
78 | + $globalDBSport = $globalDBport; |
|
79 | + } |
|
77 | 80 | } else { |
78 | 81 | $DBname = 'default'; |
79 | 82 | $globalDBSdriver = $globalDBdriver; |
@@ -81,8 +84,11 @@ discard block |
||
81 | 84 | $globalDBSname = $globalDBname; |
82 | 85 | $globalDBSuser = $user; |
83 | 86 | $globalDBSpass = $pass; |
84 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
85 | - else $globalDBSport = $globalDBport; |
|
87 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
88 | + $globalDBSport = 3306; |
|
89 | + } else { |
|
90 | + $globalDBSport = $globalDBport; |
|
91 | + } |
|
86 | 92 | } |
87 | 93 | } else { |
88 | 94 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -90,11 +96,16 @@ discard block |
||
90 | 96 | $globalDBSname = $globalDB[$DBname]['name']; |
91 | 97 | $globalDBSuser = $globalDB[$DBname]['user']; |
92 | 98 | $globalDBSpass = $globalDB[$DBname]['pass']; |
93 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
94 | - else $globalDBSport = 3306; |
|
99 | + if (isset($globalDB[$DBname]['port'])) { |
|
100 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
101 | + } else { |
|
102 | + $globalDBSport = 3306; |
|
103 | + } |
|
95 | 104 | } |
96 | 105 | // Set number of try to connect to DB |
97 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
106 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
107 | + $globalDBretry = 5; |
|
108 | + } |
|
98 | 109 | $i = 0; |
99 | 110 | while (true) { |
100 | 111 | try { |
@@ -103,10 +114,16 @@ discard block |
||
103 | 114 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
104 | 115 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
105 | 116 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
106 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
107 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
108 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
117 | + if (!isset($globalDBTimeOut)) { |
|
118 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
119 | + } else { |
|
120 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
121 | + } |
|
122 | + if (!isset($globalDBPersistent)) { |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
124 | + } else { |
|
125 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
126 | + } |
|
110 | 127 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
111 | 128 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
112 | 129 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -120,23 +137,35 @@ discard block |
||
120 | 137 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
121 | 138 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
122 | 139 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
123 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
124 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
140 | + if (!isset($globalDBTimeOut)) { |
|
141 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
142 | + } else { |
|
143 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
144 | + } |
|
145 | + if (!isset($globalDBPersistent)) { |
|
146 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
147 | + } else { |
|
148 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
149 | + } |
|
127 | 150 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
128 | 151 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
129 | 152 | } |
130 | 153 | break; |
131 | 154 | } catch(PDOException $e) { |
132 | 155 | $i++; |
133 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
156 | + if (isset($globalDebug) && $globalDebug) { |
|
157 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
158 | + } |
|
134 | 159 | //exit; |
135 | - if ($i > $globalDBretry) return false; |
|
160 | + if ($i > $globalDBretry) { |
|
161 | + return false; |
|
162 | + } |
|
136 | 163 | //return false; |
137 | 164 | } |
138 | 165 | } |
139 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
166 | + if ($DBname === 'default') { |
|
167 | + $this->db = $this->dbs['default']; |
|
168 | + } |
|
140 | 169 | return true; |
141 | 170 | } |
142 | 171 | |
@@ -148,7 +177,9 @@ discard block |
||
148 | 177 | } else { |
149 | 178 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
150 | 179 | } |
151 | - if ($this->db == NULL) return false; |
|
180 | + if ($this->db == NULL) { |
|
181 | + return false; |
|
182 | + } |
|
152 | 183 | try { |
153 | 184 | //$Connection = new Connection(); |
154 | 185 | $results = $this->db->query($query); |
@@ -157,21 +188,28 @@ discard block |
||
157 | 188 | } |
158 | 189 | if($results->rowCount()>0) { |
159 | 190 | return true; |
191 | + } else { |
|
192 | + return false; |
|
160 | 193 | } |
161 | - else return false; |
|
162 | 194 | } |
163 | 195 | |
164 | 196 | public function connectionExists() |
165 | 197 | { |
166 | 198 | global $globalDBdriver, $globalDBCheckConnection; |
167 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
199 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
200 | + return true; |
|
201 | + } |
|
168 | 202 | $query = "SELECT 1 + 1"; |
169 | - if ($this->db === null) return false; |
|
203 | + if ($this->db === null) { |
|
204 | + return false; |
|
205 | + } |
|
170 | 206 | try { |
171 | 207 | $sum = @$this->db->query($query); |
172 | 208 | if ($sum instanceof \PDOStatement) { |
173 | 209 | $sum = $sum->fetchColumn(0); |
174 | - } else $sum = 0; |
|
210 | + } else { |
|
211 | + $sum = 0; |
|
212 | + } |
|
175 | 213 | if (intval($sum) !== 2) { |
176 | 214 | return false; |
177 | 215 | } |
@@ -206,8 +244,9 @@ discard block |
||
206 | 244 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
207 | 245 | if($nb[0]['nb'] > 0) { |
208 | 246 | return true; |
247 | + } else { |
|
248 | + return false; |
|
209 | 249 | } |
210 | - else return false; |
|
211 | 250 | } |
212 | 251 | |
213 | 252 | /* |
@@ -257,9 +296,12 @@ discard block |
||
257 | 296 | } |
258 | 297 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
259 | 298 | $sth->closeCursor(); |
260 | - if ($result['nb'] > 0) return true; |
|
261 | - else return false; |
|
262 | -/* } else { |
|
299 | + if ($result['nb'] > 0) { |
|
300 | + return true; |
|
301 | + } else { |
|
302 | + return false; |
|
303 | + } |
|
304 | + /* } else { |
|
263 | 305 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
264 | 306 | try { |
265 | 307 | $results = $this->db->query($query); |
@@ -298,7 +340,9 @@ discard block |
||
298 | 340 | $sth->closeCursor(); |
299 | 341 | return $result['value']; |
300 | 342 | } |
301 | - } else return $version; |
|
343 | + } else { |
|
344 | + return $version; |
|
345 | + } |
|
302 | 346 | } |
303 | 347 | |
304 | 348 | /* |
@@ -307,9 +351,14 @@ discard block |
||
307 | 351 | */ |
308 | 352 | public function latest() { |
309 | 353 | global $globalNoDB; |
310 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
311 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
312 | - else return false; |
|
354 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
355 | + return true; |
|
356 | + } |
|
357 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
358 | + return true; |
|
359 | + } else { |
|
360 | + return false; |
|
361 | + } |
|
313 | 362 | } |
314 | 363 | |
315 | 364 | } |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
4 | -if ($date == '') $date = date('Y-m-d'); |
|
4 | +if ($date == '') { |
|
5 | + $date = date('Y-m-d'); |
|
6 | +} |
|
5 | 7 | header('Location: '.$globalURL.'/incident/'.$date); |
6 | 8 | ?> |
7 | 9 | \ No newline at end of file |
@@ -5,8 +5,11 @@ discard block |
||
5 | 5 | setcookie("MapFormat",'2d'); |
6 | 6 | |
7 | 7 | // Compressed GeoJson is used if true |
8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
9 | -else $compress = $globalJsonCompress; |
|
8 | +if (!isset($globalJsonCompress)) { |
|
9 | + $compress = true; |
|
10 | +} else { |
|
11 | + $compress = $globalJsonCompress; |
|
12 | +} |
|
10 | 13 | ?> |
11 | 14 | |
12 | 15 | |
@@ -142,9 +145,13 @@ discard block |
||
142 | 145 | if (callsign != ""){ markerMarineLabel += callsign; } |
143 | 146 | if (type != ""){ markerMarineLabel += ' - '+type; } |
144 | 147 | <?php |
145 | - if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
146 | - elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor; |
|
147 | - else $MarineIconColor = '1a3151'; |
|
148 | + if (isset($_COOKIE['MarineIconColor'])) { |
|
149 | + $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
150 | + } elseif (isset($globalMarineIconColor)) { |
|
151 | + $MarineIconColor = $globalMarineIconColor; |
|
152 | + } else { |
|
153 | + $MarineIconColor = '1a3151'; |
|
154 | + } |
|
148 | 155 | if (!isset($ident) && !isset($fammarine_id)) { |
149 | 156 | ?> |
150 | 157 | info_marine_update(feature.properties.fc); |
@@ -179,7 +186,12 @@ discard block |
||
179 | 186 | <?php |
180 | 187 | } else { |
181 | 188 | ?> |
182 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
189 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
190 | + print $archiveupdatetime*1000; |
|
191 | +} else { |
|
192 | + print $globalMapRefresh*1000+20000; |
|
193 | +} |
|
194 | +?>+feature.properties.sqt*1000); |
|
183 | 195 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
184 | 196 | <?php |
185 | 197 | } |
@@ -228,7 +240,12 @@ discard block |
||
228 | 240 | <?php |
229 | 241 | } else { |
230 | 242 | ?> |
231 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
243 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
244 | + print $archiveupdatetime*1000; |
|
245 | +} else { |
|
246 | + print $globalMapRefresh*1000+20000; |
|
247 | +} |
|
248 | +?>+feature.properties.sqt*1000); |
|
232 | 249 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
233 | 250 | <?php |
234 | 251 | } |
@@ -276,7 +293,12 @@ discard block |
||
276 | 293 | <?php |
277 | 294 | } else { |
278 | 295 | ?> |
279 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
296 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
297 | + print $archiveupdatetime*1000; |
|
298 | +} else { |
|
299 | + print $globalMapRefresh*1000+20000; |
|
300 | +} |
|
301 | +?>+feature.properties.sqt*1000); |
|
280 | 302 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
281 | 303 | <?php |
282 | 304 | } |
@@ -559,14 +581,24 @@ discard block |
||
559 | 581 | if (isset($archive) && $archive) { |
560 | 582 | ?> |
561 | 583 | //then load it again every 30 seconds |
562 | -// var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
584 | +// var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) { |
|
585 | + print ($globalMapRefresh*1000)/2; |
|
586 | +} else { |
|
587 | + print '15000'; |
|
588 | +} |
|
589 | +?>); |
|
563 | 590 | reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>); |
564 | 591 | <?php |
565 | 592 | } else { |
566 | 593 | ?> |
567 | 594 | //then load it again every 30 seconds |
568 | 595 | reloadMarinePage = setInterval( |
569 | - function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
596 | + function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) { |
|
597 | + print $globalMapRefresh*1000; |
|
598 | +} else { |
|
599 | + print '30000'; |
|
600 | +} |
|
601 | +?>); |
|
570 | 602 | <?php |
571 | 603 | } |
572 | 604 | ?> |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
78 | 80 | } |
79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
81 | + if ($filter_query_where == '' && $where) { |
|
82 | + $filter_query_where = ' WHERE'; |
|
83 | + } elseif ($filter_query_where != '' && $and) { |
|
84 | + $filter_query_where .= ' AND'; |
|
85 | + } |
|
81 | 86 | if ($filter_query_where != '') { |
82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
83 | 88 | } |
@@ -118,9 +123,13 @@ discard block |
||
118 | 123 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
119 | 124 | } |
120 | 125 | } |
121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
126 | + if ($orderby_query == '') { |
|
127 | + $orderby_query= ' ORDER BY date DESC'; |
|
128 | + } |
|
122 | 129 | |
123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
130 | + if (!isset($globalLiveInterval)) { |
|
131 | + $globalLiveInterval = '200'; |
|
132 | + } |
|
124 | 133 | if ($globalDBdriver == 'mysql') { |
125 | 134 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
126 | 135 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
145 | 154 | |
146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
147 | 156 | |
148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
157 | + if (!isset($globalLiveInterval)) { |
|
158 | + $globalLiveInterval = '200'; |
|
159 | + } |
|
149 | 160 | if ($globalDBdriver == 'mysql') { |
150 | 161 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
151 | 162 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -179,7 +190,9 @@ discard block |
||
179 | 190 | |
180 | 191 | $filter_query = $this->getFilter($filter,true,true); |
181 | 192 | |
182 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
193 | + if (!isset($globalLiveInterval)) { |
|
194 | + $globalLiveInterval = '200'; |
|
195 | + } |
|
183 | 196 | if ($globalDBdriver == 'mysql') { |
184 | 197 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
185 | 198 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -212,7 +225,9 @@ discard block |
||
212 | 225 | global $globalDBdriver, $globalLiveInterval; |
213 | 226 | $filter_query = $this->getFilter($filter,true,true); |
214 | 227 | |
215 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
228 | + if (!isset($globalLiveInterval)) { |
|
229 | + $globalLiveInterval = '200'; |
|
230 | + } |
|
216 | 231 | if ($globalDBdriver == 'mysql') { |
217 | 232 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
218 | 233 | } else { |
@@ -240,7 +255,9 @@ discard block |
||
240 | 255 | { |
241 | 256 | global $globalDBdriver, $globalLiveInterval; |
242 | 257 | $Spotter = new Spotter($this->db); |
243 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
258 | + if (!isset($globalLiveInterval)) { |
|
259 | + $globalLiveInterval = '200'; |
|
260 | + } |
|
244 | 261 | $filter_query = $this->getFilter($filter); |
245 | 262 | |
246 | 263 | if (is_array($coord)) { |
@@ -248,7 +265,9 @@ discard block |
||
248 | 265 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
249 | 266 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
250 | 267 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
251 | - } else return array(); |
|
268 | + } else { |
|
269 | + return array(); |
|
270 | + } |
|
252 | 271 | if ($globalDBdriver == 'mysql') { |
253 | 272 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
254 | 273 | } else { |
@@ -268,7 +287,9 @@ discard block |
||
268 | 287 | { |
269 | 288 | global $globalDBdriver, $globalLiveInterval; |
270 | 289 | $Spotter = new Spotter($this->db); |
271 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
290 | + if (!isset($globalLiveInterval)) { |
|
291 | + $globalLiveInterval = '200'; |
|
292 | + } |
|
272 | 293 | $filter_query = $this->getFilter($filter); |
273 | 294 | |
274 | 295 | if (is_array($coord)) { |
@@ -276,7 +297,9 @@ discard block |
||
276 | 297 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
277 | 298 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
278 | 299 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
279 | - } else return array(); |
|
300 | + } else { |
|
301 | + return array(); |
|
302 | + } |
|
280 | 303 | if ($globalDBdriver == 'mysql') { |
281 | 304 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
282 | 305 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -444,11 +467,15 @@ discard block |
||
444 | 467 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
445 | 468 | if ($globalDBdriver == 'mysql') { |
446 | 469 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
447 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
470 | + if ($liveinterval) { |
|
471 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
472 | + } |
|
448 | 473 | $query .= ' ORDER BY date'; |
449 | 474 | } else { |
450 | 475 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
451 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
476 | + if ($liveinterval) { |
|
477 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
478 | + } |
|
452 | 479 | $query .= ' ORDER BY date'; |
453 | 480 | } |
454 | 481 | |
@@ -543,7 +570,9 @@ discard block |
||
543 | 570 | $i++; |
544 | 571 | $j++; |
545 | 572 | if ($j == 30) { |
546 | - if ($globalDebug) echo "."; |
|
573 | + if ($globalDebug) { |
|
574 | + echo "."; |
|
575 | + } |
|
547 | 576 | try { |
548 | 577 | |
549 | 578 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -823,7 +852,9 @@ discard block |
||
823 | 852 | { |
824 | 853 | return false; |
825 | 854 | } |
826 | - } else return ''; |
|
855 | + } else { |
|
856 | + return ''; |
|
857 | + } |
|
827 | 858 | |
828 | 859 | if ($longitude != '') |
829 | 860 | { |
@@ -831,7 +862,9 @@ discard block |
||
831 | 862 | { |
832 | 863 | return false; |
833 | 864 | } |
834 | - } else return ''; |
|
865 | + } else { |
|
866 | + return ''; |
|
867 | + } |
|
835 | 868 | |
836 | 869 | |
837 | 870 | if ($heading != '') |
@@ -840,7 +873,9 @@ discard block |
||
840 | 873 | { |
841 | 874 | return false; |
842 | 875 | } |
843 | - } else $heading = 0; |
|
876 | + } else { |
|
877 | + $heading = 0; |
|
878 | + } |
|
844 | 879 | |
845 | 880 | if ($groundspeed != '') |
846 | 881 | { |
@@ -848,9 +883,13 @@ discard block |
||
848 | 883 | { |
849 | 884 | return false; |
850 | 885 | } |
851 | - } else $groundspeed = 0; |
|
886 | + } else { |
|
887 | + $groundspeed = 0; |
|
888 | + } |
|
852 | 889 | date_default_timezone_set('UTC'); |
853 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
890 | + if ($date == '') { |
|
891 | + $date = date("Y-m-d H:i:s", time()); |
|
892 | + } |
|
854 | 893 | |
855 | 894 | |
856 | 895 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -871,12 +910,20 @@ discard block |
||
871 | 910 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
872 | 911 | |
873 | 912 | |
874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
876 | - if ($arrival_date == '') $arrival_date = NULL; |
|
913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
914 | + $groundspeed = 0; |
|
915 | + } |
|
916 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
917 | + $heading = 0; |
|
918 | + } |
|
919 | + if ($arrival_date == '') { |
|
920 | + $arrival_date = NULL; |
|
921 | + } |
|
877 | 922 | $query = ''; |
878 | 923 | if ($globalArchive) { |
879 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
924 | + if ($globalDebug) { |
|
925 | + echo '-- Delete previous data -- '; |
|
926 | + } |
|
880 | 927 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
881 | 928 | } |
882 | 929 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -891,10 +938,14 @@ discard block |
||
891 | 938 | } |
892 | 939 | |
893 | 940 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
894 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
941 | + if ($globalDebug) { |
|
942 | + echo '(Add to Marine archive : '; |
|
943 | + } |
|
895 | 944 | $MarineArchive = new MarineArchive($this->db); |
896 | 945 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
897 | - if ($globalDebug) echo $result.')'; |
|
946 | + if ($globalDebug) { |
|
947 | + echo $result.')'; |
|
948 | + } |
|
898 | 949 | } |
899 | 950 | return "success"; |
900 | 951 | } |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | $temp += 1; |
36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else { |
|
39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
40 | + } |
|
39 | 41 | return $flat; // float |
40 | 42 | } |
41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | $temp += 1; |
48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
49 | 51 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
52 | + } else { |
|
53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
54 | + } |
|
51 | 55 | return $flon; |
52 | 56 | } |
53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
70 | 74 | */ |
71 | 75 | private function asciidec_2_8bit($ascii) { |
72 | 76 | //only process in the following range: 48-87, 96-119 |
73 | - if ($ascii < 48) { } |
|
74 | - else { |
|
75 | - if($ascii>119) { } |
|
76 | - else { |
|
77 | + if ($ascii < 48) { } else { |
|
78 | + if($ascii>119) { } else { |
|
77 | 79 | if ($ascii>87 && $ascii<96) ; |
78 | 80 | else { |
79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
180 | + if ($ro->heading == 511) { |
|
181 | + $ro->heading = ''; |
|
182 | + } |
|
179 | 183 | $ro->cls = 2; // class B |
180 | 184 | } else if ($ro->id == 19) { |
181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
186 | 190 | $ro->cls = 2; // class B |
187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
192 | + if ($ro->heading == 511) { |
|
193 | + $ro->heading = ''; |
|
194 | + } |
|
189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
216 | 222 | $ro->cls = 2; // class B |
217 | 223 | } else if ($ro->id == 27) { |
218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
225 | + if ($ro->cog == 511) { |
|
226 | + $ro->cog = 0.0; |
|
227 | + } |
|
220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
229 | + if ($ro->sog == 63) { |
|
230 | + $ro->sog = 0.0; |
|
231 | + } |
|
222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
267 | 277 | } |
268 | 278 | |
269 | 279 | public function getShipType($code) { |
270 | - if ($code == 0) return 'Not available (default)'; |
|
271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
282 | - elseif ($code == 30) return 'Fishing'; |
|
283 | - elseif ($code == 31) return 'Towing'; |
|
284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
286 | - elseif ($code == 34) return 'Diving ops'; |
|
287 | - elseif ($code == 35) return 'Military ops'; |
|
288 | - elseif ($code == 36) return 'Sailing'; |
|
289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
290 | - elseif ($code == 38) return 'Reserved'; |
|
291 | - elseif ($code == 39) return 'Reserved'; |
|
292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
304 | - elseif ($code == 52) return 'Tug'; |
|
305 | - elseif ($code == 53) return 'Port Tender'; |
|
306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
310 | - elseif ($code == 58) return 'Medical Transport'; |
|
311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
280 | + if ($code == 0) { |
|
281 | + return 'Not available (default)'; |
|
282 | + } elseif ($code >= 1 && $code <= 19) { |
|
283 | + return 'Reserved for future use'; |
|
284 | + } elseif ($code == 20) { |
|
285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
286 | + } elseif ($code == 21) { |
|
287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
288 | + } elseif ($code == 22) { |
|
289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
290 | + } elseif ($code == 23) { |
|
291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
292 | + } elseif ($code == 24) { |
|
293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
294 | + } elseif ($code == 25) { |
|
295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
296 | + } elseif ($code == 26) { |
|
297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
298 | + } elseif ($code == 27) { |
|
299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
300 | + } elseif ($code == 28) { |
|
301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
302 | + } elseif ($code == 29) { |
|
303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
304 | + } elseif ($code == 30) { |
|
305 | + return 'Fishing'; |
|
306 | + } elseif ($code == 31) { |
|
307 | + return 'Towing'; |
|
308 | + } elseif ($code == 32) { |
|
309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
310 | + } elseif ($code == 33) { |
|
311 | + return 'Dredging or underwater ops'; |
|
312 | + } elseif ($code == 34) { |
|
313 | + return 'Diving ops'; |
|
314 | + } elseif ($code == 35) { |
|
315 | + return 'Military ops'; |
|
316 | + } elseif ($code == 36) { |
|
317 | + return 'Sailing'; |
|
318 | + } elseif ($code == 37) { |
|
319 | + return 'Pleasure Craft'; |
|
320 | + } elseif ($code == 38) { |
|
321 | + return 'Reserved'; |
|
322 | + } elseif ($code == 39) { |
|
323 | + return 'Reserved'; |
|
324 | + } elseif ($code == 40) { |
|
325 | + return 'High speed craft (HSC), all ships of this type'; |
|
326 | + } elseif ($code == 41) { |
|
327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
328 | + } elseif ($code == 42) { |
|
329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
330 | + } elseif ($code == 43) { |
|
331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
332 | + } elseif ($code == 44) { |
|
333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
334 | + } elseif ($code == 45) { |
|
335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
336 | + } elseif ($code == 46) { |
|
337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
338 | + } elseif ($code == 47) { |
|
339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
340 | + } elseif ($code == 48) { |
|
341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
342 | + } elseif ($code == 49) { |
|
343 | + return 'High speed craft (HSC), No additional information'; |
|
344 | + } elseif ($code == 50) { |
|
345 | + return 'Pilot Vessel'; |
|
346 | + } elseif ($code == 51) { |
|
347 | + return 'Search and Rescue vessel'; |
|
348 | + } elseif ($code == 52) { |
|
349 | + return 'Tug'; |
|
350 | + } elseif ($code == 53) { |
|
351 | + return 'Port Tender'; |
|
352 | + } elseif ($code == 54) { |
|
353 | + return 'Anti-pollution equipment'; |
|
354 | + } elseif ($code == 55) { |
|
355 | + return 'Law Enforcement'; |
|
356 | + } elseif ($code == 56) { |
|
357 | + return 'Spare - Local Vessel'; |
|
358 | + } elseif ($code == 57) { |
|
359 | + return 'Spare - Local Vessel'; |
|
360 | + } elseif ($code == 58) { |
|
361 | + return 'Medical Transport'; |
|
362 | + } elseif ($code == 59) { |
|
363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
364 | + } elseif ($code == 60) { |
|
365 | + return 'Passenger, all ships of this type'; |
|
366 | + } elseif ($code == 61) { |
|
367 | + return 'Passenger, Hazardous category A'; |
|
368 | + } elseif ($code == 62) { |
|
369 | + return 'Passenger, Hazardous category B'; |
|
370 | + } elseif ($code == 63) { |
|
371 | + return 'Passenger, Hazardous category C'; |
|
372 | + } elseif ($code == 64) { |
|
373 | + return 'Passenger, Hazardous category D'; |
|
374 | + } elseif ($code == 65) { |
|
375 | + return 'Passenger, Reserved for future use'; |
|
376 | + } elseif ($code == 66) { |
|
377 | + return 'Passenger, Reserved for future use'; |
|
378 | + } elseif ($code == 67) { |
|
379 | + return 'Passenger, Reserved for future use'; |
|
380 | + } elseif ($code == 68) { |
|
381 | + return 'Passenger, Reserved for future use'; |
|
382 | + } elseif ($code == 69) { |
|
383 | + return 'Passenger, No additional information'; |
|
384 | + } elseif ($code == 70) { |
|
385 | + return 'Cargo, all ships of this type'; |
|
386 | + } elseif ($code == 71) { |
|
387 | + return 'Cargo, Hazardous category A'; |
|
388 | + } elseif ($code == 72) { |
|
389 | + return 'Cargo, Hazardous category B'; |
|
390 | + } elseif ($code == 73) { |
|
391 | + return 'Cargo, Hazardous category C'; |
|
392 | + } elseif ($code == 74) { |
|
393 | + return 'Cargo, Hazardous category D'; |
|
394 | + } elseif ($code == 75) { |
|
395 | + return 'Cargo, Reserved for future use'; |
|
396 | + } elseif ($code == 76) { |
|
397 | + return 'Cargo, Reserved for future use'; |
|
398 | + } elseif ($code == 77) { |
|
399 | + return 'Cargo, Reserved for future use'; |
|
400 | + } elseif ($code == 78) { |
|
401 | + return 'Cargo, Reserved for future use'; |
|
402 | + } elseif ($code == 79) { |
|
403 | + return 'Cargo, No additional information'; |
|
404 | + } elseif ($code == 80) { |
|
405 | + return 'Tanker, all ships of this type'; |
|
406 | + } elseif ($code == 81) { |
|
407 | + return 'Tanker, Hazardous category A'; |
|
408 | + } elseif ($code == 82) { |
|
409 | + return 'Tanker, Hazardous category B'; |
|
410 | + } elseif ($code == 83) { |
|
411 | + return 'Tanker, Hazardous category C'; |
|
412 | + } elseif ($code == 84) { |
|
413 | + return 'Tanker, Hazardous category D'; |
|
414 | + } elseif ($code == 85) { |
|
415 | + return 'Tanker, Reserved for future use'; |
|
416 | + } elseif ($code == 86) { |
|
417 | + return 'Tanker, Reserved for future use'; |
|
418 | + } elseif ($code == 87) { |
|
419 | + return 'Tanker, Reserved for future use'; |
|
420 | + } elseif ($code == 88) { |
|
421 | + return 'Tanker, Reserved for future use'; |
|
422 | + } elseif ($code == 89) { |
|
423 | + return 'Tanker, No additional information'; |
|
424 | + } elseif ($code == 90) { |
|
425 | + return 'Other Type, all ships of this type'; |
|
426 | + } elseif ($code == 91) { |
|
427 | + return 'Other Type, Hazardous category A'; |
|
428 | + } elseif ($code == 92) { |
|
429 | + return 'Other Type, Hazardous category B'; |
|
430 | + } elseif ($code == 93) { |
|
431 | + return 'Other Type, Hazardous category C'; |
|
432 | + } elseif ($code == 94) { |
|
433 | + return 'Other Type, Hazardous category D'; |
|
434 | + } elseif ($code == 95) { |
|
435 | + return 'Other Type, Reserved for future use'; |
|
436 | + } elseif ($code == 96) { |
|
437 | + return 'Other Type, Reserved for future use'; |
|
438 | + } elseif ($code == 97) { |
|
439 | + return 'Other Type, Reserved for future use'; |
|
440 | + } elseif ($code == 98) { |
|
441 | + return 'Other Type, Reserved for future use'; |
|
442 | + } elseif ($code == 99) { |
|
443 | + return 'Other Type, no additional information'; |
|
444 | + } |
|
352 | 445 | } |
353 | 446 | |
354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,19 +479,34 @@ discard block |
||
386 | 479 | // assume 1st ! is valid |
387 | 480 | // find * ensure that it is at correct position |
388 | 481 | $end = strrpos ( $rawdata , '*' ); |
389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
482 | + if ($end === FALSE) { |
|
483 | + return -1; |
|
484 | + } |
|
485 | + // check for NULLS!!! |
|
390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
487 | + if ( strlen($cs) != 2 ) { |
|
488 | + return -1; |
|
489 | + } |
|
490 | + // correct cs length |
|
392 | 491 | $dcs = (int)hexdec( $cs ); |
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
494 | + } |
|
495 | + // perform XOR for NMEA checksum |
|
394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
395 | 497 | $pcs = explode(',', $rawdata); |
396 | 498 | // !AI??? identifier |
397 | 499 | $num_seq = (int)$pcs[1]; // number of sequences |
398 | 500 | $seq = (int)$pcs[2]; // get sequence |
399 | 501 | // get msg sequence id |
400 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
502 | + if ($pcs[3] == '') { |
|
503 | + $msg_sid = -1; |
|
504 | + } |
|
505 | + // non-multipart message, set to -1 |
|
506 | + else { |
|
507 | + $msg_sid = (int)$pcs[3]; |
|
508 | + } |
|
509 | + // multipart message |
|
402 | 510 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 511 | // message sequence checking |
404 | 512 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -459,10 +567,18 @@ discard block |
||
459 | 567 | //DEBUG echo "[$start $end $tst]\n"; |
460 | 568 | $result = $this->process_ais_raw( $tst, "" ); |
461 | 569 | $last_pos = $end + 1; |
462 | - } else break; |
|
570 | + } else { |
|
571 | + break; |
|
572 | + } |
|
573 | + } |
|
574 | + if ($last_pos > 0) { |
|
575 | + $cbuf = substr($cbuf, $last_pos); |
|
576 | + } |
|
577 | + // move... |
|
578 | + if (strlen($cbuf) > 1024) { |
|
579 | + $cbuf = ""; |
|
463 | 580 | } |
464 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
465 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
581 | + // prevent overflow simple mode... |
|
466 | 582 | return $result; |
467 | 583 | } |
468 | 584 | |
@@ -482,7 +598,9 @@ discard block |
||
482 | 598 | if ($lat<0.0) { |
483 | 599 | $lat = -$lat; |
484 | 600 | $neg=true; |
485 | - } else $neg=false; |
|
601 | + } else { |
|
602 | + $neg=false; |
|
603 | + } |
|
486 | 604 | $latd = 0x00000000; |
487 | 605 | $latd = intval ($lat * 600000.0); |
488 | 606 | if ($neg==true) { |
@@ -498,7 +616,9 @@ discard block |
||
498 | 616 | if ($lon<0.0) { |
499 | 617 | $lon = -$lon; |
500 | 618 | $neg=true; |
501 | - } else $neg=false; |
|
619 | + } else { |
|
620 | + $neg=false; |
|
621 | + } |
|
502 | 622 | $lond = 0x00000000; |
503 | 623 | $lond = intval ($lon * 600000.0); |
504 | 624 | if ($neg==true) { |
@@ -511,9 +631,14 @@ discard block |
||
511 | 631 | |
512 | 632 | private function char2bin($name, $max_len) { |
513 | 633 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
516 | - else $pad = ''; |
|
634 | + if ($len > $max_len) { |
|
635 | + $name = substr($name,0,$max_len); |
|
636 | + } |
|
637 | + if ($len < $max_len) { |
|
638 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
639 | + } else { |
|
640 | + $pad = ''; |
|
641 | + } |
|
517 | 642 | $rv = ''; |
518 | 643 | $ais_chars = array( |
519 | 644 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -526,9 +651,12 @@ discard block |
||
526 | 651 | ); |
527 | 652 | // " |
528 | 653 | $_a = str_split($name); |
529 | - if ($_a) foreach ($_a as $_1) { |
|
654 | + if ($_a) { |
|
655 | + foreach ($_a as $_1) { |
|
530 | 656 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | - else $dec = 0; |
|
657 | + } else { |
|
658 | + $dec = 0; |
|
659 | + } |
|
532 | 660 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
533 | 661 | $rv .= $bin; |
534 | 662 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -540,7 +668,9 @@ discard block |
||
540 | 668 | $len_bit = strlen($_enc); |
541 | 669 | $rem6 = $len_bit % 6; |
542 | 670 | $pad6_len = 0; |
543 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
671 | + if ($rem6) { |
|
672 | + $pad6_len = 6 - $rem6; |
|
673 | + } |
|
544 | 674 | //echo $pad6_len.'<br>'; |
545 | 675 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | 676 | $len_enc = strlen($_enc) / 6; |
@@ -549,8 +679,11 @@ discard block |
||
549 | 679 | for ($i=0; $i<$len_enc; $i++) { |
550 | 680 | $offset = $i * 6; |
551 | 681 | $dec = bindec(substr($_enc,$offset,6)); |
552 | - if ($dec < 40) $dec += 48; |
|
553 | - else $dec += 56; |
|
682 | + if ($dec < 40) { |
|
683 | + $dec += 48; |
|
684 | + } else { |
|
685 | + $dec += 56; |
|
686 | + } |
|
554 | 687 | //echo chr($dec)." $dec<br/>"; |
555 | 688 | $itu .= chr($dec); |
556 | 689 | } |
@@ -563,25 +696,41 @@ discard block |
||
563 | 696 | } |
564 | 697 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
565 | 698 | $lsb = $chksum & 0x0F; |
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
567 | - else $lsbc = '0'; |
|
699 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
700 | + $lsbc = $hex_arr[$lsb]; |
|
701 | + } else { |
|
702 | + $lsbc = '0'; |
|
703 | + } |
|
568 | 704 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
570 | - else $msbc = '0'; |
|
705 | + if ($msb >=0 && $msb <= 15 ) { |
|
706 | + $msbc = $hex_arr[$msb]; |
|
707 | + } else { |
|
708 | + $msbc = '0'; |
|
709 | + } |
|
571 | 710 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 711 | return $itu; |
573 | 712 | } |
574 | 713 | |
575 | 714 | public function parse($buffer) { |
576 | 715 | $data = $this->process_ais_buf($buffer); |
577 | - if (!is_object($data)) return array(); |
|
578 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
579 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
716 | + if (!is_object($data)) { |
|
717 | + return array(); |
|
718 | + } |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
580 | 725 | $result['ident'] = trim($data->name); |
581 | 726 | $result['timestamp'] = $data->ts; |
582 | 727 | $result['mmsi'] = $data->mmsi; |
583 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
584 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
728 | + if ($data->sog != -1.0) { |
|
729 | + $result['speed'] = $data->sog; |
|
730 | + } |
|
731 | + if ($data->cog != 0) { |
|
732 | + $result['heading'] = $data->cog; |
|
733 | + } |
|
585 | 734 | /* |
586 | 735 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
587 | 736 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -591,15 +740,25 @@ discard block |
||
591 | 740 | |
592 | 741 | public function mmsitype($mmsi) { |
593 | 742 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
602 | - else return 'Ship'; |
|
743 | + if (substr($mmsi,0,3) == '974') { |
|
744 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
745 | + } elseif (substr($mmsi,0,3) == '972') { |
|
746 | + return 'MOB (Man Overboard) device'; |
|
747 | + } elseif (substr($mmsi,0,3) == '970') { |
|
748 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
749 | + } elseif (substr($mmsi,0,3) == '111') { |
|
750 | + return 'SAR (Search and Rescue) aircraft'; |
|
751 | + } elseif (substr($mmsi,0,2) == '98') { |
|
752 | + return 'Auxiliary craft associated with a parent ship'; |
|
753 | + } elseif (substr($mmsi,0,2) == '99') { |
|
754 | + return 'Aids to Navigation'; |
|
755 | + } elseif (substr($mmsi,0,2) == '00') { |
|
756 | + return 'Coastal stations'; |
|
757 | + } elseif (substr($mmsi,0,1) == '0') { |
|
758 | + return 'Group of ships'; |
|
759 | + } else { |
|
760 | + return 'Ship'; |
|
761 | + } |
|
603 | 762 | } |
604 | 763 | |
605 | 764 | |
@@ -616,32 +775,61 @@ discard block |
||
616 | 775 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 776 | return array(); |
618 | 777 | } |
619 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
620 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
778 | + if ($data->lon != 0) { |
|
779 | + $result['longitude'] = $data->lon; |
|
780 | + } |
|
781 | + if ($data->lat != 0) { |
|
782 | + $result['latitude'] = $data->lat; |
|
783 | + } |
|
621 | 784 | $result['ident'] = trim(str_replace('@','',$data->name)); |
622 | 785 | $result['timestamp'] = $data->ts; |
623 | 786 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
787 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
788 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
789 | + } |
|
625 | 790 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
627 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
628 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
629 | - if ($data->status != '') $result['status'] = $data->status; |
|
630 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
631 | - if ($data->type !== '') $result['type'] = $data->type; |
|
632 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
633 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
791 | + if ($data->sog != -1.0) { |
|
792 | + $result['speed'] = $data->sog; |
|
793 | + } |
|
794 | + if ($data->heading !== '') { |
|
795 | + $result['heading'] = $data->heading; |
|
796 | + } elseif ($data->cog != 0) { |
|
797 | + $result['heading'] = $data->cog; |
|
798 | + } |
|
799 | + if ($data->status != '') { |
|
800 | + $result['status'] = $data->status; |
|
801 | + } |
|
802 | + if ($data->statusid !== '') { |
|
803 | + $result['statusid'] = $data->statusid; |
|
804 | + } |
|
805 | + if ($data->type !== '') { |
|
806 | + $result['type'] = $data->type; |
|
807 | + } |
|
808 | + if ($data->typeid !== '') { |
|
809 | + $result['typeid'] = $data->typeid; |
|
810 | + } |
|
811 | + if ($data->imo !== '') { |
|
812 | + $result['imo'] = $data->imo; |
|
813 | + } |
|
814 | + if ($data->callsign !== '') { |
|
815 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
816 | + } |
|
635 | 817 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
636 | 818 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
637 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
819 | + if ($eta_ts != '') { |
|
820 | + $result['eta_ts'] = $eta_ts; |
|
821 | + } |
|
638 | 822 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
639 | 823 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
640 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
824 | + if ($eta_ts != '') { |
|
825 | + $result['eta_ts'] = $eta_ts; |
|
826 | + } |
|
641 | 827 | } |
642 | 828 | if ($data->destination != '') { |
643 | 829 | $dest = trim(str_replace('@','',$data->destination)); |
644 | - if ($dest != '') $result['destination'] = $dest; |
|
830 | + if ($dest != '') { |
|
831 | + $result['destination'] = $dest; |
|
832 | + } |
|
645 | 833 | } |
646 | 834 | $result['all'] = (array) $data; |
647 | 835 | /* |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
25 | 25 | $reg = $registration; |
26 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
26 | + if ($reg == '' && $aircraft_icao != '') { |
|
27 | + $reg = $aircraft_icao.$airline_icao; |
|
28 | + } |
|
27 | 29 | $reg = trim($reg); |
28 | 30 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
29 | 31 | FROM spotter_image |
@@ -31,9 +33,13 @@ discard block |
||
31 | 33 | $sth = $this->db->prepare($query); |
32 | 34 | $sth->execute(array(':registration' => $reg)); |
33 | 35 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
34 | - if (!empty($result)) return $result; |
|
35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
36 | - else return array(); |
|
36 | + if (!empty($result)) { |
|
37 | + return $result; |
|
38 | + } elseif ($registration != '') { |
|
39 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
40 | + } else { |
|
41 | + return array(); |
|
42 | + } |
|
37 | 43 | } |
38 | 44 | |
39 | 45 | /** |
@@ -76,8 +82,11 @@ discard block |
||
76 | 82 | public function getExifCopyright($url) { |
77 | 83 | $exif = exif_read_data($url); |
78 | 84 | $copyright = ''; |
79 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
80 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
85 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
86 | + $copyright = $exif['COMPUTED']['copyright']; |
|
87 | + } elseif (isset($exif['copyright'])) { |
|
88 | + $copyright = $exif['copyright']; |
|
89 | + } |
|
81 | 90 | if ($copyright != '') { |
82 | 91 | $copyright = str_replace('Copyright ','',$copyright); |
83 | 92 | $copyright = str_replace('© ','',$copyright); |
@@ -95,17 +104,27 @@ discard block |
||
95 | 104 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
96 | 105 | { |
97 | 106 | global $globalDebug,$globalAircraftImageFetch; |
98 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
107 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
108 | + return ''; |
|
109 | + } |
|
99 | 110 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
100 | 111 | $registration = trim($registration); |
101 | 112 | //getting the aircraft image |
102 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
103 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
104 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
113 | + if ($globalDebug && $registration != '') { |
|
114 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
115 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
116 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
117 | + } elseif ($globalDebug && $airline_icao != '') { |
|
118 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
119 | + } |
|
105 | 120 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
106 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
121 | + if ($registration == '' && $aircraft_icao != '') { |
|
122 | + $registration = $aircraft_icao.$airline_icao; |
|
123 | + } |
|
107 | 124 | if ($image_url['original'] != '') { |
108 | - if ($globalDebug) echo 'Found !'."\n"; |
|
125 | + if ($globalDebug) { |
|
126 | + echo 'Found !'."\n"; |
|
127 | + } |
|
109 | 128 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
110 | 129 | try { |
111 | 130 | $sth = $this->db->prepare($query); |
@@ -114,7 +133,9 @@ discard block |
||
114 | 133 | echo $e->getMessage()."\n"; |
115 | 134 | return "error"; |
116 | 135 | } |
117 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
136 | + } elseif ($globalDebug) { |
|
137 | + echo "Not found :'(\n"; |
|
138 | + } |
|
118 | 139 | return "success"; |
119 | 140 | } |
120 | 141 | |
@@ -127,7 +148,9 @@ discard block |
||
127 | 148 | public function addMarineImage($mmsi,$imo = '',$name = '') |
128 | 149 | { |
129 | 150 | global $globalDebug,$globalMarineImageFetch; |
130 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
151 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
152 | + return ''; |
|
153 | + } |
|
131 | 154 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
132 | 155 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
133 | 156 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -137,16 +160,22 @@ discard block |
||
137 | 160 | $identity = $Marine->getIdentity($mmsi); |
138 | 161 | if (isset($identity[0]['mmsi'])) { |
139 | 162 | $imo = $identity[0]['imo']; |
140 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
163 | + if ($identity[0]['ship_name'] != '') { |
|
164 | + $name = $identity[0]['ship_name']; |
|
165 | + } |
|
141 | 166 | } |
142 | 167 | } |
143 | 168 | unset($Marine); |
144 | 169 | |
145 | 170 | //getting the aircraft image |
146 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
171 | + if ($globalDebug && $name != '') { |
|
172 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
173 | + } |
|
147 | 174 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
148 | 175 | if ($image_url['original'] != '') { |
149 | - if ($globalDebug) echo 'Found !'."\n"; |
|
176 | + if ($globalDebug) { |
|
177 | + echo 'Found !'."\n"; |
|
178 | + } |
|
150 | 179 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
151 | 180 | try { |
152 | 181 | $sth = $this->db->prepare($query); |
@@ -155,7 +184,9 @@ discard block |
||
155 | 184 | echo $e->getMessage()."\n"; |
156 | 185 | return "error"; |
157 | 186 | } |
158 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
187 | + } elseif ($globalDebug) { |
|
188 | + echo "Not found :'(\n"; |
|
189 | + } |
|
159 | 190 | return "success"; |
160 | 191 | } |
161 | 192 | |
@@ -170,41 +201,85 @@ discard block |
||
170 | 201 | { |
171 | 202 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
172 | 203 | $Spotter = new Spotter($this->db); |
173 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
204 | + if (!isset($globalIVAO)) { |
|
205 | + $globalIVAO = FALSE; |
|
206 | + } |
|
174 | 207 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
175 | 208 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
209 | + if (strpos($aircraft_registration,'/') !== false) { |
|
210 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
211 | + } |
|
177 | 212 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
178 | 213 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
179 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
180 | - else $aircraft_name = ''; |
|
181 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
182 | - else $aircraft_icao = ''; |
|
183 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
184 | - else $airline_icao = ''; |
|
214 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
215 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
216 | + } else { |
|
217 | + $aircraft_name = ''; |
|
218 | + } |
|
219 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
220 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
221 | + } else { |
|
222 | + $aircraft_icao = ''; |
|
223 | + } |
|
224 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
225 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
226 | + } else { |
|
227 | + $airline_icao = ''; |
|
228 | + } |
|
185 | 229 | } elseif ($aircraft_icao != '') { |
186 | 230 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
187 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
188 | - else $aircraft_name = ''; |
|
231 | + if (isset($aircraft_info[0]['type'])) { |
|
232 | + $aircraft_name = $aircraft_info[0]['type']; |
|
233 | + } else { |
|
234 | + $aircraft_name = ''; |
|
235 | + } |
|
189 | 236 | $aircraft_registration = $aircraft_icao; |
190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
237 | + } else { |
|
238 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
239 | + } |
|
191 | 240 | unset($Spotter); |
192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
241 | + if (!isset($globalAircraftImageSources)) { |
|
242 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
243 | + } |
|
193 | 244 | foreach ($globalAircraftImageSources as $source) { |
194 | 245 | $source = strtolower($source); |
195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
206 | - } |
|
207 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
246 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
247 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
248 | + } |
|
249 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
250 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
251 | + } |
|
252 | + if ($source == 'flickr') { |
|
253 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'bing') { |
|
256 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'deviantart') { |
|
259 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'wikimedia') { |
|
262 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
265 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
268 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
271 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'customsources') { |
|
274 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if (isset($images_array) && $images_array['original'] != '') { |
|
277 | + return $images_array; |
|
278 | + } |
|
279 | + } |
|
280 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
281 | + return $this->findAircraftImage($aircraft_icao); |
|
282 | + } |
|
208 | 283 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
209 | 284 | } |
210 | 285 | |
@@ -224,7 +299,9 @@ discard block |
||
224 | 299 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
225 | 300 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
226 | 301 | $name = trim($name); |
227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
302 | + if (strlen($name) < 4) { |
|
303 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
304 | + } |
|
228 | 305 | /* |
229 | 306 | $Marine = new Marine($this->db); |
230 | 307 | if ($imo == '' || $name == '') { |
@@ -236,15 +313,29 @@ discard block |
||
236 | 313 | } |
237 | 314 | unset($Marine); |
238 | 315 | */ |
239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
316 | + if (!isset($globalMarineImageSources)) { |
|
317 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
318 | + } |
|
240 | 319 | foreach ($globalMarineImageSources as $source) { |
241 | 320 | $source = strtolower($source); |
242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
247 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
321 | + if ($source == 'flickr') { |
|
322 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
323 | + } |
|
324 | + if ($source == 'bing') { |
|
325 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'deviantart') { |
|
328 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'wikimedia') { |
|
331 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'customsources') { |
|
334 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if (isset($images_array) && $images_array['original'] != '') { |
|
337 | + return $images_array; |
|
338 | + } |
|
248 | 339 | } |
249 | 340 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
250 | 341 | } |
@@ -407,11 +498,17 @@ discard block |
||
407 | 498 | public function fromFlickr($type,$registration,$name='') { |
408 | 499 | $Common = new Common(); |
409 | 500 | if ($type == 'aircraft') { |
410 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
411 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
501 | + if ($name != '') { |
|
502 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
503 | + } else { |
|
504 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
505 | + } |
|
412 | 506 | } elseif ($type == 'marine') { |
413 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
414 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
507 | + if ($name != '') { |
|
508 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
509 | + } else { |
|
510 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
511 | + } |
|
415 | 512 | } |
416 | 513 | $data = $Common->getData($url); |
417 | 514 | if ($xml = simplexml_load_string($data)) { |
@@ -456,13 +553,21 @@ discard block |
||
456 | 553 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
457 | 554 | global $globalImageBingKey; |
458 | 555 | $Common = new Common(); |
459 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
556 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
557 | + return false; |
|
558 | + } |
|
460 | 559 | if ($type == 'aircraft') { |
461 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
462 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
560 | + if ($aircraft_name != '') { |
|
561 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
562 | + } else { |
|
563 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
564 | + } |
|
463 | 565 | } elseif ($type == 'marine') { |
464 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
465 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
566 | + if ($aircraft_name != '') { |
|
567 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
568 | + } else { |
|
569 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
570 | + } |
|
466 | 571 | } |
467 | 572 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
468 | 573 | $data = $Common->getData($url,'get','',$headers); |
@@ -518,17 +623,25 @@ discard block |
||
518 | 623 | public function fromWikimedia($type,$registration,$name='') { |
519 | 624 | $Common = new Common(); |
520 | 625 | if ($type == 'aircraft') { |
521 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
522 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
626 | + if ($name != '') { |
|
627 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
628 | + } else { |
|
629 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
630 | + } |
|
523 | 631 | } elseif ($type == 'marine') { |
524 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
525 | - else return false; |
|
632 | + if ($name != '') { |
|
633 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
634 | + } else { |
|
635 | + return false; |
|
636 | + } |
|
526 | 637 | } |
527 | 638 | $data = $Common->getData($url); |
528 | 639 | $result = json_decode($data); |
529 | 640 | if (isset($result->query->search[0]->title)) { |
530 | 641 | $fileo = $result->query->search[0]->title; |
531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
642 | + if (substr($fileo,-3) == 'pdf') { |
|
643 | + return false; |
|
644 | + } |
|
532 | 645 | $file = urlencode($fileo); |
533 | 646 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
534 | 647 | $data2 = $Common->getData($url2); |
@@ -599,18 +712,27 @@ discard block |
||
599 | 712 | $image_url = array(); |
600 | 713 | $image_url['thumbnail'] = $url_thumbnail; |
601 | 714 | $image_url['original'] = $url; |
602 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
603 | - else $exifCopyright = ''; |
|
604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
605 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
606 | - else $image_url['copyright'] = $source['source_website']; |
|
715 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
716 | + $exifCopyright = $this->getExifCopyright($url); |
|
717 | + } else { |
|
718 | + $exifCopyright = ''; |
|
719 | + } |
|
720 | + if ($exifCopyright != '') { |
|
721 | + $image_url['copyright'] = $exifCopyright; |
|
722 | + } elseif (isset($source['copyright'])) { |
|
723 | + $image_url['copyright'] = $source['copyright']; |
|
724 | + } else { |
|
725 | + $image_url['copyright'] = $source['source_website']; |
|
726 | + } |
|
607 | 727 | $image_url['source_website'] = $source['source_website']; |
608 | 728 | $image_url['source'] = $source['source']; |
609 | 729 | return $image_url; |
610 | 730 | } |
611 | 731 | } |
612 | 732 | return false; |
613 | - } else return false; |
|
733 | + } else { |
|
734 | + return false; |
|
735 | + } |
|
614 | 736 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
615 | 737 | $customsources = array(); |
616 | 738 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -635,18 +757,27 @@ discard block |
||
635 | 757 | $image_url = array(); |
636 | 758 | $image_url['thumbnail'] = $url_thumbnail; |
637 | 759 | $image_url['original'] = $url; |
638 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
639 | - else $exifCopyright = ''; |
|
640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
641 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
642 | - else $image_url['copyright'] = $source['source_website']; |
|
760 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
761 | + $exifCopyright = $this->getExifCopyright($url); |
|
762 | + } else { |
|
763 | + $exifCopyright = ''; |
|
764 | + } |
|
765 | + if ($exifCopyright != '') { |
|
766 | + $image_url['copyright'] = $exifCopyright; |
|
767 | + } elseif (isset($source['copyright'])) { |
|
768 | + $image_url['copyright'] = $source['copyright']; |
|
769 | + } else { |
|
770 | + $image_url['copyright'] = $source['source_website']; |
|
771 | + } |
|
643 | 772 | $image_url['source_website'] = $source['source_website']; |
644 | 773 | $image_url['source'] = $source['source']; |
645 | 774 | return $image_url; |
646 | 775 | } |
647 | 776 | } |
648 | 777 | return false; |
649 | - } else return false; |
|
778 | + } else { |
|
779 | + return false; |
|
780 | + } |
|
650 | 781 | } |
651 | 782 | } |
652 | 783 |
@@ -1,13 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) { |
|
5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
6 | +} |
|
7 | +if (isset($_GET['ident'])) { |
|
8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
9 | +} |
|
6 | 10 | if ($ident != '') |
7 | 11 | { |
8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
10 | -} else { |
|
12 | + if (isset($_GET['marine'])) { |
|
13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
14 | + } else { |
|
15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
16 | + } |
|
17 | + } else { |
|
11 | 18 | header('Location: '.$globalURL); |
12 | 19 | } |
13 | 20 | ?> |
14 | 21 | \ No newline at end of file |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $limit_start = 0; |
32 | 32 | $limit_end = 25; |
33 | 33 | $absolute_difference = 25; |
34 | -} else { |
|
34 | +} else { |
|
35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
36 | 36 | $limit_start = $limit_explode[0]; |
37 | 37 | $limit_end = $limit_explode[1]; |
@@ -50,20 +50,32 @@ discard block |
||
50 | 50 | print '</div>'; |
51 | 51 | |
52 | 52 | print '<div class="table column">'; |
53 | -if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
54 | -elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
55 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
53 | +if ($type == 'aircraft') { |
|
54 | + print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
55 | +} elseif ($type == 'marine') { |
|
56 | + print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
57 | +} elseif ($type == 'tracker') { |
|
58 | + print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
59 | +} |
|
56 | 60 | |
57 | 61 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
58 | 62 | if ($sort != '') { |
59 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
60 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
61 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
62 | -} else { |
|
63 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
64 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
65 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
66 | -} |
|
63 | + if ($type == 'aircraft') { |
|
64 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
65 | + } elseif ($type == 'marine') { |
|
66 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
67 | + } elseif ($type == 'tracker') { |
|
68 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
69 | + } |
|
70 | + } else { |
|
71 | + if ($type == 'aircraft') { |
|
72 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
73 | + } elseif ($type == 'marine') { |
|
74 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
75 | + } elseif ($type == 'tracker') { |
|
76 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
77 | + } |
|
78 | + } |
|
67 | 79 | |
68 | 80 | if (!empty($spotter_array)) |
69 | 81 | { |