@@ -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 | } |
@@ -107,17 +107,23 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
110 | + if ($globalDebug) { |
|
111 | + echo '!!! APRS invalid : '.$input."\n"; |
|
112 | + } |
|
111 | 113 | return false; |
112 | 114 | } |
113 | 115 | |
114 | - if ($debug) echo 'input : '.$input."\n"; |
|
116 | + if ($debug) { |
|
117 | + echo 'input : '.$input."\n"; |
|
118 | + } |
|
115 | 119 | /* Save header and body. */ |
116 | 120 | $body = substr($input,$splitpos+1,$input_len); |
117 | 121 | $body_len = strlen($body); |
118 | 122 | $header = substr($input,0,$splitpos); |
119 | 123 | //$header_len = strlen($header); |
120 | - if ($debug) echo 'header : '.$header."\n"; |
|
124 | + if ($debug) { |
|
125 | + echo 'header : '.$header."\n"; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | /* Parse source, target and path. */ |
123 | 129 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -131,10 +137,14 @@ discard block |
||
131 | 137 | $result['format_source'] = 'famaprs'; |
132 | 138 | $result['source_type'] = 'ais'; |
133 | 139 | } else { |
134 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
140 | + if ($debug) { |
|
141 | + echo 'ident : '.$ident."\n"; |
|
142 | + } |
|
135 | 143 | $result['ident'] = $ident; |
136 | 144 | } |
137 | - } else return false; |
|
145 | + } else { |
|
146 | + return false; |
|
147 | + } |
|
138 | 148 | $elements = explode(',',$all_elements); |
139 | 149 | $source = end($elements); |
140 | 150 | $result['source'] = $source; |
@@ -143,7 +153,9 @@ discard block |
||
143 | 153 | //echo "ok"; |
144 | 154 | //if ($element == 'TCPIP*') return false; |
145 | 155 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
146 | - if ($debug) echo 'element : '.$element."\n"; |
|
156 | + if ($debug) { |
|
157 | + echo 'element : '.$element."\n"; |
|
158 | + } |
|
147 | 159 | return false; |
148 | 160 | } |
149 | 161 | /* |
@@ -156,13 +168,17 @@ discard block |
||
156 | 168 | } |
157 | 169 | |
158 | 170 | $type = substr($body,0,1); |
159 | - if ($debug) echo 'type : '.$type."\n"; |
|
171 | + if ($debug) { |
|
172 | + echo 'type : '.$type."\n"; |
|
173 | + } |
|
160 | 174 | if ($type == ';') { |
161 | 175 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | 176 | $result['address'] = trim(substr($body,1,9)); |
163 | 177 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
164 | 178 | $result['mmsi'] = trim(substr($body,1,9)); |
165 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
179 | + } else { |
|
180 | + $result['ident'] = trim(substr($body,1,9)); |
|
181 | + } |
|
166 | 182 | } elseif ($type == ',') { |
167 | 183 | // Invalid data or test data |
168 | 184 | return false; |
@@ -230,7 +246,9 @@ discard block |
||
230 | 246 | //$symbol_table = $matches[4]; |
231 | 247 | $lat = intval($lat_deg); |
232 | 248 | $lon = intval($lon_deg); |
233 | - if ($lat > 89 || $lon > 179) return false; |
|
249 | + if ($lat > 89 || $lon > 179) { |
|
250 | + return false; |
|
251 | + } |
|
234 | 252 | |
235 | 253 | /* |
236 | 254 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -240,8 +258,12 @@ discard block |
||
240 | 258 | */ |
241 | 259 | $latitude = $lat + floatval($lat_min)/60; |
242 | 260 | $longitude = $lon + floatval($lon_min)/60; |
243 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
244 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
261 | + if ($sind == 'S') { |
|
262 | + $latitude = 0-$latitude; |
|
263 | + } |
|
264 | + if ($wind == 'W') { |
|
265 | + $longitude = 0-$longitude; |
|
266 | + } |
|
245 | 267 | $result['latitude'] = $latitude; |
246 | 268 | $result['longitude'] = $longitude; |
247 | 269 | $body_parse = substr($body_parse,18); |
@@ -275,7 +297,9 @@ discard block |
||
275 | 297 | $body_parse = substr($body_parse,1); |
276 | 298 | $body_parse_len = strlen($body_parse); |
277 | 299 | $result['symbol_code'] = $symbol_code; |
278 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
300 | + if (isset($this->symbols[$symbol_code])) { |
|
301 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
302 | + } |
|
279 | 303 | if ($symbol_code != '_') { |
280 | 304 | } |
281 | 305 | //$body_parse = substr($body_parse,1); |
@@ -286,7 +310,9 @@ discard block |
||
286 | 310 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
287 | 311 | $course = substr($body_parse,0,3); |
288 | 312 | $tmp_s = intval($course); |
289 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
313 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
314 | + $result['heading'] = intval($course); |
|
315 | + } |
|
290 | 316 | $speed = substr($body_parse,4,3); |
291 | 317 | if ($speed != '...') { |
292 | 318 | //$result['speed'] = round($speed*1.852); |
@@ -327,10 +353,16 @@ discard block |
||
327 | 353 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
328 | 354 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
329 | 355 | |
330 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
331 | - else $result['latitude'] += $lat_off; |
|
332 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
333 | - else $result['longitude'] += $lon_off; |
|
356 | + if ($result['latitude'] < 0) { |
|
357 | + $result['latitude'] -= $lat_off; |
|
358 | + } else { |
|
359 | + $result['latitude'] += $lat_off; |
|
360 | + } |
|
361 | + if ($result['longitude'] < 0) { |
|
362 | + $result['longitude'] -= $lon_off; |
|
363 | + } else { |
|
364 | + $result['longitude'] += $lon_off; |
|
365 | + } |
|
334 | 366 | } |
335 | 367 | |
336 | 368 | $body_parse = substr($body_parse,6); |
@@ -369,27 +401,48 @@ discard block |
||
369 | 401 | $address = substr($id,2); |
370 | 402 | //print_r($matches); |
371 | 403 | $addressType = (intval(substr($id,0,2),16))&3; |
372 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
373 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
374 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
375 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
404 | + if ($addressType == 0) { |
|
405 | + $result['addresstype'] = "RANDOM"; |
|
406 | + } elseif ($addressType == 1) { |
|
407 | + $result['addresstype'] = "ICAO"; |
|
408 | + } elseif ($addressType == 2) { |
|
409 | + $result['addresstype'] = "FLARM"; |
|
410 | + } elseif ($addressType == 3) { |
|
411 | + $result['addresstype'] = "OGN"; |
|
412 | + } |
|
376 | 413 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
377 | 414 | $result['aircrafttype_code'] = $aircraftType; |
378 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
379 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
380 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
381 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
382 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
383 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
384 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
385 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
386 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
387 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
388 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
389 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
390 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
391 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
392 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
415 | + if ($aircraftType == 0) { |
|
416 | + $result['aircrafttype'] = "UNKNOWN"; |
|
417 | + } elseif ($aircraftType == 1) { |
|
418 | + $result['aircrafttype'] = "GLIDER"; |
|
419 | + } elseif ($aircraftType == 2) { |
|
420 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
421 | + } elseif ($aircraftType == 3) { |
|
422 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
423 | + } elseif ($aircraftType == 4) { |
|
424 | + $result['aircrafttype'] = "PARACHUTE"; |
|
425 | + } elseif ($aircraftType == 5) { |
|
426 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
427 | + } elseif ($aircraftType == 6) { |
|
428 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
429 | + } elseif ($aircraftType == 7) { |
|
430 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
431 | + } elseif ($aircraftType == 8) { |
|
432 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
433 | + } elseif ($aircraftType == 9) { |
|
434 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
435 | + } elseif ($aircraftType == 10) { |
|
436 | + $result['aircrafttype'] = "UFO"; |
|
437 | + } elseif ($aircraftType == 11) { |
|
438 | + $result['aircrafttype'] = "BALLOON"; |
|
439 | + } elseif ($aircraftType == 12) { |
|
440 | + $result['aircrafttype'] = "AIRSHIP"; |
|
441 | + } elseif ($aircraftType == 13) { |
|
442 | + $result['aircrafttype'] = "UAV"; |
|
443 | + } elseif ($aircraftType == 15) { |
|
444 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
445 | + } |
|
393 | 446 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
394 | 447 | $result['stealth'] = $stealth; |
395 | 448 | $result['address'] = $address; |
@@ -429,13 +482,21 @@ discard block |
||
429 | 482 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
430 | 483 | } |
431 | 484 | } |
432 | - } else $result['comment'] = trim($body_parse); |
|
485 | + } else { |
|
486 | + $result['comment'] = trim($body_parse); |
|
487 | + } |
|
433 | 488 | |
434 | 489 | } |
435 | 490 | //} |
436 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
437 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
438 | - if ($debug) print_r($result); |
|
491 | + if (isset($result['latitude'])) { |
|
492 | + $result['latitude'] = round($result['latitude'],4); |
|
493 | + } |
|
494 | + if (isset($result['longitude'])) { |
|
495 | + $result['longitude'] = round($result['longitude'],4); |
|
496 | + } |
|
497 | + if ($debug) { |
|
498 | + print_r($result); |
|
499 | + } |
|
439 | 500 | return $result; |
440 | 501 | } |
441 | 502 | |
@@ -444,12 +505,21 @@ discard block |
||
444 | 505 | $aprs_connect = 0; |
445 | 506 | $aprs_keep = 120; |
446 | 507 | $aprs_last_tx = time(); |
447 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
448 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
449 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
450 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
451 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
452 | - else $aprs_pass = '-1'; |
|
508 | + if (isset($globalAPRSversion)) { |
|
509 | + $aprs_version = $globalAPRSversion; |
|
510 | + } else { |
|
511 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
512 | + } |
|
513 | + if (isset($globalServerAPRSssid)) { |
|
514 | + $aprs_ssid = $globalServerAPRSssid; |
|
515 | + } else { |
|
516 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
517 | + } |
|
518 | + if (isset($globalServerAPRSpass)) { |
|
519 | + $aprs_pass = $globalServerAPRSpass; |
|
520 | + } else { |
|
521 | + $aprs_pass = '-1'; |
|
522 | + } |
|
453 | 523 | |
454 | 524 | $aprs_filter = ''; |
455 | 525 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -481,7 +551,9 @@ discard block |
||
481 | 551 | } |
482 | 552 | |
483 | 553 | public function send($data) { |
484 | - if ($this->connected === false) $this->connect(); |
|
554 | + if ($this->connected === false) { |
|
555 | + $this->connect(); |
|
556 | + } |
|
485 | 557 | $send = socket_send( $this->socket , $data , strlen($data),0); |
486 | 558 | if ($send === FALSE) { |
487 | 559 | socket_close($this->socket); |
@@ -503,18 +575,26 @@ discard block |
||
503 | 575 | //$w = '00'; |
504 | 576 | $custom = ''; |
505 | 577 | if ($ident != '') { |
506 | - if ($custom != '') $custom .= '/'; |
|
578 | + if ($custom != '') { |
|
579 | + $custom .= '/'; |
|
580 | + } |
|
507 | 581 | $custom .= 'CS='.$ident; |
508 | 582 | } |
509 | 583 | if ($squawk != '') { |
510 | - if ($custom != '') $custom .= '/'; |
|
584 | + if ($custom != '') { |
|
585 | + $custom .= '/'; |
|
586 | + } |
|
511 | 587 | $custom .= 'SQ='.$squawk; |
512 | 588 | } |
513 | 589 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
514 | - if ($custom != '') $custom .= '/'; |
|
590 | + if ($custom != '') { |
|
591 | + $custom .= '/'; |
|
592 | + } |
|
515 | 593 | $custom .= 'AI='.$aircraft_icao; |
516 | 594 | } |
517 | - if ($custom != '') $custom = ' '.$custom; |
|
595 | + if ($custom != '') { |
|
596 | + $custom = ' '.$custom; |
|
597 | + } |
|
518 | 598 | $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
519 | 599 | } |
520 | 600 | } |
@@ -532,30 +612,44 @@ discard block |
||
532 | 612 | //$w = '00'; |
533 | 613 | $custom = ''; |
534 | 614 | if ($ident != '') { |
535 | - if ($custom != '') $custom .= '/'; |
|
615 | + if ($custom != '') { |
|
616 | + $custom .= '/'; |
|
617 | + } |
|
536 | 618 | $custom .= 'CS='.str_replace(' ','_',$ident); |
537 | 619 | } |
538 | 620 | if ($typeid != '') { |
539 | - if ($custom != '') $custom .= '/'; |
|
621 | + if ($custom != '') { |
|
622 | + $custom .= '/'; |
|
623 | + } |
|
540 | 624 | $custom .= 'TI='.$typeid; |
541 | 625 | } |
542 | 626 | if ($statusid != '') { |
543 | - if ($custom != '') $custom .= '/'; |
|
627 | + if ($custom != '') { |
|
628 | + $custom .= '/'; |
|
629 | + } |
|
544 | 630 | $custom .= 'SI='.$statusid; |
545 | 631 | } |
546 | 632 | if ($imo != '') { |
547 | - if ($custom != '') $custom .= '/'; |
|
633 | + if ($custom != '') { |
|
634 | + $custom .= '/'; |
|
635 | + } |
|
548 | 636 | $custom .= 'IMO='.$imo; |
549 | 637 | } |
550 | 638 | if ($arrival_date != '') { |
551 | - if ($custom != '') $custom .= '/'; |
|
639 | + if ($custom != '') { |
|
640 | + $custom .= '/'; |
|
641 | + } |
|
552 | 642 | $custom .= 'AD='.strtotime($arrival_date); |
553 | 643 | } |
554 | 644 | if ($arrival_code != '') { |
555 | - if ($custom != '') $custom .= '/'; |
|
645 | + if ($custom != '') { |
|
646 | + $custom .= '/'; |
|
647 | + } |
|
556 | 648 | $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
557 | 649 | } |
558 | - if ($custom != '') $custom = ' '.$custom; |
|
650 | + if ($custom != '') { |
|
651 | + $custom = ' '.$custom; |
|
652 | + } |
|
559 | 653 | $altitude = 0; |
560 | 654 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
561 | 655 | } |
@@ -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) { |
@@ -118,8 +120,11 @@ discard block |
||
118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
120 | 122 | } |
121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
123 | + if ($filter_query_where == '' && $where) { |
|
124 | + $filter_query_where = ' WHERE'; |
|
125 | + } elseif ($filter_query_where != '' && $and) { |
|
126 | + $filter_query_where .= ' AND'; |
|
127 | + } |
|
123 | 128 | if ($filter_query_where != '') { |
124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
125 | 130 | } |
@@ -160,9 +165,13 @@ discard block |
||
160 | 165 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
161 | 166 | } |
162 | 167 | } |
163 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
168 | + if ($orderby_query == '') { |
|
169 | + $orderby_query = ' ORDER BY date DESC'; |
|
170 | + } |
|
164 | 171 | |
165 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
172 | + if (!isset($globalLiveInterval)) { |
|
173 | + $globalLiveInterval = '200'; |
|
174 | + } |
|
166 | 175 | if ($globalDBdriver == 'mysql') { |
167 | 176 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
168 | 177 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -185,7 +194,9 @@ discard block |
||
185 | 194 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
186 | 195 | date_default_timezone_set('UTC'); |
187 | 196 | $filter_query = $this->getFilter($filter,true,true); |
188 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
197 | + if (!isset($globalLiveInterval)) { |
|
198 | + $globalLiveInterval = '200'; |
|
199 | + } |
|
189 | 200 | if ($globalDBdriver == 'mysql') { |
190 | 201 | if (isset($globalArchive) && $globalArchive === TRUE) { |
191 | 202 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -228,7 +239,9 @@ discard block |
||
228 | 239 | |
229 | 240 | $filter_query = $this->getFilter($filter,true,true); |
230 | 241 | |
231 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
242 | + if (!isset($globalLiveInterval)) { |
|
243 | + $globalLiveInterval = '200'; |
|
244 | + } |
|
232 | 245 | if ($globalDBdriver == 'mysql') { |
233 | 246 | if (isset($globalArchive) && $globalArchive === TRUE) { |
234 | 247 | $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
@@ -273,7 +286,9 @@ discard block |
||
273 | 286 | global $globalDBdriver, $globalLiveInterval; |
274 | 287 | $filter_query = $this->getFilter($filter,true,true); |
275 | 288 | |
276 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
289 | + if (!isset($globalLiveInterval)) { |
|
290 | + $globalLiveInterval = '200'; |
|
291 | + } |
|
277 | 292 | if ($globalDBdriver == 'mysql') { |
278 | 293 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
279 | 294 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -303,7 +318,9 @@ discard block |
||
303 | 318 | { |
304 | 319 | global $globalDBdriver, $globalLiveInterval; |
305 | 320 | $Spotter = new Spotter($this->db); |
306 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
321 | + if (!isset($globalLiveInterval)) { |
|
322 | + $globalLiveInterval = '200'; |
|
323 | + } |
|
307 | 324 | $filter_query = $this->getFilter($filter); |
308 | 325 | |
309 | 326 | if (is_array($coord)) { |
@@ -311,7 +328,9 @@ discard block |
||
311 | 328 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
312 | 329 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
313 | 330 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
314 | - } else return array(); |
|
331 | + } else { |
|
332 | + return array(); |
|
333 | + } |
|
315 | 334 | if ($globalDBdriver == 'mysql') { |
316 | 335 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
317 | 336 | } else { |
@@ -332,7 +351,9 @@ discard block |
||
332 | 351 | { |
333 | 352 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
334 | 353 | $Spotter = new Spotter($this->db); |
335 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
354 | + if (!isset($globalLiveInterval)) { |
|
355 | + $globalLiveInterval = '200'; |
|
356 | + } |
|
336 | 357 | $filter_query = $this->getFilter($filter,true,true); |
337 | 358 | |
338 | 359 | if (is_array($coord)) { |
@@ -340,7 +361,9 @@ discard block |
||
340 | 361 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
341 | 362 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
342 | 363 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
343 | - } else return array(); |
|
364 | + } else { |
|
365 | + return array(); |
|
366 | + } |
|
344 | 367 | if ($globalDBdriver == 'mysql') { |
345 | 368 | if (isset($globalArchive) && $globalArchive === TRUE) { |
346 | 369 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -571,11 +594,15 @@ discard block |
||
571 | 594 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
572 | 595 | if ($globalDBdriver == 'mysql') { |
573 | 596 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
574 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
597 | + if ($liveinterval) { |
|
598 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
599 | + } |
|
575 | 600 | $query .= ' ORDER BY date'; |
576 | 601 | } else { |
577 | 602 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
578 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
603 | + if ($liveinterval) { |
|
604 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
605 | + } |
|
579 | 606 | $query .= ' ORDER BY date'; |
580 | 607 | } |
581 | 608 | |
@@ -670,7 +697,9 @@ discard block |
||
670 | 697 | $i++; |
671 | 698 | $j++; |
672 | 699 | if ($j == 30) { |
673 | - if ($globalDebug) echo "."; |
|
700 | + if ($globalDebug) { |
|
701 | + echo "."; |
|
702 | + } |
|
674 | 703 | try { |
675 | 704 | |
676 | 705 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -977,7 +1006,9 @@ discard block |
||
977 | 1006 | { |
978 | 1007 | return false; |
979 | 1008 | } |
980 | - } else return ''; |
|
1009 | + } else { |
|
1010 | + return ''; |
|
1011 | + } |
|
981 | 1012 | |
982 | 1013 | if ($longitude != '') |
983 | 1014 | { |
@@ -985,7 +1016,9 @@ discard block |
||
985 | 1016 | { |
986 | 1017 | return false; |
987 | 1018 | } |
988 | - } else return ''; |
|
1019 | + } else { |
|
1020 | + return ''; |
|
1021 | + } |
|
989 | 1022 | |
990 | 1023 | if ($waypoints != '') |
991 | 1024 | { |
@@ -1001,7 +1034,9 @@ discard block |
||
1001 | 1034 | { |
1002 | 1035 | return false; |
1003 | 1036 | } |
1004 | - } else $altitude = 0; |
|
1037 | + } else { |
|
1038 | + $altitude = 0; |
|
1039 | + } |
|
1005 | 1040 | |
1006 | 1041 | if ($heading != '') |
1007 | 1042 | { |
@@ -1009,7 +1044,9 @@ discard block |
||
1009 | 1044 | { |
1010 | 1045 | return false; |
1011 | 1046 | } |
1012 | - } else $heading = 0; |
|
1047 | + } else { |
|
1048 | + $heading = 0; |
|
1049 | + } |
|
1013 | 1050 | |
1014 | 1051 | if ($groundspeed != '') |
1015 | 1052 | { |
@@ -1017,9 +1054,13 @@ discard block |
||
1017 | 1054 | { |
1018 | 1055 | return false; |
1019 | 1056 | } |
1020 | - } else $groundspeed = 0; |
|
1057 | + } else { |
|
1058 | + $groundspeed = 0; |
|
1059 | + } |
|
1021 | 1060 | date_default_timezone_set('UTC'); |
1022 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1061 | + if ($date == '') { |
|
1062 | + $date = date("Y-m-d H:i:s", time()); |
|
1063 | + } |
|
1023 | 1064 | |
1024 | 1065 | |
1025 | 1066 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1063,14 +1104,24 @@ discard block |
||
1063 | 1104 | $arrival_airport_country = ''; |
1064 | 1105 | |
1065 | 1106 | |
1066 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1067 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1068 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1069 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1107 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1108 | + $squawk = NULL; |
|
1109 | + } |
|
1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1111 | + $verticalrate = NULL; |
|
1112 | + } |
|
1113 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1114 | + $groundspeed = 0; |
|
1115 | + } |
|
1116 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1117 | + $heading = 0; |
|
1118 | + } |
|
1070 | 1119 | |
1071 | 1120 | $query = ''; |
1072 | 1121 | if ($globalArchive) { |
1073 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1122 | + if ($globalDebug) { |
|
1123 | + echo '-- Delete previous data -- '; |
|
1124 | + } |
|
1074 | 1125 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1075 | 1126 | } |
1076 | 1127 | |
@@ -1087,10 +1138,14 @@ discard block |
||
1087 | 1138 | return "error : ".$e->getMessage(); |
1088 | 1139 | } |
1089 | 1140 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1090 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1141 | + if ($globalDebug) { |
|
1142 | + echo '(Add to SBS archive : '; |
|
1143 | + } |
|
1091 | 1144 | $SpotterArchive = new SpotterArchive($this->db); |
1092 | 1145 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1093 | - if ($globalDebug) echo $result.')'; |
|
1146 | + if ($globalDebug) { |
|
1147 | + echo $result.')'; |
|
1148 | + } |
|
1094 | 1149 | } |
1095 | 1150 | return "success"; |
1096 | 1151 |
@@ -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).'"'; |
|
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).'"'; |
|
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 |
@@ -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) { |
@@ -68,8 +70,11 @@ discard block |
||
68 | 70 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
69 | 71 | } |
70 | 72 | } |
71 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
72 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
73 | + if ($filter_query_where == '' && $where) { |
|
74 | + $filter_query_where = ' WHERE'; |
|
75 | + } elseif ($filter_query_where != '' && $and) { |
|
76 | + $filter_query_where .= ' AND'; |
|
77 | + } |
|
73 | 78 | if ($filter_query_where != '') { |
74 | 79 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
75 | 80 | } |
@@ -123,32 +128,54 @@ discard block |
||
123 | 128 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
124 | 129 | } elseif (isset($row['spotter_archive_output_id'])) { |
125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
126 | - */} |
|
127 | - elseif (isset($row['marineid'])) { |
|
131 | + */} elseif (isset($row['marineid'])) { |
|
128 | 132 | $temp_array['marine_id'] = $row['marineid']; |
129 | 133 | } else { |
130 | 134 | $temp_array['marine_id'] = ''; |
131 | 135 | } |
132 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
133 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
134 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
135 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
136 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
137 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
138 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
139 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
136 | + if (isset($row['fammarine_id'])) { |
|
137 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
138 | + } |
|
139 | + if (isset($row['mmsi'])) { |
|
140 | + $temp_array['mmsi'] = $row['mmsi']; |
|
141 | + } |
|
142 | + if (isset($row['type'])) { |
|
143 | + $temp_array['type'] = $row['type']; |
|
144 | + } |
|
145 | + if (isset($row['type_id'])) { |
|
146 | + $temp_array['type_id'] = $row['type_id']; |
|
147 | + } |
|
148 | + if (isset($row['ident'])) { |
|
149 | + $temp_array['ident'] = $row['ident']; |
|
150 | + } |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
140 | 160 | if (isset($row['heading'])) { |
141 | 161 | $temp_array['heading'] = $row['heading']; |
142 | 162 | $heading_direction = $this->parseDirection($row['heading']); |
143 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
163 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
165 | + } |
|
166 | + } |
|
167 | + if (isset($row['ground_speed'])) { |
|
168 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
144 | 169 | } |
145 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
146 | 170 | |
147 | 171 | if($temp_array['mmsi'] != "") |
148 | 172 | { |
149 | 173 | $Image = new Image($this->db); |
150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
151 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
174 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
175 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
176 | + } else { |
|
177 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
178 | + } |
|
152 | 179 | unset($Image); |
153 | 180 | if (count($image_array) > 0) { |
154 | 181 | $temp_array['image'] = $image_array[0]['image']; |
@@ -200,13 +227,21 @@ discard block |
||
200 | 227 | } |
201 | 228 | |
202 | 229 | $fromsource = NULL; |
203 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
204 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
205 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
230 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
231 | + $temp_array['source_name'] = $row['source_name']; |
|
232 | + } |
|
233 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
234 | + $temp_array['over_country'] = $row['over_country']; |
|
235 | + } |
|
236 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
237 | + $temp_array['distance'] = $row['distance']; |
|
238 | + } |
|
206 | 239 | $temp_array['query_number_rows'] = $num_rows; |
207 | 240 | $spotter_array[] = $temp_array; |
208 | 241 | } |
209 | - if ($num_rows == 0) return array(); |
|
242 | + if ($num_rows == 0) { |
|
243 | + return array(); |
|
244 | + } |
|
210 | 245 | $spotter_array[0]['query_number_rows'] = $num_rows; |
211 | 246 | return $spotter_array; |
212 | 247 | } |
@@ -232,8 +267,12 @@ discard block |
||
232 | 267 | { |
233 | 268 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
234 | 269 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
235 | - } else $limit_query = ""; |
|
236 | - } else $limit_query = ""; |
|
270 | + } else { |
|
271 | + $limit_query = ""; |
|
272 | + } |
|
273 | + } else { |
|
274 | + $limit_query = ""; |
|
275 | + } |
|
237 | 276 | if ($sort != "") |
238 | 277 | { |
239 | 278 | $search_orderby_array = $this->getOrderBy(); |
@@ -257,7 +296,9 @@ discard block |
||
257 | 296 | global $global_query; |
258 | 297 | |
259 | 298 | date_default_timezone_set('UTC'); |
260 | - if ($id == '') return array(); |
|
299 | + if ($id == '') { |
|
300 | + return array(); |
|
301 | + } |
|
261 | 302 | $additional_query = "marine_output.fammarine_id = :id"; |
262 | 303 | $query_values = array(':id' => $id); |
263 | 304 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -400,8 +441,11 @@ discard block |
||
400 | 441 | $query .= " ORDER BY marine_output.source_name ASC"; |
401 | 442 | |
402 | 443 | $sth = $this->db->prepare($query); |
403 | - if (!empty($query_values)) $sth->execute($query_values); |
|
404 | - else $sth->execute(); |
|
444 | + if (!empty($query_values)) { |
|
445 | + $sth->execute($query_values); |
|
446 | + } else { |
|
447 | + $sth->execute(); |
|
448 | + } |
|
405 | 449 | |
406 | 450 | $source_array = array(); |
407 | 451 | $temp_array = array(); |
@@ -456,8 +500,11 @@ discard block |
||
456 | 500 | $sth = $this->db->prepare($query); |
457 | 501 | $sth->execute(array(':mmsi' => $mmsi)); |
458 | 502 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
459 | - if (isset($result[0])) return $result[0]; |
|
460 | - else return array(); |
|
503 | + if (isset($result[0])) { |
|
504 | + return $result[0]; |
|
505 | + } else { |
|
506 | + return array(); |
|
507 | + } |
|
461 | 508 | } |
462 | 509 | |
463 | 510 | /* |
@@ -473,7 +520,9 @@ discard block |
||
473 | 520 | date_default_timezone_set($globalTimezone); |
474 | 521 | $datetime = new DateTime(); |
475 | 522 | $offset = $datetime->format('P'); |
476 | - } else $offset = '+00:00'; |
|
523 | + } else { |
|
524 | + $offset = '+00:00'; |
|
525 | + } |
|
477 | 526 | |
478 | 527 | if ($globalDBdriver == 'mysql') { |
479 | 528 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -677,9 +726,15 @@ discard block |
||
677 | 726 | $latitude = 0; |
678 | 727 | $longitude = 0; |
679 | 728 | } |
680 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
681 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
682 | - if ($arrival_date == '') $arrival_date = NULL; |
|
729 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
730 | + $heading = 0; |
|
731 | + } |
|
732 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
733 | + $groundspeed = 0; |
|
734 | + } |
|
735 | + if ($arrival_date == '') { |
|
736 | + $arrival_date = NULL; |
|
737 | + } |
|
683 | 738 | $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) |
684 | 739 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
685 | 740 | |
@@ -843,12 +898,18 @@ discard block |
||
843 | 898 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
844 | 899 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
845 | 900 | if ($olderthanmonths > 0) { |
846 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
847 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
901 | + if ($globalDBdriver == 'mysql') { |
|
902 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
903 | + } else { |
|
904 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
905 | + } |
|
848 | 906 | } |
849 | 907 | if ($sincedate != '') { |
850 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
851 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
908 | + if ($globalDBdriver == 'mysql') { |
|
909 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
910 | + } else { |
|
911 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
912 | + } |
|
852 | 913 | } |
853 | 914 | $query_values = array(); |
854 | 915 | if ($year != '') { |
@@ -879,7 +940,9 @@ discard block |
||
879 | 940 | } |
880 | 941 | } |
881 | 942 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
882 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
943 | + if ($limit) { |
|
944 | + $query .= " LIMIT 10 OFFSET 0"; |
|
945 | + } |
|
883 | 946 | |
884 | 947 | $sth = $this->db->prepare($query); |
885 | 948 | $sth->execute($query_values); |
@@ -914,7 +977,9 @@ discard block |
||
914 | 977 | date_default_timezone_set($globalTimezone); |
915 | 978 | $datetime = new DateTime(); |
916 | 979 | $offset = $datetime->format('P'); |
917 | - } else $offset = '+00:00'; |
|
980 | + } else { |
|
981 | + $offset = '+00:00'; |
|
982 | + } |
|
918 | 983 | |
919 | 984 | if ($globalDBdriver == 'mysql') { |
920 | 985 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -964,7 +1029,9 @@ discard block |
||
964 | 1029 | date_default_timezone_set($globalTimezone); |
965 | 1030 | $datetime = new DateTime(); |
966 | 1031 | $offset = $datetime->format('P'); |
967 | - } else $offset = '+00:00'; |
|
1032 | + } else { |
|
1033 | + $offset = '+00:00'; |
|
1034 | + } |
|
968 | 1035 | $filter_query = $this->getFilter($filters,true,true); |
969 | 1036 | if ($globalDBdriver == 'mysql') { |
970 | 1037 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1010,7 +1077,9 @@ discard block |
||
1010 | 1077 | date_default_timezone_set($globalTimezone); |
1011 | 1078 | $datetime = new DateTime(); |
1012 | 1079 | $offset = $datetime->format('P'); |
1013 | - } else $offset = '+00:00'; |
|
1080 | + } else { |
|
1081 | + $offset = '+00:00'; |
|
1082 | + } |
|
1014 | 1083 | $filter_query = $this->getFilter($filters,true,true); |
1015 | 1084 | if ($globalDBdriver == 'mysql') { |
1016 | 1085 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1058,7 +1127,9 @@ discard block |
||
1058 | 1127 | date_default_timezone_set($globalTimezone); |
1059 | 1128 | $datetime = new DateTime(); |
1060 | 1129 | $offset = $datetime->format('P'); |
1061 | - } else $offset = '+00:00'; |
|
1130 | + } else { |
|
1131 | + $offset = '+00:00'; |
|
1132 | + } |
|
1062 | 1133 | |
1063 | 1134 | if ($globalDBdriver == 'mysql') { |
1064 | 1135 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1107,7 +1178,9 @@ discard block |
||
1107 | 1178 | date_default_timezone_set($globalTimezone); |
1108 | 1179 | $datetime = new DateTime(); |
1109 | 1180 | $offset = $datetime->format('P'); |
1110 | - } else $offset = '+00:00'; |
|
1181 | + } else { |
|
1182 | + $offset = '+00:00'; |
|
1183 | + } |
|
1111 | 1184 | $filter_query = $this->getFilter($filters,true,true); |
1112 | 1185 | if ($globalDBdriver == 'mysql') { |
1113 | 1186 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1156,7 +1229,9 @@ discard block |
||
1156 | 1229 | date_default_timezone_set($globalTimezone); |
1157 | 1230 | $datetime = new DateTime(); |
1158 | 1231 | $offset = $datetime->format('P'); |
1159 | - } else $offset = '+00:00'; |
|
1232 | + } else { |
|
1233 | + $offset = '+00:00'; |
|
1234 | + } |
|
1160 | 1235 | |
1161 | 1236 | $orderby_sql = ''; |
1162 | 1237 | if ($orderby == "hour") |
@@ -1225,7 +1300,9 @@ discard block |
||
1225 | 1300 | date_default_timezone_set($globalTimezone); |
1226 | 1301 | $datetime = new DateTime($date); |
1227 | 1302 | $offset = $datetime->format('P'); |
1228 | - } else $offset = '+00:00'; |
|
1303 | + } else { |
|
1304 | + $offset = '+00:00'; |
|
1305 | + } |
|
1229 | 1306 | |
1230 | 1307 | if ($globalDBdriver == 'mysql') { |
1231 | 1308 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1273,7 +1350,9 @@ discard block |
||
1273 | 1350 | date_default_timezone_set($globalTimezone); |
1274 | 1351 | $datetime = new DateTime(); |
1275 | 1352 | $offset = $datetime->format('P'); |
1276 | - } else $offset = '+00:00'; |
|
1353 | + } else { |
|
1354 | + $offset = '+00:00'; |
|
1355 | + } |
|
1277 | 1356 | |
1278 | 1357 | if ($globalDBdriver == 'mysql') { |
1279 | 1358 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1337,8 +1416,11 @@ discard block |
||
1337 | 1416 | $query_values = array_merge($query_values,array(':month' => $month)); |
1338 | 1417 | } |
1339 | 1418 | } |
1340 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1341 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1419 | + if (empty($query_values)) { |
|
1420 | + $queryi .= $this->getFilter($filters); |
|
1421 | + } else { |
|
1422 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1423 | + } |
|
1342 | 1424 | |
1343 | 1425 | $sth = $this->db->prepare($queryi); |
1344 | 1426 | $sth->execute($query_values); |
@@ -1360,7 +1442,9 @@ discard block |
||
1360 | 1442 | date_default_timezone_set($globalTimezone); |
1361 | 1443 | $datetime = new DateTime(); |
1362 | 1444 | $offset = $datetime->format('P'); |
1363 | - } else $offset = '+00:00'; |
|
1445 | + } else { |
|
1446 | + $offset = '+00:00'; |
|
1447 | + } |
|
1364 | 1448 | |
1365 | 1449 | if ($globalDBdriver == 'mysql') { |
1366 | 1450 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1464,7 +1548,9 @@ discard block |
||
1464 | 1548 | */ |
1465 | 1549 | public function parseDirection($direction = 0) |
1466 | 1550 | { |
1467 | - if ($direction == '') $direction = 0; |
|
1551 | + if ($direction == '') { |
|
1552 | + $direction = 0; |
|
1553 | + } |
|
1468 | 1554 | $direction_array = array(); |
1469 | 1555 | $temp_array = array(); |
1470 | 1556 | |
@@ -1553,7 +1639,9 @@ discard block |
||
1553 | 1639 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1554 | 1640 | |
1555 | 1641 | $Connection = new Connection($this->db); |
1556 | - if (!$Connection->tableExists('countries')) return ''; |
|
1642 | + if (!$Connection->tableExists('countries')) { |
|
1643 | + return ''; |
|
1644 | + } |
|
1557 | 1645 | |
1558 | 1646 | try { |
1559 | 1647 | /* |
@@ -1573,9 +1661,13 @@ discard block |
||
1573 | 1661 | $sth->closeCursor(); |
1574 | 1662 | if (count($row) > 0) { |
1575 | 1663 | return $row; |
1576 | - } else return ''; |
|
1664 | + } else { |
|
1665 | + return ''; |
|
1666 | + } |
|
1577 | 1667 | } catch (PDOException $e) { |
1578 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1668 | + if (isset($globalDebug) && $globalDebug) { |
|
1669 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1670 | + } |
|
1579 | 1671 | return ''; |
1580 | 1672 | } |
1581 | 1673 | |
@@ -1593,7 +1685,9 @@ discard block |
||
1593 | 1685 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1594 | 1686 | |
1595 | 1687 | $Connection = new Connection($this->db); |
1596 | - if (!$Connection->tableExists('countries')) return ''; |
|
1688 | + if (!$Connection->tableExists('countries')) { |
|
1689 | + return ''; |
|
1690 | + } |
|
1597 | 1691 | |
1598 | 1692 | try { |
1599 | 1693 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1605,9 +1699,13 @@ discard block |
||
1605 | 1699 | $sth->closeCursor(); |
1606 | 1700 | if (count($row) > 0) { |
1607 | 1701 | return $row; |
1608 | - } else return ''; |
|
1702 | + } else { |
|
1703 | + return ''; |
|
1704 | + } |
|
1609 | 1705 | } catch (PDOException $e) { |
1610 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1706 | + if (isset($globalDebug) && $globalDebug) { |
|
1707 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1708 | + } |
|
1611 | 1709 | return ''; |
1612 | 1710 | } |
1613 | 1711 | |
@@ -1625,7 +1723,9 @@ discard block |
||
1625 | 1723 | { |
1626 | 1724 | global $globalBitlyAccessToken; |
1627 | 1725 | |
1628 | - if ($globalBitlyAccessToken == '') return $url; |
|
1726 | + if ($globalBitlyAccessToken == '') { |
|
1727 | + return $url; |
|
1728 | + } |
|
1629 | 1729 | |
1630 | 1730 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1631 | 1731 |