@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 121 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 122 | 122 | |
| 123 | 123 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 124 | 124 | if ($globalDBdriver == 'mysql') { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } else { |
| 128 | 128 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= 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; |
| 129 | 129 | } |
| 130 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 130 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 131 | 131 | |
| 132 | 132 | return $spotter_array; |
| 133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | global $globalDBdriver, $globalLiveInterval; |
| 144 | 144 | date_default_timezone_set('UTC'); |
| 145 | 145 | |
| 146 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 146 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 147 | 147 | |
| 148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | 159 | $sth->execute(); |
| 160 | - } catch(PDOException $e) { |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | echo $e->getMessage(); |
| 162 | 162 | die; |
| 163 | 163 | } |
@@ -177,15 +177,15 @@ discard block |
||
| 177 | 177 | global $globalDBdriver, $globalLiveInterval; |
| 178 | 178 | date_default_timezone_set('UTC'); |
| 179 | 179 | |
| 180 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 180 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 181 | 181 | |
| 182 | 182 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 183 | 183 | if ($globalDBdriver == 'mysql') { |
| 184 | - $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 |
|
| 184 | + $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 | 185 | 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' |
| 186 | 186 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 187 | 187 | } else { |
| 188 | - $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 |
|
| 188 | + $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 |
|
| 189 | 189 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 190 | 190 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | $sth = $this->db->prepare($query); |
| 195 | 195 | $sth->execute(); |
| 196 | - } catch(PDOException $e) { |
|
| 196 | + } catch (PDOException $e) { |
|
| 197 | 197 | echo $e->getMessage(); |
| 198 | 198 | die; |
| 199 | 199 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function getLiveMarineCount($filter = array()) |
| 211 | 211 | { |
| 212 | 212 | global $globalDBdriver, $globalLiveInterval; |
| 213 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 213 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 214 | 214 | |
| 215 | 215 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 216 | 216 | if ($globalDBdriver == 'mysql') { |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | try { |
| 222 | 222 | $sth = $this->db->prepare($query); |
| 223 | 223 | $sth->execute(); |
| 224 | - } catch(PDOException $e) { |
|
| 224 | + } catch (PDOException $e) { |
|
| 225 | 225 | echo $e->getMessage(); |
| 226 | 226 | die; |
| 227 | 227 | } |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | $filter_query = $this->getFilter($filter); |
| 245 | 245 | |
| 246 | 246 | if (is_array($coord)) { |
| 247 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | 251 | } else return array(); |
| 252 | 252 | if ($globalDBdriver == 'mysql') { |
| 253 | 253 | $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; |
@@ -272,17 +272,17 @@ discard block |
||
| 272 | 272 | $filter_query = $this->getFilter($filter); |
| 273 | 273 | |
| 274 | 274 | if (is_array($coord)) { |
| 275 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | 279 | } else return array(); |
| 280 | 280 | if ($globalDBdriver == 'mysql') { |
| 281 | 281 | $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 | 282 | 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." |
| 283 | 283 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 284 | 284 | } else { |
| 285 | - $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 |
|
| 285 | + $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 |
|
| 286 | 286 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= 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." |
| 287 | 287 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 288 | 288 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if ($interval == '1m') |
| 332 | 332 | { |
| 333 | 333 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 334 | - } else if ($interval == '15m'){ |
|
| 334 | + } else if ($interval == '15m') { |
|
| 335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 336 | 336 | } |
| 337 | 337 | } |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 343 | 343 | WHERE marine_live.latitude <> '' |
| 344 | 344 | AND marine_live.longitude <> '' |
| 345 | 345 | ".$additional_query." |
| 346 | 346 | HAVING distance < :radius |
| 347 | 347 | ORDER BY distance"; |
| 348 | 348 | |
| 349 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 349 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 350 | 350 | |
| 351 | 351 | return $spotter_array; |
| 352 | 352 | } |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | date_default_timezone_set('UTC'); |
| 365 | 365 | |
| 366 | 366 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 367 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 368 | 368 | |
| 369 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 369 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 370 | 370 | |
| 371 | 371 | return $spotter_array; |
| 372 | 372 | } |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | * @return Array the spotter information |
| 378 | 378 | * |
| 379 | 379 | */ |
| 380 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 380 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 381 | 381 | { |
| 382 | 382 | $Marine = new Marine($this->db); |
| 383 | 383 | date_default_timezone_set('UTC'); |
| 384 | 384 | |
| 385 | 385 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 386 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 387 | 387 | |
| 388 | - $date = date('c',$date); |
|
| 389 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 388 | + $date = date('c', $date); |
|
| 389 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 390 | 390 | |
| 391 | 391 | return $spotter_array; |
| 392 | 392 | } |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | date_default_timezone_set('UTC'); |
| 404 | 404 | |
| 405 | 405 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 407 | 407 | |
| 408 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 408 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 409 | 409 | |
| 410 | 410 | return $spotter_array; |
| 411 | 411 | } |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | * @return Array the spotter information |
| 417 | 417 | * |
| 418 | 418 | */ |
| 419 | - public function getDateLiveMarineDataById($id,$date) |
|
| 419 | + public function getDateLiveMarineDataById($id, $date) |
|
| 420 | 420 | { |
| 421 | 421 | $Marine = new Marine($this->db); |
| 422 | 422 | date_default_timezone_set('UTC'); |
| 423 | 423 | |
| 424 | 424 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | - $date = date('c',$date); |
|
| 427 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | + $date = date('c', $date); |
|
| 427 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 428 | 428 | |
| 429 | 429 | return $spotter_array; |
| 430 | 430 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | * @return Array the spotter information |
| 437 | 437 | * |
| 438 | 438 | */ |
| 439 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 439 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 440 | 440 | { |
| 441 | 441 | global $globalDBdriver, $globalLiveInterval; |
| 442 | 442 | date_default_timezone_set('UTC'); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(array(':id' => $id)); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | { |
| 474 | 474 | date_default_timezone_set('UTC'); |
| 475 | 475 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 476 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 476 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 477 | 477 | try { |
| 478 | 478 | |
| 479 | 479 | $sth = $this->db->prepare($query); |
| 480 | 480 | $sth->execute(array(':ident' => $ident)); |
| 481 | - } catch(PDOException $e) { |
|
| 481 | + } catch (PDOException $e) { |
|
| 482 | 482 | echo $e->getMessage(); |
| 483 | 483 | die; |
| 484 | 484 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $sth = $this->db->prepare($query); |
| 510 | 510 | $sth->execute(); |
| 511 | - } catch(PDOException $e) { |
|
| 511 | + } catch (PDOException $e) { |
|
| 512 | 512 | return "error"; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | $sth = $this->db->prepare($query); |
| 533 | 533 | $sth->execute(); |
| 534 | - } catch(PDOException $e) { |
|
| 534 | + } catch (PDOException $e) { |
|
| 535 | 535 | return "error"; |
| 536 | 536 | } |
| 537 | 537 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 538 | 538 | $i = 0; |
| 539 | - $j =0; |
|
| 539 | + $j = 0; |
|
| 540 | 540 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 541 | - foreach($all as $row) |
|
| 541 | + foreach ($all as $row) |
|
| 542 | 542 | { |
| 543 | 543 | $i++; |
| 544 | 544 | $j++; |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | if ($globalDebug) echo "."; |
| 547 | 547 | try { |
| 548 | 548 | |
| 549 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 549 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 550 | 550 | $sth->execute(); |
| 551 | - } catch(PDOException $e) { |
|
| 551 | + } catch (PDOException $e) { |
|
| 552 | 552 | return "error"; |
| 553 | 553 | } |
| 554 | 554 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | if ($i > 0) { |
| 560 | 560 | try { |
| 561 | 561 | |
| 562 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 562 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 563 | 563 | $sth->execute(); |
| 564 | - } catch(PDOException $e) { |
|
| 564 | + } catch (PDOException $e) { |
|
| 565 | 565 | return "error"; |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | return "error"; |
| 579 | 579 | } |
| 580 | 580 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -622,13 +622,13 @@ discard block |
||
| 622 | 622 | public function deleteLiveMarineDataByIdent($ident) |
| 623 | 623 | { |
| 624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 625 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 625 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 626 | 626 | |
| 627 | 627 | try { |
| 628 | 628 | |
| 629 | 629 | $sth = $this->db->prepare($query); |
| 630 | 630 | $sth->execute(array(':ident' => $ident)); |
| 631 | - } catch(PDOException $e) { |
|
| 631 | + } catch (PDOException $e) { |
|
| 632 | 632 | return "error"; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -644,13 +644,13 @@ discard block |
||
| 644 | 644 | public function deleteLiveMarineDataById($id) |
| 645 | 645 | { |
| 646 | 646 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 647 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 647 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 648 | 648 | |
| 649 | 649 | try { |
| 650 | 650 | |
| 651 | 651 | $sth = $this->db->prepare($query); |
| 652 | 652 | $sth->execute(array(':id' => $id)); |
| 653 | - } catch(PDOException $e) { |
|
| 653 | + } catch (PDOException $e) { |
|
| 654 | 654 | return "error"; |
| 655 | 655 | } |
| 656 | 656 | |
@@ -668,13 +668,13 @@ discard block |
||
| 668 | 668 | { |
| 669 | 669 | global $globalDBdriver, $globalTimezone; |
| 670 | 670 | if ($globalDBdriver == 'mysql') { |
| 671 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 671 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 672 | 672 | WHERE marine_live.ident = :ident |
| 673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 674 | 674 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 675 | 675 | $query_data = array(':ident' => $ident); |
| 676 | 676 | } else { |
| 677 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 677 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 678 | 678 | WHERE marine_live.ident = :ident |
| 679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 680 | 680 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $sth = $this->db->prepare($query); |
| 685 | 685 | $sth->execute($query_data); |
| 686 | - $ident_result=''; |
|
| 687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 686 | + $ident_result = ''; |
|
| 687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 688 | 688 | { |
| 689 | 689 | $ident_result = $row['ident']; |
| 690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | global $globalDBdriver, $globalTimezone; |
| 703 | 703 | if ($globalDBdriver == 'mysql') { |
| 704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 705 | 705 | WHERE marine_live.ident = :ident |
| 706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 708 | 708 | $query_data = array(':ident' => $ident); |
| 709 | 709 | } else { |
| 710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 711 | 711 | WHERE marine_live.ident = :ident |
| 712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $sth = $this->db->prepare($query); |
| 718 | 718 | $sth->execute($query_data); |
| 719 | - $ident_result=''; |
|
| 720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 719 | + $ident_result = ''; |
|
| 720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 721 | 721 | { |
| 722 | 722 | $ident_result = $row['fammarine_id']; |
| 723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
| 734 | 734 | { |
| 735 | 735 | global $globalDBdriver, $globalTimezone; |
| 736 | 736 | if ($globalDBdriver == 'mysql') { |
| 737 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 737 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 738 | 738 | WHERE marine_live.fammarine_id = :id |
| 739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 741 | 741 | $query_data = array(':id' => $id); |
| 742 | 742 | } else { |
| 743 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 743 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 744 | 744 | WHERE marine_live.fammarine_id = :id |
| 745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | $sth = $this->db->prepare($query); |
| 751 | 751 | $sth->execute($query_data); |
| 752 | - $ident_result=''; |
|
| 753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 752 | + $ident_result = ''; |
|
| 753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 754 | 754 | { |
| 755 | 755 | $ident_result = $row['fammarine_id']; |
| 756 | 756 | } |
@@ -767,13 +767,13 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | global $globalDBdriver, $globalTimezone; |
| 769 | 769 | if ($globalDBdriver == 'mysql') { |
| 770 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 770 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 771 | 771 | WHERE marine_live.mmsi = :mmsi |
| 772 | 772 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 773 | 773 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 774 | 774 | $query_data = array(':mmsi' => $mmsi); |
| 775 | 775 | } else { |
| 776 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 776 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 777 | 777 | WHERE marine_live.mmsi = :mmsi |
| 778 | 778 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 779 | 779 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | |
| 783 | 783 | $sth = $this->db->prepare($query); |
| 784 | 784 | $sth->execute($query_data); |
| 785 | - $ident_result=''; |
|
| 786 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 785 | + $ident_result = ''; |
|
| 786 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 787 | 787 | { |
| 788 | 788 | $ident_result = $row['fammarine_id']; |
| 789 | 789 | } |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * @return String success or false |
| 802 | 802 | * |
| 803 | 803 | */ |
| 804 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 804 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 805 | 805 | { |
| 806 | 806 | global $globalURL, $globalArchive, $globalDebug; |
| 807 | 807 | $Common = new Common(); |
@@ -853,26 +853,26 @@ discard block |
||
| 853 | 853 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 854 | 854 | |
| 855 | 855 | |
| 856 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 857 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 858 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 860 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 861 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 863 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 864 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 865 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 866 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 867 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 868 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 869 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 870 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 871 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 856 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 857 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 858 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 860 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 861 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 863 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 864 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 865 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 866 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 867 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 868 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 869 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 870 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 871 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 874 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 875 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 876 | 876 | if ($arrival_date == '') $arrival_date = NULL; |
| 877 | 877 | $query = ''; |
| 878 | 878 | if ($globalArchive) { |
@@ -882,18 +882,18 @@ discard block |
||
| 882 | 882 | $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) |
| 883 | 883 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 884 | 884 | |
| 885 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 885 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 886 | 886 | try { |
| 887 | 887 | $sth = $this->db->prepare($query); |
| 888 | 888 | $sth->execute($query_values); |
| 889 | - } catch(PDOException $e) { |
|
| 889 | + } catch (PDOException $e) { |
|
| 890 | 890 | return "error : ".$e->getMessage(); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 894 | 894 | if ($globalDebug) echo '(Add to Marine archive : '; |
| 895 | 895 | $MarineArchive = new MarineArchive($this->db); |
| 896 | - $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); |
|
| 896 | + $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 | 897 | if ($globalDebug) echo $result.')'; |
| 898 | 898 | } |
| 899 | 899 | return "success"; |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | public function getOrderBy() |
| 903 | 903 | { |
| 904 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 904 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 905 | 905 | return $orderby; |
| 906 | 906 | } |
| 907 | 907 | |
@@ -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 | } |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | private function urshift($n, $s) { |
| 93 | - return ($n >= 0) ? ($n >> $s) : |
|
| 94 | - (($n & 0x7fffffff) >> $s) | |
|
| 93 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
| 95 | 94 | (0x40000000 >> ($s - 1)); |
| 96 | 95 | } |
| 97 | 96 | |
@@ -103,7 +102,7 @@ discard block |
||
| 103 | 102 | //$split_input = str_split($input); |
| 104 | 103 | |
| 105 | 104 | /* Find the end of header checking for NULL bytes while doing it. */ |
| 106 | - $splitpos = strpos($input,':'); |
|
| 105 | + $splitpos = strpos($input, ':'); |
|
| 107 | 106 | |
| 108 | 107 | /* Check that end was found and body has at least one byte. */ |
| 109 | 108 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -113,15 +112,15 @@ discard block |
||
| 113 | 112 | |
| 114 | 113 | if ($debug) echo 'input : '.$input."\n"; |
| 115 | 114 | /* Save header and body. */ |
| 116 | - $body = substr($input,$splitpos+1,$input_len); |
|
| 115 | + $body = substr($input, $splitpos + 1, $input_len); |
|
| 117 | 116 | $body_len = strlen($body); |
| 118 | - $header = substr($input,0,$splitpos); |
|
| 117 | + $header = substr($input, 0, $splitpos); |
|
| 119 | 118 | //$header_len = strlen($header); |
| 120 | 119 | if ($debug) echo 'header : '.$header."\n"; |
| 121 | 120 | |
| 122 | 121 | /* Parse source, target and path. */ |
| 123 | 122 | //FLRDF0A52>APRS,qAS,LSTB |
| 124 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
| 123 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
| 125 | 124 | $ident = $matches[1]; |
| 126 | 125 | $all_elements = $matches[2]; |
| 127 | 126 | if ($ident == 'AIRCRAFT') { |
@@ -135,14 +134,14 @@ discard block |
||
| 135 | 134 | $result['ident'] = $ident; |
| 136 | 135 | } |
| 137 | 136 | } else return false; |
| 138 | - $elements = explode(',',$all_elements); |
|
| 137 | + $elements = explode(',', $all_elements); |
|
| 139 | 138 | $source = end($elements); |
| 140 | 139 | $result['source'] = $source; |
| 141 | 140 | foreach ($elements as $element) { |
| 142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 141 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
| 143 | 142 | //echo "ok"; |
| 144 | 143 | //if ($element == 'TCPIP*') return false; |
| 145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 144 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
| 146 | 145 | if ($debug) echo 'element : '.$element."\n"; |
| 147 | 146 | return false; |
| 148 | 147 | } |
@@ -155,14 +154,14 @@ discard block |
||
| 155 | 154 | */ |
| 156 | 155 | } |
| 157 | 156 | |
| 158 | - $type = substr($body,0,1); |
|
| 157 | + $type = substr($body, 0, 1); |
|
| 159 | 158 | if ($debug) echo 'type : '.$type."\n"; |
| 160 | 159 | if ($type == ';') { |
| 161 | 160 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 162 | - $result['address'] = trim(substr($body,1,9)); |
|
| 161 | + $result['address'] = trim(substr($body, 1, 9)); |
|
| 163 | 162 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 164 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
| 165 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 163 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
| 164 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
| 166 | 165 | } elseif ($type == ',') { |
| 167 | 166 | // Invalid data or test data |
| 168 | 167 | return false; |
@@ -170,24 +169,24 @@ discard block |
||
| 170 | 169 | |
| 171 | 170 | // Check for Timestamp |
| 172 | 171 | $find = false; |
| 173 | - $body_parse = substr($body,1); |
|
| 172 | + $body_parse = substr($body, 1); |
|
| 174 | 173 | //echo 'Body : '.$body."\n"; |
| 175 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
| 176 | - $body_parse = substr($body_parse,10); |
|
| 174 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
| 175 | + $body_parse = substr($body_parse, 10); |
|
| 177 | 176 | $find = true; |
| 178 | 177 | //echo $body_parse."\n"; |
| 179 | 178 | } |
| 180 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
| 181 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 179 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
| 180 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 182 | 181 | $find = true; |
| 183 | 182 | //echo $body_parse."\n"; |
| 184 | 183 | } |
| 185 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
| 186 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 184 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
| 185 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 187 | 186 | $find = true; |
| 188 | 187 | //echo $body_parse."\n"; |
| 189 | 188 | } |
| 190 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
| 189 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
| 191 | 190 | $find = true; |
| 192 | 191 | //print_r($matches); |
| 193 | 192 | $timestamp = $matches[0]; |
@@ -202,19 +201,19 @@ discard block |
||
| 202 | 201 | // This work or not ? |
| 203 | 202 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 204 | 203 | } |
| 205 | - $body_parse = substr($body_parse,7); |
|
| 204 | + $body_parse = substr($body_parse, 7); |
|
| 206 | 205 | $result['timestamp'] = $timestamp; |
| 207 | 206 | //echo date('Ymd H:i:s',$timestamp); |
| 208 | 207 | } |
| 209 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
| 208 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
| 210 | 209 | $find = true; |
| 211 | 210 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
| 212 | - $body_parse = substr($body_parse,8); |
|
| 211 | + $body_parse = substr($body_parse, 8); |
|
| 213 | 212 | $result['timestamp'] = $timestamp; |
| 214 | 213 | //echo date('Ymd H:i:s',$timestamp); |
| 215 | 214 | } |
| 216 | 215 | //if (strlen($body_parse) > 19) { |
| 217 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 216 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
| 218 | 217 | $find = true; |
| 219 | 218 | // 4658.70N/00707.78Ez |
| 220 | 219 | //print_r(str_split($body_parse)); |
@@ -240,11 +239,11 @@ discard block |
||
| 240 | 239 | */ |
| 241 | 240 | $latitude = $lat + floatval($lat_min)/60; |
| 242 | 241 | $longitude = $lon + floatval($lon_min)/60; |
| 243 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 244 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 242 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
| 243 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
| 245 | 244 | $result['latitude'] = $latitude; |
| 246 | 245 | $result['longitude'] = $longitude; |
| 247 | - $body_parse = substr($body_parse,18); |
|
| 246 | + $body_parse = substr($body_parse, 18); |
|
| 248 | 247 | $body_parse_len = strlen($body_parse); |
| 249 | 248 | } |
| 250 | 249 | $body_parse_len = strlen($body_parse); |
@@ -272,7 +271,7 @@ discard block |
||
| 272 | 271 | //echo $body_parse; |
| 273 | 272 | //if ($type != ';' && $type != '>') { |
| 274 | 273 | if ($type != '') { |
| 275 | - $body_parse = substr($body_parse,1); |
|
| 274 | + $body_parse = substr($body_parse, 1); |
|
| 276 | 275 | $body_parse_len = strlen($body_parse); |
| 277 | 276 | $result['symbol_code'] = $symbol_code; |
| 278 | 277 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -283,16 +282,16 @@ discard block |
||
| 283 | 282 | //$body_parse_len = strlen($body_parse); |
| 284 | 283 | if ($body_parse_len >= 7) { |
| 285 | 284 | |
| 286 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 287 | - $course = substr($body_parse,0,3); |
|
| 285 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
| 286 | + $course = substr($body_parse, 0, 3); |
|
| 288 | 287 | $tmp_s = intval($course); |
| 289 | 288 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
| 290 | - $speed = substr($body_parse,4,3); |
|
| 289 | + $speed = substr($body_parse, 4, 3); |
|
| 291 | 290 | if ($speed != '...') { |
| 292 | 291 | //$result['speed'] = round($speed*1.852); |
| 293 | 292 | $result['speed'] = intval($speed); |
| 294 | 293 | } |
| 295 | - $body_parse = substr($body_parse,7); |
|
| 294 | + $body_parse = substr($body_parse, 7); |
|
| 296 | 295 | } |
| 297 | 296 | // Check PHGR, PHG, RNG |
| 298 | 297 | } |
@@ -302,12 +301,12 @@ discard block |
||
| 302 | 301 | } |
| 303 | 302 | */ |
| 304 | 303 | if (strlen($body_parse) > 0) { |
| 305 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 304 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
| 306 | 305 | $altitude = intval($matches[1]); |
| 307 | 306 | //$result['altitude'] = round($altitude*0.3048); |
| 308 | 307 | $result['altitude'] = $altitude; |
| 309 | 308 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
| 310 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 309 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
| 311 | 310 | } |
| 312 | 311 | } |
| 313 | 312 | |
@@ -319,13 +318,13 @@ discard block |
||
| 319 | 318 | */ |
| 320 | 319 | // DAO |
| 321 | 320 | |
| 322 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 321 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
| 323 | 322 | |
| 324 | 323 | $dao = $matches[1]; |
| 325 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 324 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
| 326 | 325 | $dao_split = str_split($dao); |
| 327 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 328 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 326 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
| 327 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
| 329 | 328 | |
| 330 | 329 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 331 | 330 | else $result['latitude'] += $lat_off; |
@@ -333,47 +332,47 @@ discard block |
||
| 333 | 332 | else $result['longitude'] += $lon_off; |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | - $body_parse = substr($body_parse,6); |
|
| 335 | + $body_parse = substr($body_parse, 6); |
|
| 337 | 336 | } |
| 338 | 337 | |
| 339 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 340 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
| 338 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
| 339 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
| 341 | 340 | } |
| 342 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 341 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
| 343 | 342 | $result['squawk'] = $matches[1]; |
| 344 | 343 | } |
| 345 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 344 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
| 346 | 345 | $result['aircraft_icao'] = $matches[1]; |
| 347 | 346 | } |
| 348 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
| 347 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
| 349 | 348 | $result['typeid'] = $matches[1]; |
| 350 | 349 | } |
| 351 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
| 350 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
| 352 | 351 | $result['statusid'] = $matches[1]; |
| 353 | 352 | } |
| 354 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
| 353 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
| 355 | 354 | $result['imo'] = $matches[1]; |
| 356 | 355 | } |
| 357 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
| 356 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
| 358 | 357 | $result['arrival_date'] = $matches[1]; |
| 359 | 358 | } |
| 360 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
| 361 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
| 359 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
| 360 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
| 362 | 361 | } |
| 363 | 362 | // OGN comment |
| 364 | 363 | // echo "Before OGN : ".$body_parse."\n"; |
| 365 | 364 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
| 366 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 365 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
| 367 | 366 | $id = $matches[1]; |
| 368 | 367 | //$mode = substr($id,0,2); |
| 369 | - $address = substr($id,2); |
|
| 368 | + $address = substr($id, 2); |
|
| 370 | 369 | //print_r($matches); |
| 371 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
| 370 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
| 372 | 371 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
| 373 | 372 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
| 374 | 373 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
| 375 | 374 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
| 376 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
| 375 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
| 377 | 376 | $result['aircrafttype_code'] = $aircraftType; |
| 378 | 377 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
| 379 | 378 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -390,7 +389,7 @@ discard block |
||
| 390 | 389 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
| 391 | 390 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
| 392 | 391 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
| 393 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
| 392 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
| 394 | 393 | $result['stealth'] = $stealth; |
| 395 | 394 | $result['address'] = $address; |
| 396 | 395 | } |
@@ -402,77 +401,77 @@ discard block |
||
| 402 | 401 | //$body_parse = substr($body_parse,1); |
| 403 | 402 | //$body_parse_len = strlen($body_parse); |
| 404 | 403 | |
| 405 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 404 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 406 | 405 | $result['wind_dir'] = intval($matches[1]); |
| 407 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 408 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 409 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 410 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 411 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 406 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
| 407 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
| 408 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
| 409 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 410 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 412 | 411 | $result['wind_dir'] = intval($matches[1]); |
| 413 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 414 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 415 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 417 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 412 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 413 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 414 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
| 415 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 416 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 418 | 417 | $result['wind_dir'] = intval($matches[1]); |
| 419 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 420 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 421 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 422 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 418 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 419 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 420 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 421 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 423 | 422 | $result['wind_dir'] = intval($matches[1]); |
| 424 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 425 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 426 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 423 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 424 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 425 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 427 | 426 | } |
| 428 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 429 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
| 427 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
| 428 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
| 430 | 429 | } |
| 431 | 430 | } |
| 432 | 431 | } else $result['comment'] = trim($body_parse); |
| 433 | 432 | |
| 434 | 433 | } |
| 435 | 434 | //} |
| 436 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 437 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 435 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
| 436 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
| 438 | 437 | if ($debug) print_r($result); |
| 439 | 438 | return $result; |
| 440 | 439 | } |
| 441 | 440 | |
| 442 | 441 | public function connect() { |
| 443 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 442 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 444 | 443 | $aprs_connect = 0; |
| 445 | 444 | $aprs_keep = 120; |
| 446 | 445 | $aprs_last_tx = time(); |
| 447 | 446 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 448 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 447 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 449 | 448 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
| 450 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 449 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 451 | 450 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
| 452 | 451 | else $aprs_pass = '-1'; |
| 453 | 452 | |
| 454 | - $aprs_filter = ''; |
|
| 453 | + $aprs_filter = ''; |
|
| 455 | 454 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 456 | 455 | $Common = new Common(); |
| 457 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
| 456 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
| 458 | 457 | if ($s !== false) { |
| 459 | 458 | echo 'Connected to APRS server! '."\n"; |
| 460 | 459 | $authstart = time(); |
| 461 | 460 | $this->socket = $s; |
| 462 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 463 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
| 461 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
| 462 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
| 464 | 463 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
| 465 | 464 | echo 'APRS user verified !'."\n"; |
| 466 | 465 | $this->connected = true; |
| 467 | 466 | return true; |
| 468 | 467 | break; |
| 469 | 468 | } |
| 470 | - if (time()-$authstart > 5) { |
|
| 469 | + if (time() - $authstart > 5) { |
|
| 471 | 470 | echo 'APRS timeout'."\n"; |
| 472 | 471 | break; |
| 473 | 472 | } |
| 474 | 473 | } |
| 475 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
|
| 474 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE); |
|
| 476 | 475 | } |
| 477 | 476 | } |
| 478 | 477 | |
@@ -482,7 +481,7 @@ discard block |
||
| 482 | 481 | |
| 483 | 482 | public function send($data) { |
| 484 | 483 | if ($this->connected === false) $this->connect(); |
| 485 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
| 484 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
| 486 | 485 | if ($send === FALSE) { |
| 487 | 486 | socket_close($this->socket); |
| 488 | 487 | $this->connect(); |
@@ -491,14 +490,14 @@ discard block |
||
| 491 | 490 | } |
| 492 | 491 | |
| 493 | 492 | class APRSSpotter extends APRS { |
| 494 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
| 493 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
| 495 | 494 | $Common = new Common(); |
| 496 | 495 | if ($latitude != '' && $longitude != '') { |
| 497 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 498 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 499 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 500 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 501 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 496 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 497 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 498 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 499 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 500 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 502 | 501 | $w = $w1.$w2; |
| 503 | 502 | //$w = '00'; |
| 504 | 503 | $custom = ''; |
@@ -515,25 +514,25 @@ discard block |
||
| 515 | 514 | $custom .= 'AI='.$aircraft_icao; |
| 516 | 515 | } |
| 517 | 516 | if ($custom != '') $custom = ' '.$custom; |
| 518 | - $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"); |
|
| 517 | + $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 | 518 | } |
| 520 | 519 | } |
| 521 | 520 | } |
| 522 | 521 | class APRSMarine extends APRS { |
| 523 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
| 522 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
| 524 | 523 | $Common = new Common(); |
| 525 | 524 | if ($latitude != '' && $longitude != '') { |
| 526 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 527 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 528 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 529 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 530 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 525 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 526 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 527 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 528 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 529 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 531 | 530 | $w = $w1.$w2; |
| 532 | 531 | //$w = '00'; |
| 533 | 532 | $custom = ''; |
| 534 | 533 | if ($ident != '') { |
| 535 | 534 | if ($custom != '') $custom .= '/'; |
| 536 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
| 535 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
| 537 | 536 | } |
| 538 | 537 | if ($typeid != '') { |
| 539 | 538 | if ($custom != '') $custom .= '/'; |
@@ -553,11 +552,11 @@ discard block |
||
| 553 | 552 | } |
| 554 | 553 | if ($arrival_code != '') { |
| 555 | 554 | if ($custom != '') $custom .= '/'; |
| 556 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
| 555 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
| 557 | 556 | } |
| 558 | 557 | if ($custom != '') $custom = ' '.$custom; |
| 559 | 558 | $altitude = 0; |
| 560 | - $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"); |
|
| 559 | + $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 | 560 | } |
| 562 | 561 | } |
| 563 | 562 | } |
@@ -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 | |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | * @return Array the images list |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 21 | 21 | { |
| 22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 25 | 25 | $reg = $registration; |
| 26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
| 27 | 27 | $reg = trim($reg); |
| 28 | - $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 |
|
| 28 | + $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 | 29 | FROM spotter_image |
| 30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
| 31 | 31 | $sth = $this->db->prepare($query); |
| 32 | 32 | $sth->execute(array(':registration' => $reg)); |
| 33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 34 | 34 | if (!empty($result)) return $result; |
| 35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 36 | 36 | else return array(); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * @return Array the images list |
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
| 45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
| 46 | 46 | { |
| 47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 50 | 50 | $name = trim($name); |
| 51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 52 | 52 | FROM marine_image |
| 53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
| 54 | 54 | $query_data = array(':mmsi' => $mmsi); |
| 55 | 55 | if ($imo != '') { |
| 56 | 56 | $query .= " AND marine_image.imo = :imo"; |
| 57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
| 57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
| 58 | 58 | } |
| 59 | 59 | if ($name != '') { |
| 60 | 60 | $query .= " AND marine_image.name = :name"; |
| 61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
| 61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
| 62 | 62 | } |
| 63 | 63 | $query .= " LIMIT 1"; |
| 64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 81 | 81 | if ($copyright != '') { |
| 82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 83 | - $copyright = str_replace('© ','',$copyright); |
|
| 84 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 83 | + $copyright = str_replace('© ', '', $copyright); |
|
| 84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 85 | 85 | } |
| 86 | 86 | return $copyright; |
| 87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | * @return String either success or error |
| 93 | 93 | * |
| 94 | 94 | */ |
| 95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 96 | 96 | { |
| 97 | - global $globalDebug,$globalAircraftImageFetch; |
|
| 97 | + global $globalDebug, $globalAircraftImageFetch; |
|
| 98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
| 99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 100 | 100 | $registration = trim($registration); |
| 101 | 101 | //getting the aircraft image |
| 102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 107 | 107 | if ($image_url['original'] != '') { |
| 108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
| 109 | - $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)"; |
|
| 109 | + $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 | 110 | try { |
| 111 | 111 | $sth = $this->db->prepare($query); |
| 112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 113 | - } catch(PDOException $e) { |
|
| 112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 113 | + } catch (PDOException $e) { |
|
| 114 | 114 | echo $e->getMessage()."\n"; |
| 115 | 115 | return "error"; |
| 116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | * @return String either success or error |
| 125 | 125 | * |
| 126 | 126 | */ |
| 127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
| 127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
| 128 | 128 | { |
| 129 | - global $globalDebug,$globalMarineImageFetch; |
|
| 129 | + global $globalDebug, $globalMarineImageFetch; |
|
| 130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
| 131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 134 | 134 | $name = trim($name); |
| 135 | 135 | $Marine = new Marine($this->db); |
| 136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | //getting the aircraft image |
| 146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
| 147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
| 147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
| 148 | 148 | if ($image_url['original'] != '') { |
| 149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
| 150 | - $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)"; |
|
| 150 | + $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 | 151 | try { |
| 152 | 152 | $sth = $this->db->prepare($query); |
| 153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 154 | - } catch(PDOException $e) { |
|
| 153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 154 | + } catch (PDOException $e) { |
|
| 155 | 155 | echo $e->getMessage()."\n"; |
| 156 | 156 | return "error"; |
| 157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 172 | 172 | $Spotter = new Spotter($this->db); |
| 173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 175 | 175 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
| 187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
| 188 | 188 | else $aircraft_name = ''; |
| 189 | 189 | $aircraft_registration = $aircraft_icao; |
| 190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 191 | 191 | unset($Spotter); |
| 192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 193 | 193 | foreach ($globalAircraftImageSources as $source) { |
| 194 | 194 | $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); |
|
| 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 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 206 | 206 | } |
| 207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
| 208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
| 220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
| 221 | 221 | { |
| 222 | 222 | global $globalMarineImageSources; |
| 223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 224 | 224 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 226 | 226 | $name = trim($name); |
| 227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 228 | 228 | /* |
| 229 | 229 | $Marine = new Marine($this->db); |
| 230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | unset($Marine); |
| 238 | 238 | */ |
| 239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
| 240 | 240 | foreach ($globalMarineImageSources as $source) { |
| 241 | 241 | $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); |
|
| 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 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 248 | 248 | } |
| 249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
| 257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 258 | 258 | * |
| 259 | 259 | */ |
| 260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
| 260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
| 261 | 261 | $Common = new Common(); |
| 262 | 262 | // If aircraft registration is only number, also check with aircraft model |
| 263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 265 | 265 | } else { |
| 266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 268 | 268 | } |
| 269 | 269 | $data = $Common->getData($url); |
| 270 | 270 | if ($xml = simplexml_load_string($data)) { |
| 271 | 271 | if (isset($xml->channel->item)) { |
| 272 | 272 | $image_url = array(); |
| 273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
| 275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 278 | 278 | $image_url['source'] = 'planespotters'; |
| 279 | 279 | return $image_url; |
| 280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
| 290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 291 | 291 | * |
| 292 | 292 | */ |
| 293 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 294 | 294 | $Common = new Common(); |
| 295 | 295 | if ($type == 'aircraft') { |
| 296 | 296 | // If aircraft registration is only number, also check with aircraft model |
| 297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 299 | 299 | } else { |
| 300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 301 | 301 | } |
| 302 | 302 | } elseif ($type == 'marine') { |
| 303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $data = $Common->getData($url); |
| 307 | 307 | if ($xml = simplexml_load_string($data)) { |
| 308 | 308 | if (isset($xml->channel->item->link)) { |
| 309 | 309 | $image_url = array(); |
| 310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
| 312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 313 | 313 | $image_url['original'] = $original_url; |
| 314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 316 | 316 | $image_url['source'] = 'deviantart'; |
| 317 | 317 | return $image_url; |
| 318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
| 328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 329 | 329 | * |
| 330 | 330 | */ |
| 331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 332 | 332 | $Common = new Common(); |
| 333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 334 | 334 | $data = $Common->getData($url); |
| 335 | 335 | $dom = new DOMDocument(); |
| 336 | 336 | @$dom->loadHTML($data); |
| 337 | 337 | $all_pics = array(); |
| 338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 340 | 340 | $all_pics[] = $image->getAttribute('src'); |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | $all_authors = array(); |
| 344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 346 | 346 | $all_authors[] = $author->getAttribute('content'); |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | $all_ref = array(); |
| 350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 351 | 351 | $all_ref[] = $link->getAttribute('href'); |
| 352 | 352 | } |
| 353 | 353 | if (isset($all_pics[0])) { |
| 354 | 354 | $image_url = array(); |
| 355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
| 356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 357 | 357 | $image_url['copyright'] = $all_authors[0]; |
| 358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
| 370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 371 | 371 | * |
| 372 | 372 | */ |
| 373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 374 | 374 | $Common = new Common(); |
| 375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 376 | 376 | $data = $Common->getData($url); |
| 377 | 377 | $dom = new DOMDocument(); |
| 378 | 378 | @$dom->loadHTML($data); |
| 379 | 379 | $all_pics = array(); |
| 380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 381 | 381 | $all_pics[] = $image->getAttribute('src'); |
| 382 | 382 | } |
| 383 | 383 | $all_links = array(); |
| 384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 386 | 386 | } |
| 387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 388 | 388 | $image_url = array(); |
| 389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
| 392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 405 | 405 | * |
| 406 | 406 | */ |
| 407 | - public function fromFlickr($type,$registration,$name='') { |
|
| 407 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 408 | 408 | $Common = new Common(); |
| 409 | 409 | if ($type == 'aircraft') { |
| 410 | 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); |
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | $data = $Common->getData($url); |
| 417 | 417 | if ($xml = simplexml_load_string($data)) { |
| 418 | 418 | if (isset($xml->channel->item)) { |
| 419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 420 | 420 | $image_url = array(); |
| 421 | 421 | $image_url['thumbnail'] = $original_url; |
| 422 | 422 | $image_url['original'] = $original_url; |
| 423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 425 | 425 | $image_url['source'] = 'flickr'; |
| 426 | 426 | return $image_url; |
| 427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
| 432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 433 | 433 | $Common = new Common(); |
| 434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 454 | 454 | * |
| 455 | 455 | */ |
| 456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 457 | 457 | global $globalImageBingKey; |
| 458 | 458 | $Common = new Common(); |
| 459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 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 | 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'; |
| 466 | 466 | } |
| 467 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 468 | - $data = $Common->getData($url,'get','',$headers); |
|
| 467 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 468 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 469 | 469 | $result = json_decode($data); |
| 470 | 470 | if (isset($result->d->results[0]->MediaUrl)) { |
| 471 | 471 | $image_url = array(); |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 491 | 491 | * |
| 492 | 492 | */ |
| 493 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 493 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 494 | 494 | $Common = new Common(); |
| 495 | 495 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 496 | 496 | $data = $Common->getData($url); |
| 497 | 497 | $result = json_decode($data); |
| 498 | 498 | if (isset($result->count) && $result->count > 0) { |
| 499 | 499 | $image_url = array(); |
| 500 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 500 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 501 | 501 | $image_url['source_website'] = $result->data[0]->link; |
| 502 | 502 | $image_url['thumbnail'] = $result->data[0]->image; |
| 503 | 503 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 516 | 516 | * |
| 517 | 517 | */ |
| 518 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 518 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 519 | 519 | $Common = new Common(); |
| 520 | 520 | if ($type == 'aircraft') { |
| 521 | 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); |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $result = json_decode($data); |
| 529 | 529 | if (isset($result->query->search[0]->title)) { |
| 530 | 530 | $fileo = $result->query->search[0]->title; |
| 531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 531 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 532 | 532 | $file = urlencode($fileo); |
| 533 | 533 | $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 | 534 | $data2 = $Common->getData($url2); |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | if (isset($result2->query->pages)) { |
| 554 | 554 | foreach ($result2->query->pages as $page) { |
| 555 | 555 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 556 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 556 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 557 | 557 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 558 | 558 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 559 | 559 | } |
| 560 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 560 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 561 | 561 | return $image_url; |
| 562 | 562 | } |
| 563 | 563 | } |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 577 | 577 | * |
| 578 | 578 | */ |
| 579 | - public function fromCustomSource($type,$registration,$name='') { |
|
| 579 | + public function fromCustomSource($type, $registration, $name = '') { |
|
| 580 | 580 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 581 | 581 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 582 | 582 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -593,15 +593,15 @@ discard block |
||
| 593 | 593 | print_r($source); |
| 594 | 594 | print_r($customsources); |
| 595 | 595 | } |
| 596 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 597 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 596 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 597 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 598 | 598 | if ($Common->urlexist($url)) { |
| 599 | 599 | $image_url = array(); |
| 600 | 600 | $image_url['thumbnail'] = $url_thumbnail; |
| 601 | 601 | $image_url['original'] = $url; |
| 602 | 602 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 603 | 603 | else $exifCopyright = ''; |
| 604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 604 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 605 | 605 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 606 | 606 | else $image_url['copyright'] = $source['source_website']; |
| 607 | 607 | $image_url['source_website'] = $source['source_website']; |
@@ -625,19 +625,19 @@ discard block |
||
| 625 | 625 | print_r($source); |
| 626 | 626 | print_r($customsources); |
| 627 | 627 | } |
| 628 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 629 | - $url = str_replace('{mmsi}',$registration,$url); |
|
| 630 | - $url = str_replace('{name}',$name,$url); |
|
| 631 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 632 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
| 633 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
| 628 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 629 | + $url = str_replace('{mmsi}', $registration, $url); |
|
| 630 | + $url = str_replace('{name}', $name, $url); |
|
| 631 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 632 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
| 633 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
| 634 | 634 | if ($Common->urlexist($url)) { |
| 635 | 635 | $image_url = array(); |
| 636 | 636 | $image_url['thumbnail'] = $url_thumbnail; |
| 637 | 637 | $image_url['original'] = $url; |
| 638 | 638 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 639 | 639 | else $exifCopyright = ''; |
| 640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 640 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 641 | 641 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 642 | 642 | else $image_url['copyright'] = $source['source_website']; |
| 643 | 643 | $image_url['source_website'] = $source['source_website']; |
@@ -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 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @return Array the SQL part |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 73 | 73 | if ($filter_query_where != '') { |
| 74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 75 | 75 | } |
| 76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
| 77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return Array the spotter information |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
| 92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
| 107 | 107 | $sth->execute($params); |
| 108 | 108 | } catch (PDOException $e) { |
| 109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 110 | 110 | exit(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $num_rows = 0; |
| 114 | 114 | $spotter_array = array(); |
| 115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | 116 | { |
| 117 | 117 | $num_rows++; |
| 118 | 118 | $temp_array = array(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 146 | 146 | |
| 147 | - if($temp_array['mmsi'] != "") |
|
| 147 | + if ($temp_array['mmsi'] != "") |
|
| 148 | 148 | { |
| 149 | 149 | $Image = new Image($this->db); |
| 150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 150 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 151 | 151 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 152 | 152 | unset($Image); |
| 153 | 153 | if (count($image_array) > 0) { |
@@ -183,17 +183,17 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 185 | 185 | } else { |
| 186 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 186 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 187 | 187 | } |
| 188 | 188 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 189 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 190 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 189 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 191 | 191 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 192 | 192 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 193 | 193 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 194 | 194 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 195 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 196 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 195 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 197 | 197 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | if ($limit != "") |
| 227 | 227 | { |
| 228 | 228 | $limit_array = explode(",", $limit); |
| 229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | 231 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 232 | 232 | { |
| 233 | 233 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | } else { |
| 242 | 242 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 243 | 243 | } |
| 244 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 245 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 244 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 245 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 246 | 246 | return $spotter_array; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | if ($id == '') return array(); |
| 261 | 261 | $additional_query = "marine_output.fammarine_id = :id"; |
| 262 | 262 | $query_values = array(':id' => $id); |
| 263 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 264 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 263 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 264 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 265 | 265 | return $spotter_array; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $query_values = array(); |
| 281 | 281 | $limit_query = ''; |
| 282 | 282 | $additional_query = ''; |
| 283 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 283 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 284 | 284 | if ($ident != "") |
| 285 | 285 | { |
| 286 | 286 | if (!is_string($ident)) |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | { |
| 297 | 297 | $limit_array = explode(",", $limit); |
| 298 | 298 | |
| 299 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 299 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | 301 | |
| 302 | 302 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 303 | 303 | { |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | return $spotter_array; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 324 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 325 | 325 | { |
| 326 | 326 | global $global_query, $globalTimezone, $globalDBdriver; |
| 327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $limit_query = ''; |
| 330 | 330 | $additional_query = ''; |
| 331 | 331 | |
| 332 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 332 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 333 | 333 | |
| 334 | 334 | if ($date != "") |
| 335 | 335 | { |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | { |
| 356 | 356 | $limit_array = explode(",", $limit); |
| 357 | 357 | |
| 358 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 358 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | 360 | |
| 361 | 361 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 362 | 362 | { |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | * @return Array list of source name |
| 388 | 388 | * |
| 389 | 389 | */ |
| 390 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 390 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 391 | 391 | { |
| 392 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 392 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 393 | 393 | $query_values = array(); |
| 394 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 394 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 395 | 395 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 396 | 396 | if ($type != '') { |
| 397 | 397 | $query_values = array(':type' => $type); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $source_array = array(); |
| 407 | 407 | $temp_array = array(); |
| 408 | 408 | |
| 409 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 409 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 410 | 410 | { |
| 411 | 411 | $temp_array['source_name'] = $row['source_name']; |
| 412 | 412 | $source_array[] = $temp_array; |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | public function getAllIdents($filters = array()) |
| 425 | 425 | { |
| 426 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 427 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 426 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 427 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 428 | 428 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 429 | 429 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $ident_array = array(); |
| 435 | 435 | $temp_array = array(); |
| 436 | 436 | |
| 437 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 437 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 438 | 438 | { |
| 439 | 439 | $temp_array['ident'] = $row['ident']; |
| 440 | 440 | $ident_array[] = $temp_array; |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function getIdentity($mmsi) |
| 453 | 453 | { |
| 454 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 454 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 455 | 455 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -476,12 +476,12 @@ discard block |
||
| 476 | 476 | } else $offset = '+00:00'; |
| 477 | 477 | |
| 478 | 478 | if ($globalDBdriver == 'mysql') { |
| 479 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 479 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 480 | 480 | FROM marine_output |
| 481 | 481 | WHERE marine_output.date <> '' |
| 482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 483 | 483 | } else { |
| 484 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 484 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 485 | 485 | FROM marine_output |
| 486 | 486 | WHERE marine_output.date <> '' |
| 487 | 487 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $date_array = array(); |
| 494 | 494 | $temp_array = array(); |
| 495 | 495 | |
| 496 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 496 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 497 | 497 | { |
| 498 | 498 | $temp_array['date'] = $row['date']; |
| 499 | 499 | |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | * @return String success or false |
| 513 | 513 | * |
| 514 | 514 | */ |
| 515 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 515 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 516 | 516 | { |
| 517 | 517 | |
| 518 | 518 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 519 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 519 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 520 | 520 | |
| 521 | 521 | try { |
| 522 | 522 | $sth = $this->db->prepare($query); |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 540 | 540 | { |
| 541 | 541 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 542 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 542 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 543 | 543 | |
| 544 | 544 | try { |
| 545 | 545 | $sth = $this->db->prepare($query); |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @param String $verticalrate vertival rate of flight |
| 578 | 578 | * @return String success or false |
| 579 | 579 | */ |
| 580 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
| 580 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
| 581 | 581 | { |
| 582 | 582 | global $globalURL, $globalMarineImageFetch; |
| 583 | 583 | |
@@ -644,31 +644,31 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | |
| 647 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 647 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 648 | 648 | { |
| 649 | 649 | $date = date("Y-m-d H:i:s", time()); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 653 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 654 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 655 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 656 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 657 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 658 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 659 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 660 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 661 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 662 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 663 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 664 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 665 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 652 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 653 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 654 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 655 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 656 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 657 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 658 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 659 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 660 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 661 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 662 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 663 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 664 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 665 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 666 | 666 | |
| 667 | 667 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 668 | 668 | $Image = new Image($this->db); |
| 669 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 669 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 670 | 670 | if (!isset($image_array[0]['mmsi'])) { |
| 671 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 671 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 672 | 672 | } |
| 673 | 673 | unset($Image); |
| 674 | 674 | } |
@@ -680,10 +680,10 @@ discard block |
||
| 680 | 680 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 681 | 681 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 682 | 682 | if ($arrival_date == '') $arrival_date = NULL; |
| 683 | - $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) |
|
| 683 | + $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 | 684 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 685 | 685 | |
| 686 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 686 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 687 | 687 | try { |
| 688 | 688 | |
| 689 | 689 | $sth = $this->db->prepare($query); |
@@ -708,13 +708,13 @@ discard block |
||
| 708 | 708 | { |
| 709 | 709 | global $globalDBdriver, $globalTimezone; |
| 710 | 710 | if ($globalDBdriver == 'mysql') { |
| 711 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 711 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 712 | 712 | WHERE marine_output.ident = :ident |
| 713 | 713 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 714 | 714 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 715 | 715 | $query_data = array(':ident' => $ident); |
| 716 | 716 | } else { |
| 717 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 717 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 718 | 718 | WHERE marine_output.ident = :ident |
| 719 | 719 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 720 | 720 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -723,8 +723,8 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | $sth = $this->db->prepare($query); |
| 725 | 725 | $sth->execute($query_data); |
| 726 | - $ident_result=''; |
|
| 727 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 726 | + $ident_result = ''; |
|
| 727 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 728 | 728 | { |
| 729 | 729 | $ident_result = $row['ident']; |
| 730 | 730 | } |
@@ -750,8 +750,8 @@ discard block |
||
| 750 | 750 | return false; |
| 751 | 751 | } else { |
| 752 | 752 | $q_array = explode(" ", $q); |
| 753 | - foreach ($q_array as $q_item){ |
|
| 754 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 753 | + foreach ($q_array as $q_item) { |
|
| 754 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 755 | 755 | $additional_query .= " AND ("; |
| 756 | 756 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 757 | 757 | $additional_query .= ")"; |
@@ -759,11 +759,11 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | if ($globalDBdriver == 'mysql') { |
| 762 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 762 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 763 | 763 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 764 | 764 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 765 | 765 | } else { |
| 766 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 766 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 767 | 767 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 768 | 768 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 769 | 769 | } |
@@ -836,11 +836,11 @@ discard block |
||
| 836 | 836 | * @return Array the callsign list |
| 837 | 837 | * |
| 838 | 838 | */ |
| 839 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 839 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 840 | 840 | { |
| 841 | 841 | global $globalDBdriver; |
| 842 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 843 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 842 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 843 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 844 | 844 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 845 | 845 | if ($olderthanmonths > 0) { |
| 846 | 846 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -854,28 +854,28 @@ discard block |
||
| 854 | 854 | if ($year != '') { |
| 855 | 855 | if ($globalDBdriver == 'mysql') { |
| 856 | 856 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 857 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 857 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 858 | 858 | } else { |
| 859 | 859 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 860 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 860 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | 863 | if ($month != '') { |
| 864 | 864 | if ($globalDBdriver == 'mysql') { |
| 865 | 865 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 866 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 866 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 867 | 867 | } else { |
| 868 | 868 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 869 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 869 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | if ($day != '') { |
| 873 | 873 | if ($globalDBdriver == 'mysql') { |
| 874 | 874 | $query .= " AND DAY(marine_output.date) = :day"; |
| 875 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 875 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 876 | 876 | } else { |
| 877 | 877 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 878 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 878 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | $callsign_array = array(); |
| 888 | 888 | $temp_array = array(); |
| 889 | 889 | |
| 890 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 890 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 891 | 891 | { |
| 892 | 892 | $temp_array['callsign_icao'] = $row['ident']; |
| 893 | 893 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | $date_array = array(); |
| 940 | 940 | $temp_array = array(); |
| 941 | 941 | |
| 942 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 942 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 943 | 943 | { |
| 944 | 944 | $temp_array['date_name'] = $row['date_name']; |
| 945 | 945 | $temp_array['date_count'] = $row['date_count']; |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | $datetime = new DateTime(); |
| 966 | 966 | $offset = $datetime->format('P'); |
| 967 | 967 | } else $offset = '+00:00'; |
| 968 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 968 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 969 | 969 | if ($globalDBdriver == 'mysql') { |
| 970 | 970 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 971 | 971 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | $date_array = array(); |
| 987 | 987 | $temp_array = array(); |
| 988 | 988 | |
| 989 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 989 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 990 | 990 | { |
| 991 | 991 | $temp_array['date_name'] = $row['date_name']; |
| 992 | 992 | $temp_array['date_count'] = $row['date_count']; |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | $datetime = new DateTime(); |
| 1012 | 1012 | $offset = $datetime->format('P'); |
| 1013 | 1013 | } else $offset = '+00:00'; |
| 1014 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1014 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1015 | 1015 | if ($globalDBdriver == 'mysql') { |
| 1016 | 1016 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1017 | 1017 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | $date_array = array(); |
| 1033 | 1033 | $temp_array = array(); |
| 1034 | 1034 | |
| 1035 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1035 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | $temp_array['date_name'] = $row['date_name']; |
| 1038 | 1038 | $temp_array['date_count'] = $row['date_count']; |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | $date_array = array(); |
| 1080 | 1080 | $temp_array = array(); |
| 1081 | 1081 | |
| 1082 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1082 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1083 | 1083 | { |
| 1084 | 1084 | $temp_array['month_name'] = $row['month_name']; |
| 1085 | 1085 | $temp_array['year_name'] = $row['year_name']; |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | $datetime = new DateTime(); |
| 1109 | 1109 | $offset = $datetime->format('P'); |
| 1110 | 1110 | } else $offset = '+00:00'; |
| 1111 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1111 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1112 | 1112 | if ($globalDBdriver == 'mysql') { |
| 1113 | 1113 | $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 |
| 1114 | 1114 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | $date_array = array(); |
| 1130 | 1130 | $temp_array = array(); |
| 1131 | 1131 | |
| 1132 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1132 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1133 | 1133 | { |
| 1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
| 1135 | 1135 | $temp_array['month_name'] = $row['month_name']; |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * @return Array the hour list |
| 1150 | 1150 | * |
| 1151 | 1151 | */ |
| 1152 | - public function countAllHours($orderby,$filters = array()) |
|
| 1152 | + public function countAllHours($orderby, $filters = array()) |
|
| 1153 | 1153 | { |
| 1154 | 1154 | global $globalTimezone, $globalDBdriver; |
| 1155 | 1155 | if ($globalTimezone != '') { |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | $hour_array = array(); |
| 1198 | 1198 | $temp_array = array(); |
| 1199 | 1199 | |
| 1200 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1200 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1201 | 1201 | { |
| 1202 | 1202 | $temp_array['hour_name'] = $row['hour_name']; |
| 1203 | 1203 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1219,8 +1219,8 @@ discard block |
||
| 1219 | 1219 | public function countAllHoursByDate($date, $filters = array()) |
| 1220 | 1220 | { |
| 1221 | 1221 | global $globalTimezone, $globalDBdriver; |
| 1222 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1223 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1222 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1223 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1224 | 1224 | if ($globalTimezone != '') { |
| 1225 | 1225 | date_default_timezone_set($globalTimezone); |
| 1226 | 1226 | $datetime = new DateTime($date); |
@@ -1228,12 +1228,12 @@ discard block |
||
| 1228 | 1228 | } else $offset = '+00:00'; |
| 1229 | 1229 | |
| 1230 | 1230 | if ($globalDBdriver == 'mysql') { |
| 1231 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1231 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1232 | 1232 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1233 | 1233 | GROUP BY hour_name |
| 1234 | 1234 | ORDER BY hour_name ASC"; |
| 1235 | 1235 | } else { |
| 1236 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1236 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1237 | 1237 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1238 | 1238 | GROUP BY hour_name |
| 1239 | 1239 | ORDER BY hour_name ASC"; |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | $hour_array = array(); |
| 1246 | 1246 | $temp_array = array(); |
| 1247 | 1247 | |
| 1248 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1248 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1249 | 1249 | { |
| 1250 | 1250 | $temp_array['hour_name'] = $row['hour_name']; |
| 1251 | 1251 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1267,8 +1267,8 @@ discard block |
||
| 1267 | 1267 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
| 1270 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1271 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1270 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1272 | 1272 | if ($globalTimezone != '') { |
| 1273 | 1273 | date_default_timezone_set($globalTimezone); |
| 1274 | 1274 | $datetime = new DateTime(); |
@@ -1276,12 +1276,12 @@ discard block |
||
| 1276 | 1276 | } else $offset = '+00:00'; |
| 1277 | 1277 | |
| 1278 | 1278 | if ($globalDBdriver == 'mysql') { |
| 1279 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1279 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1280 | 1280 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1281 | 1281 | GROUP BY hour_name |
| 1282 | 1282 | ORDER BY hour_name ASC"; |
| 1283 | 1283 | } else { |
| 1284 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1284 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1285 | 1285 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1286 | 1286 | GROUP BY hour_name |
| 1287 | 1287 | ORDER BY hour_name ASC"; |
@@ -1289,12 +1289,12 @@ discard block |
||
| 1289 | 1289 | |
| 1290 | 1290 | |
| 1291 | 1291 | $sth = $this->db->prepare($query); |
| 1292 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1292 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1293 | 1293 | |
| 1294 | 1294 | $hour_array = array(); |
| 1295 | 1295 | $temp_array = array(); |
| 1296 | 1296 | |
| 1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
| 1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1313,32 +1313,32 @@ discard block |
||
| 1313 | 1313 | * @return Integer the number of flights |
| 1314 | 1314 | * |
| 1315 | 1315 | */ |
| 1316 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
| 1316 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
| 1317 | 1317 | { |
| 1318 | 1318 | global $globalDBdriver; |
| 1319 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1319 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1320 | 1320 | $query_values = array(); |
| 1321 | 1321 | $query = ''; |
| 1322 | 1322 | if ($year != '') { |
| 1323 | 1323 | if ($globalDBdriver == 'mysql') { |
| 1324 | 1324 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1325 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1325 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1326 | 1326 | } else { |
| 1327 | 1327 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1328 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1328 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1329 | 1329 | } |
| 1330 | 1330 | } |
| 1331 | 1331 | if ($month != '') { |
| 1332 | 1332 | if ($globalDBdriver == 'mysql') { |
| 1333 | 1333 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1334 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1334 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1335 | 1335 | } else { |
| 1336 | 1336 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1337 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1337 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | } |
| 1340 | 1340 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1341 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1341 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1342 | 1342 | |
| 1343 | 1343 | $sth = $this->db->prepare($queryi); |
| 1344 | 1344 | $sth->execute($query_values); |
@@ -1355,7 +1355,7 @@ discard block |
||
| 1355 | 1355 | public function countAllHoursFromToday($filters = array()) |
| 1356 | 1356 | { |
| 1357 | 1357 | global $globalTimezone, $globalDBdriver; |
| 1358 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1358 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1359 | 1359 | if ($globalTimezone != '') { |
| 1360 | 1360 | date_default_timezone_set($globalTimezone); |
| 1361 | 1361 | $datetime = new DateTime(); |
@@ -1363,12 +1363,12 @@ discard block |
||
| 1363 | 1363 | } else $offset = '+00:00'; |
| 1364 | 1364 | |
| 1365 | 1365 | if ($globalDBdriver == 'mysql') { |
| 1366 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1366 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1367 | 1367 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1368 | 1368 | GROUP BY hour_name |
| 1369 | 1369 | ORDER BY hour_name ASC"; |
| 1370 | 1370 | } else { |
| 1371 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1371 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1372 | 1372 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1373 | 1373 | GROUP BY hour_name |
| 1374 | 1374 | ORDER BY hour_name ASC"; |
@@ -1380,7 +1380,7 @@ discard block |
||
| 1380 | 1380 | $hour_array = array(); |
| 1381 | 1381 | $temp_array = array(); |
| 1382 | 1382 | |
| 1383 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1383 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1384 | 1384 | { |
| 1385 | 1385 | $temp_array['hour_name'] = $row['hour_name']; |
| 1386 | 1386 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1399,9 +1399,9 @@ discard block |
||
| 1399 | 1399 | */ |
| 1400 | 1400 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1401 | 1401 | { |
| 1402 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1402 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1403 | 1403 | |
| 1404 | - $query = "SELECT marine_output.marine_id |
|
| 1404 | + $query = "SELECT marine_output.marine_id |
|
| 1405 | 1405 | FROM marine_output |
| 1406 | 1406 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1407 | 1407 | |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | $sth = $this->db->prepare($query); |
| 1410 | 1410 | $sth->execute(); |
| 1411 | 1411 | |
| 1412 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1412 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1413 | 1413 | { |
| 1414 | 1414 | return $row['marine_id']; |
| 1415 | 1415 | } |
@@ -1434,23 +1434,23 @@ discard block |
||
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | $current_date = date("Y-m-d H:i:s"); |
| 1437 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1437 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1438 | 1438 | |
| 1439 | 1439 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1440 | 1440 | |
| 1441 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1441 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1442 | 1442 | $years = $time_array['years']; |
| 1443 | 1443 | |
| 1444 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1444 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1445 | 1445 | $months = $time_array['months']; |
| 1446 | 1446 | |
| 1447 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1447 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1448 | 1448 | $days = $time_array['days']; |
| 1449 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1449 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1450 | 1450 | $hours = $time_array['hours']; |
| 1451 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1451 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1452 | 1452 | $minutes = $time_array['minutes']; |
| 1453 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1453 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1454 | 1454 | |
| 1455 | 1455 | return $time_array; |
| 1456 | 1456 | } |
@@ -1473,63 +1473,63 @@ discard block |
||
| 1473 | 1473 | $temp_array['direction_degree'] = $direction; |
| 1474 | 1474 | $temp_array['direction_shortname'] = "N"; |
| 1475 | 1475 | $temp_array['direction_fullname'] = "North"; |
| 1476 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1476 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1477 | 1477 | $temp_array['direction_degree'] = $direction; |
| 1478 | 1478 | $temp_array['direction_shortname'] = "NNE"; |
| 1479 | 1479 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1480 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1480 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1481 | 1481 | $temp_array['direction_degree'] = $direction; |
| 1482 | 1482 | $temp_array['direction_shortname'] = "NE"; |
| 1483 | 1483 | $temp_array['direction_fullname'] = "Northeast"; |
| 1484 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1484 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1485 | 1485 | $temp_array['direction_degree'] = $direction; |
| 1486 | 1486 | $temp_array['direction_shortname'] = "ENE"; |
| 1487 | 1487 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1488 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1488 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1489 | 1489 | $temp_array['direction_degree'] = $direction; |
| 1490 | 1490 | $temp_array['direction_shortname'] = "E"; |
| 1491 | 1491 | $temp_array['direction_fullname'] = "East"; |
| 1492 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1492 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1493 | 1493 | $temp_array['direction_degree'] = $direction; |
| 1494 | 1494 | $temp_array['direction_shortname'] = "ESE"; |
| 1495 | 1495 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1496 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1496 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1497 | 1497 | $temp_array['direction_degree'] = $direction; |
| 1498 | 1498 | $temp_array['direction_shortname'] = "SE"; |
| 1499 | 1499 | $temp_array['direction_fullname'] = "Southeast"; |
| 1500 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1500 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1501 | 1501 | $temp_array['direction_degree'] = $direction; |
| 1502 | 1502 | $temp_array['direction_shortname'] = "SSE"; |
| 1503 | 1503 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1504 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1504 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1505 | 1505 | $temp_array['direction_degree'] = $direction; |
| 1506 | 1506 | $temp_array['direction_shortname'] = "S"; |
| 1507 | 1507 | $temp_array['direction_fullname'] = "South"; |
| 1508 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1508 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1509 | 1509 | $temp_array['direction_degree'] = $direction; |
| 1510 | 1510 | $temp_array['direction_shortname'] = "SSW"; |
| 1511 | 1511 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1512 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1512 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1513 | 1513 | $temp_array['direction_degree'] = $direction; |
| 1514 | 1514 | $temp_array['direction_shortname'] = "SW"; |
| 1515 | 1515 | $temp_array['direction_fullname'] = "Southwest"; |
| 1516 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1516 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1517 | 1517 | $temp_array['direction_degree'] = $direction; |
| 1518 | 1518 | $temp_array['direction_shortname'] = "WSW"; |
| 1519 | 1519 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1520 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1520 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1521 | 1521 | $temp_array['direction_degree'] = $direction; |
| 1522 | 1522 | $temp_array['direction_shortname'] = "W"; |
| 1523 | 1523 | $temp_array['direction_fullname'] = "West"; |
| 1524 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1524 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1525 | 1525 | $temp_array['direction_degree'] = $direction; |
| 1526 | 1526 | $temp_array['direction_shortname'] = "WNW"; |
| 1527 | 1527 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1528 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1528 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1529 | 1529 | $temp_array['direction_degree'] = $direction; |
| 1530 | 1530 | $temp_array['direction_shortname'] = "NW"; |
| 1531 | 1531 | $temp_array['direction_fullname'] = "Northwest"; |
| 1532 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1532 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1533 | 1533 | $temp_array['direction_degree'] = $direction; |
| 1534 | 1534 | $temp_array['direction_shortname'] = "NNW"; |
| 1535 | 1535 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1546,11 +1546,11 @@ discard block |
||
| 1546 | 1546 | * @param Float $longitude longitute of the flight |
| 1547 | 1547 | * @return String the countrie |
| 1548 | 1548 | */ |
| 1549 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1549 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1550 | 1550 | { |
| 1551 | 1551 | global $globalDBdriver, $globalDebug; |
| 1552 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1553 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1552 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1553 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1554 | 1554 | |
| 1555 | 1555 | $Connection = new Connection($this->db); |
| 1556 | 1556 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | public function getCountryFromISO2($iso2) |
| 1591 | 1591 | { |
| 1592 | 1592 | global $globalDBdriver, $globalDebug; |
| 1593 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1593 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1594 | 1594 | |
| 1595 | 1595 | $Connection = new Connection($this->db); |
| 1596 | 1596 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | |
| 1639 | 1639 | $bitly_data = json_decode($bitly_data); |
| 1640 | 1640 | $bitly_url = ''; |
| 1641 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1641 | + if ($bitly_data->status_txt = "OK") { |
|
| 1642 | 1642 | $bitly_url = $bitly_data->data->url; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | |
| 1649 | 1649 | public function getOrderBy() |
| 1650 | 1650 | { |
| 1651 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1651 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1652 | 1652 | |
| 1653 | 1653 | return $orderby; |
| 1654 | 1654 | |
@@ -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 | |