@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 54; |
8 | 8 | |
9 | + /** |
|
10 | + * @param string $dbname |
|
11 | + */ |
|
9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | 13 | global $globalNoDB; |
11 | 14 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
@@ -142,6 +145,9 @@ discard block |
||
142 | 145 | return true; |
143 | 146 | } |
144 | 147 | |
148 | + /** |
|
149 | + * @param string $table |
|
150 | + */ |
|
145 | 151 | public function tableExists($table) |
146 | 152 | { |
147 | 153 | global $globalDBdriver, $globalDBname; |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 54; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | try { |
155 | 155 | //$Connection = new Connection(); |
156 | 156 | $results = $this->db->query($query); |
157 | - } catch(PDOException $e) { |
|
157 | + } catch (PDOException $e) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | - if($results->rowCount()>0) { |
|
160 | + if ($results->rowCount() > 0) { |
|
161 | 161 | return true; |
162 | 162 | } |
163 | 163 | else return false; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - } catch(PDOException $e) { |
|
183 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | + } catch (PDOException $e) { |
|
183 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
184 | 184 | throw $e; |
185 | 185 | } |
186 | 186 | //echo 'error ! '.$e->getMessage(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /* |
193 | 193 | * Check if index exist |
194 | 194 | */ |
195 | - public function indexExists($table,$index) |
|
195 | + public function indexExists($table, $index) |
|
196 | 196 | { |
197 | 197 | global $globalDBdriver, $globalDBname; |
198 | 198 | if ($globalDBdriver == 'mysql') { |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | try { |
204 | 204 | //$Connection = new Connection(); |
205 | 205 | $results = $this->db->query($query); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
210 | - if($nb[0]['nb'] > 0) { |
|
210 | + if ($nb[0]['nb'] > 0) { |
|
211 | 211 | return true; |
212 | 212 | } |
213 | 213 | else return false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
223 | 223 | try { |
224 | 224 | $results = $this->db->query($query); |
225 | - } catch(PDOException $e) { |
|
225 | + } catch (PDOException $e) { |
|
226 | 226 | return "error : ".$e->getMessage()."\n"; |
227 | 227 | } |
228 | 228 | $columns = array(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | return $columns; |
235 | 235 | } |
236 | 236 | |
237 | - public function getColumnType($table,$column) { |
|
237 | + public function getColumnType($table, $column) { |
|
238 | 238 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
239 | 239 | $tomet = $select->getColumnMeta(0); |
240 | 240 | return $tomet['native_type']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * Check if a column name exist in a table |
245 | 245 | * @return Boolean column exist or not |
246 | 246 | */ |
247 | - public function checkColumnName($table,$name) |
|
247 | + public function checkColumnName($table, $name) |
|
248 | 248 | { |
249 | 249 | global $globalDBdriver, $globalDBname; |
250 | 250 | if ($globalDBdriver == 'mysql') { |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | } |
255 | 255 | try { |
256 | 256 | $sth = $this->db()->prepare($query); |
257 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
258 | - } catch(PDOException $e) { |
|
257 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
258 | + } catch (PDOException $e) { |
|
259 | 259 | echo "error : ".$e->getMessage()."\n"; |
260 | 260 | } |
261 | 261 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | try { |
295 | 295 | $sth = $this->db->prepare($query); |
296 | 296 | $sth->execute(); |
297 | - } catch(PDOException $e) { |
|
297 | + } catch (PDOException $e) { |
|
298 | 298 | return "error : ".$e->getMessage()."\n"; |
299 | 299 | } |
300 | 300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -1003,25 +1003,6 @@ discard block |
||
1003 | 1003 | * |
1004 | 1004 | * @param String $fammarine_id the ID |
1005 | 1005 | * @param String $ident the marine ident |
1006 | - * @param String $departure_airport_icao the departure airport |
|
1007 | - * @param String $arrival_airport_icao the arrival airport |
|
1008 | - * @param String $latitude latitude of flight |
|
1009 | - * @param String $longitude latitude of flight |
|
1010 | - * @param String $waypoints waypoints of flight |
|
1011 | - * @param String $heading heading of flight |
|
1012 | - * @param String $groundspeed speed of flight |
|
1013 | - * @param String $date date of flight |
|
1014 | - * @param String $departure_airport_time departure time of flight |
|
1015 | - * @param String $arrival_airport_time arrival time of flight |
|
1016 | - * @param String $squawk squawk code of flight |
|
1017 | - * @param String $route_stop route stop of flight |
|
1018 | - * @param String $highlight highlight or not |
|
1019 | - * @param String $ModeS ModesS code of flight |
|
1020 | - * @param String $registration registration code of flight |
|
1021 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
1022 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
1023 | - * @param String $verticalrate vertival rate of flight |
|
1024 | - * @return String success or false |
|
1025 | 1006 | */ |
1026 | 1007 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
1027 | 1008 | { |
@@ -1624,6 +1605,7 @@ discard block |
||
1624 | 1605 | /** |
1625 | 1606 | * Counts all hours |
1626 | 1607 | * |
1608 | + * @param string $orderby |
|
1627 | 1609 | * @return Array the hour list |
1628 | 1610 | * |
1629 | 1611 | */ |
@@ -1975,7 +1957,7 @@ discard block |
||
1975 | 1957 | /** |
1976 | 1958 | * Parses the direction degrees to working |
1977 | 1959 | * |
1978 | - * @param Float $direction the direction in degrees |
|
1960 | + * @param integer $direction the direction in degrees |
|
1979 | 1961 | * @return Array the direction information |
1980 | 1962 | * |
1981 | 1963 | */ |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | - * Executes the SQL statements to get the spotter information |
|
92 | - * |
|
93 | - * @param String $query the SQL query |
|
94 | - * @param Array $params parameter of the query |
|
95 | - * @param String $limitQuery the limit query |
|
96 | - * @return Array the spotter information |
|
97 | - * |
|
98 | - */ |
|
91 | + * Executes the SQL statements to get the spotter information |
|
92 | + * |
|
93 | + * @param String $query the SQL query |
|
94 | + * @param Array $params parameter of the query |
|
95 | + * @param String $limitQuery the limit query |
|
96 | + * @return Array the spotter information |
|
97 | + * |
|
98 | + */ |
|
99 | 99 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
100 | 100 | { |
101 | 101 | date_default_timezone_set('UTC'); |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | |
232 | 232 | |
233 | 233 | /** |
234 | - * Gets all the spotter information based on the latest data entry |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
234 | + * Gets all the spotter information based on the latest data entry |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | 239 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
240 | 240 | { |
241 | 241 | global $global_marine_query; |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | - * Gets all the spotter information based on the callsign |
|
288 | - * |
|
289 | - * @return Array the spotter information |
|
290 | - * |
|
291 | - */ |
|
287 | + * Gets all the spotter information based on the callsign |
|
288 | + * |
|
289 | + * @return Array the spotter information |
|
290 | + * |
|
291 | + */ |
|
292 | 292 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
293 | 293 | { |
294 | 294 | global $global_marine_query; |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | - * Gets all the marine information based on the type |
|
344 | - * |
|
345 | - * @return Array the marine information |
|
346 | - * |
|
347 | - */ |
|
343 | + * Gets all the marine information based on the type |
|
344 | + * |
|
345 | + * @return Array the marine information |
|
346 | + * |
|
347 | + */ |
|
348 | 348 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
349 | 349 | { |
350 | 350 | global $global_marine_query; |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
453 | - * Gets all the marine information based on the captain |
|
454 | - * |
|
455 | - * @return Array the marine information |
|
456 | - * |
|
457 | - */ |
|
453 | + * Gets all the marine information based on the captain |
|
454 | + * |
|
455 | + * @return Array the marine information |
|
456 | + * |
|
457 | + */ |
|
458 | 458 | public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array()) |
459 | 459 | { |
460 | 460 | global $global_marine_query; |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
496 | - * Gets all the marine information based on the race |
|
497 | - * |
|
498 | - * @return Array the marine information |
|
499 | - * |
|
500 | - */ |
|
496 | + * Gets all the marine information based on the race |
|
497 | + * |
|
498 | + * @return Array the marine information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
502 | 502 | { |
503 | 503 | global $global_marine_query; |
@@ -536,11 +536,11 @@ discard block |
||
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
539 | - * Count races by captain |
|
540 | - * |
|
541 | - * @return String Duration of all races |
|
542 | - * |
|
543 | - */ |
|
539 | + * Count races by captain |
|
540 | + * |
|
541 | + * @return String Duration of all races |
|
542 | + * |
|
543 | + */ |
|
544 | 544 | public function countRacesByCaptain($captain,$filters = array()) |
545 | 545 | { |
546 | 546 | $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
559 | - * Count captains by race |
|
560 | - * |
|
561 | - * @return String Duration of all races |
|
562 | - * |
|
563 | - */ |
|
559 | + * Count captains by race |
|
560 | + * |
|
561 | + * @return String Duration of all races |
|
562 | + * |
|
563 | + */ |
|
564 | 564 | public function countCaptainsByRace($race,$filters = array()) |
565 | 565 | { |
566 | 566 | $race = filter_var($race,FILTER_SANITIZE_STRING); |
@@ -576,11 +576,11 @@ discard block |
||
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
579 | - * Gets all boat types that have been used by a captain |
|
580 | - * |
|
581 | - * @return Array the boat list |
|
582 | - * |
|
583 | - */ |
|
579 | + * Gets all boat types that have been used by a captain |
|
580 | + * |
|
581 | + * @return Array the boat list |
|
582 | + * |
|
583 | + */ |
|
584 | 584 | public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
585 | 585 | { |
586 | 586 | global $globalDBdriver; |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
628 | - * Gets all boat types that have been used on a race |
|
629 | - * |
|
630 | - * @return Array the boat list |
|
631 | - * |
|
632 | - */ |
|
628 | + * Gets all boat types that have been used on a race |
|
629 | + * |
|
630 | + * @return Array the boat list |
|
631 | + * |
|
632 | + */ |
|
633 | 633 | public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
634 | 634 | { |
635 | 635 | global $globalDBdriver; |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
677 | - * Gets race duration by captain |
|
678 | - * |
|
679 | - * @return String Duration of all race |
|
680 | - * |
|
681 | - */ |
|
677 | + * Gets race duration by captain |
|
678 | + * |
|
679 | + * @return String Duration of all race |
|
680 | + * |
|
681 | + */ |
|
682 | 682 | public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
683 | 683 | { |
684 | 684 | global $globalDBdriver; |
@@ -724,11 +724,11 @@ discard block |
||
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
727 | - * Gets a list of all captain names and captain ids |
|
728 | - * |
|
729 | - * @return Array list of captain names and captain ids |
|
730 | - * |
|
731 | - */ |
|
727 | + * Gets a list of all captain names and captain ids |
|
728 | + * |
|
729 | + * @return Array list of captain names and captain ids |
|
730 | + * |
|
731 | + */ |
|
732 | 732 | public function getAllCaptainNames($filters = array()) |
733 | 733 | { |
734 | 734 | $filter_query = $this->getFilter($filters,true,true); |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
745 | - * Gets a list of all race names and race ids |
|
746 | - * |
|
747 | - * @return Array list of race names and race ids |
|
748 | - * |
|
749 | - */ |
|
745 | + * Gets a list of all race names and race ids |
|
746 | + * |
|
747 | + * @return Array list of race names and race ids |
|
748 | + * |
|
749 | + */ |
|
750 | 750 | public function getAllRaceNames($filters = array()) |
751 | 751 | { |
752 | 752 | $filter_query = $this->getFilter($filters,true,true); |
@@ -760,12 +760,12 @@ discard block |
||
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
763 | - * Gets all source name |
|
764 | - * |
|
765 | - * @param String type format of source |
|
766 | - * @return Array list of source name |
|
767 | - * |
|
768 | - */ |
|
763 | + * Gets all source name |
|
764 | + * |
|
765 | + * @param String type format of source |
|
766 | + * @return Array list of source name |
|
767 | + * |
|
768 | + */ |
|
769 | 769 | public function getAllSourceName($type = '',$filters = array()) |
770 | 770 | { |
771 | 771 | $filter_query = $this->getFilter($filters,true,true); |
@@ -795,11 +795,11 @@ discard block |
||
795 | 795 | |
796 | 796 | |
797 | 797 | /** |
798 | - * Gets a list of all idents/callsigns |
|
799 | - * |
|
800 | - * @return Array list of ident/callsign names |
|
801 | - * |
|
802 | - */ |
|
798 | + * Gets a list of all idents/callsigns |
|
799 | + * |
|
800 | + * @return Array list of ident/callsign names |
|
801 | + * |
|
802 | + */ |
|
803 | 803 | public function getAllIdents($filters = array()) |
804 | 804 | { |
805 | 805 | $filter_query = $this->getFilter($filters,true,true); |
@@ -823,11 +823,11 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
826 | - * Gets all info from a mmsi |
|
827 | - * |
|
828 | - * @return Array ident |
|
829 | - * |
|
830 | - */ |
|
826 | + * Gets all info from a mmsi |
|
827 | + * |
|
828 | + * @return Array ident |
|
829 | + * |
|
830 | + */ |
|
831 | 831 | public function getIdentity($mmsi) |
832 | 832 | { |
833 | 833 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -840,9 +840,9 @@ discard block |
||
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
843 | - * Add identity |
|
844 | - * |
|
845 | - */ |
|
843 | + * Add identity |
|
844 | + * |
|
845 | + */ |
|
846 | 846 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
847 | 847 | { |
848 | 848 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -908,13 +908,13 @@ discard block |
||
908 | 908 | } |
909 | 909 | |
910 | 910 | /** |
911 | - * Update ident tracker data |
|
912 | - * |
|
913 | - * @param String $fammarine_id the ID |
|
914 | - * @param String $ident the marine ident |
|
915 | - * @return String success or false |
|
916 | - * |
|
917 | - */ |
|
911 | + * Update ident tracker data |
|
912 | + * |
|
913 | + * @param String $fammarine_id the ID |
|
914 | + * @param String $ident the marine ident |
|
915 | + * @return String success or false |
|
916 | + * |
|
917 | + */ |
|
918 | 918 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
919 | 919 | { |
920 | 920 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -929,13 +929,13 @@ discard block |
||
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
932 | - * Update arrival marine data |
|
933 | - * |
|
934 | - * @param String $fammarine_id the ID |
|
935 | - * @param String $arrival_code the marine ident |
|
936 | - * @return String success or false |
|
937 | - * |
|
938 | - */ |
|
932 | + * Update arrival marine data |
|
933 | + * |
|
934 | + * @param String $fammarine_id the ID |
|
935 | + * @param String $arrival_code the marine ident |
|
936 | + * @return String success or false |
|
937 | + * |
|
938 | + */ |
|
939 | 939 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
940 | 940 | { |
941 | 941 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -950,19 +950,19 @@ discard block |
||
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
953 | - * Update Status data |
|
954 | - * |
|
955 | - * @param String $fammarine_id the ID |
|
956 | - * @param String $status_id the marine status id |
|
957 | - * @param String $status the marine status |
|
958 | - * @return String success or false |
|
959 | - * |
|
960 | - */ |
|
953 | + * Update Status data |
|
954 | + * |
|
955 | + * @param String $fammarine_id the ID |
|
956 | + * @param String $status_id the marine status id |
|
957 | + * @param String $status the marine status |
|
958 | + * @return String success or false |
|
959 | + * |
|
960 | + */ |
|
961 | 961 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
962 | 962 | { |
963 | 963 | |
964 | 964 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
965 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
965 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
966 | 966 | |
967 | 967 | try { |
968 | 968 | $sth = $this->db->prepare($query); |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | |
976 | 976 | } |
977 | 977 | /** |
978 | - * Update latest marine data |
|
979 | - * |
|
980 | - * @param String $fammarine_id the ID |
|
981 | - * @param String $ident the marine ident |
|
982 | - * @return String success or false |
|
983 | - * |
|
984 | - */ |
|
978 | + * Update latest marine data |
|
979 | + * |
|
980 | + * @param String $fammarine_id the ID |
|
981 | + * @param String $ident the marine ident |
|
982 | + * @return String success or false |
|
983 | + * |
|
984 | + */ |
|
985 | 985 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL) |
986 | 986 | { |
987 | 987 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time WHERE fammarine_id = :fammarine_id'; |
988 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
988 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
989 | 989 | |
990 | 990 | try { |
991 | 991 | $sth = $this->db->prepare($query); |
@@ -999,30 +999,30 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
1002 | - * Adds a new marine data |
|
1003 | - * |
|
1004 | - * @param String $fammarine_id the ID |
|
1005 | - * @param String $ident the marine ident |
|
1006 | - * @param String $departure_airport_icao the departure airport |
|
1007 | - * @param String $arrival_airport_icao the arrival airport |
|
1008 | - * @param String $latitude latitude of flight |
|
1009 | - * @param String $longitude latitude of flight |
|
1010 | - * @param String $waypoints waypoints of flight |
|
1011 | - * @param String $heading heading of flight |
|
1012 | - * @param String $groundspeed speed of flight |
|
1013 | - * @param String $date date of flight |
|
1014 | - * @param String $departure_airport_time departure time of flight |
|
1015 | - * @param String $arrival_airport_time arrival time of flight |
|
1016 | - * @param String $squawk squawk code of flight |
|
1017 | - * @param String $route_stop route stop of flight |
|
1018 | - * @param String $highlight highlight or not |
|
1019 | - * @param String $ModeS ModesS code of flight |
|
1020 | - * @param String $registration registration code of flight |
|
1021 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
1022 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
1023 | - * @param String $verticalrate vertival rate of flight |
|
1024 | - * @return String success or false |
|
1025 | - */ |
|
1002 | + * Adds a new marine data |
|
1003 | + * |
|
1004 | + * @param String $fammarine_id the ID |
|
1005 | + * @param String $ident the marine ident |
|
1006 | + * @param String $departure_airport_icao the departure airport |
|
1007 | + * @param String $arrival_airport_icao the arrival airport |
|
1008 | + * @param String $latitude latitude of flight |
|
1009 | + * @param String $longitude latitude of flight |
|
1010 | + * @param String $waypoints waypoints of flight |
|
1011 | + * @param String $heading heading of flight |
|
1012 | + * @param String $groundspeed speed of flight |
|
1013 | + * @param String $date date of flight |
|
1014 | + * @param String $departure_airport_time departure time of flight |
|
1015 | + * @param String $arrival_airport_time arrival time of flight |
|
1016 | + * @param String $squawk squawk code of flight |
|
1017 | + * @param String $route_stop route stop of flight |
|
1018 | + * @param String $highlight highlight or not |
|
1019 | + * @param String $ModeS ModesS code of flight |
|
1020 | + * @param String $registration registration code of flight |
|
1021 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
1022 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
1023 | + * @param String $verticalrate vertival rate of flight |
|
1024 | + * @return String success or false |
|
1025 | + */ |
|
1026 | 1026 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
1027 | 1027 | { |
1028 | 1028 | global $globalURL, $globalMarineImageFetch; |
@@ -1155,11 +1155,11 @@ discard block |
||
1155 | 1155 | |
1156 | 1156 | |
1157 | 1157 | /** |
1158 | - * Gets the aircraft ident within the last hour |
|
1159 | - * |
|
1160 | - * @return String the ident |
|
1161 | - * |
|
1162 | - */ |
|
1158 | + * Gets the aircraft ident within the last hour |
|
1159 | + * |
|
1160 | + * @return String the ident |
|
1161 | + * |
|
1162 | + */ |
|
1163 | 1163 | public function getIdentFromLastHour($ident) |
1164 | 1164 | { |
1165 | 1165 | global $globalDBdriver, $globalTimezone; |
@@ -1175,11 +1175,11 @@ discard block |
||
1175 | 1175 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
1176 | 1176 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
1177 | 1177 | $query_data = array(':ident' => $ident); |
1178 | - } |
|
1178 | + } |
|
1179 | 1179 | |
1180 | 1180 | $sth = $this->db->prepare($query); |
1181 | 1181 | $sth->execute($query_data); |
1182 | - $ident_result=''; |
|
1182 | + $ident_result=''; |
|
1183 | 1183 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1184 | 1184 | { |
1185 | 1185 | $ident_result = $row['ident']; |
@@ -1190,11 +1190,11 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | |
1192 | 1192 | /** |
1193 | - * Gets the aircraft data from the last 20 seconds |
|
1194 | - * |
|
1195 | - * @return Array the marine data |
|
1196 | - * |
|
1197 | - */ |
|
1193 | + * Gets the aircraft data from the last 20 seconds |
|
1194 | + * |
|
1195 | + * @return Array the marine data |
|
1196 | + * |
|
1197 | + */ |
|
1198 | 1198 | public function getRealTimeData($q = '') |
1199 | 1199 | { |
1200 | 1200 | global $globalDBdriver; |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | |
1233 | 1233 | |
1234 | 1234 | /** |
1235 | - * Gets all number of flight over countries |
|
1236 | - * |
|
1237 | - * @return Array the airline country list |
|
1238 | - * |
|
1239 | - */ |
|
1235 | + * Gets all number of flight over countries |
|
1236 | + * |
|
1237 | + * @return Array the airline country list |
|
1238 | + * |
|
1239 | + */ |
|
1240 | 1240 | |
1241 | 1241 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
1242 | 1242 | { |
@@ -1309,11 +1309,11 @@ discard block |
||
1309 | 1309 | |
1310 | 1310 | |
1311 | 1311 | /** |
1312 | - * Gets all callsigns that have flown over |
|
1313 | - * |
|
1314 | - * @return Array the callsign list |
|
1315 | - * |
|
1316 | - */ |
|
1312 | + * Gets all callsigns that have flown over |
|
1313 | + * |
|
1314 | + * @return Array the callsign list |
|
1315 | + * |
|
1316 | + */ |
|
1317 | 1317 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
1318 | 1318 | { |
1319 | 1319 | global $globalDBdriver; |
@@ -1380,11 +1380,11 @@ discard block |
||
1380 | 1380 | |
1381 | 1381 | |
1382 | 1382 | /** |
1383 | - * Counts all dates |
|
1384 | - * |
|
1385 | - * @return Array the date list |
|
1386 | - * |
|
1387 | - */ |
|
1383 | + * Counts all dates |
|
1384 | + * |
|
1385 | + * @return Array the date list |
|
1386 | + * |
|
1387 | + */ |
|
1388 | 1388 | public function countAllDates($filters = array()) |
1389 | 1389 | { |
1390 | 1390 | global $globalTimezone, $globalDBdriver; |
@@ -1430,11 +1430,11 @@ discard block |
||
1430 | 1430 | |
1431 | 1431 | |
1432 | 1432 | /** |
1433 | - * Counts all dates during the last 7 days |
|
1434 | - * |
|
1435 | - * @return Array the date list |
|
1436 | - * |
|
1437 | - */ |
|
1433 | + * Counts all dates during the last 7 days |
|
1434 | + * |
|
1435 | + * @return Array the date list |
|
1436 | + * |
|
1437 | + */ |
|
1438 | 1438 | public function countAllDatesLast7Days($filters = array()) |
1439 | 1439 | { |
1440 | 1440 | global $globalTimezone, $globalDBdriver; |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | $query .= " GROUP BY date_name |
1457 | 1457 | ORDER BY date_name ASC"; |
1458 | 1458 | $query_data = array(':offset' => $offset); |
1459 | - } |
|
1459 | + } |
|
1460 | 1460 | |
1461 | 1461 | $sth = $this->db->prepare($query); |
1462 | 1462 | $sth->execute($query_data); |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | /** |
1479 | - * Counts all dates during the last month |
|
1480 | - * |
|
1481 | - * @return Array the date list |
|
1482 | - * |
|
1483 | - */ |
|
1479 | + * Counts all dates during the last month |
|
1480 | + * |
|
1481 | + * @return Array the date list |
|
1482 | + * |
|
1483 | + */ |
|
1484 | 1484 | public function countAllDatesLastMonth($filters = array()) |
1485 | 1485 | { |
1486 | 1486 | global $globalTimezone, $globalDBdriver; |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | $query .= " GROUP BY date_name |
1503 | 1503 | ORDER BY date_name ASC"; |
1504 | 1504 | $query_data = array(':offset' => $offset); |
1505 | - } |
|
1505 | + } |
|
1506 | 1506 | |
1507 | 1507 | $sth = $this->db->prepare($query); |
1508 | 1508 | $sth->execute($query_data); |
@@ -1524,11 +1524,11 @@ discard block |
||
1524 | 1524 | |
1525 | 1525 | |
1526 | 1526 | /** |
1527 | - * Counts all month |
|
1528 | - * |
|
1529 | - * @return Array the month list |
|
1530 | - * |
|
1531 | - */ |
|
1527 | + * Counts all month |
|
1528 | + * |
|
1529 | + * @return Array the month list |
|
1530 | + * |
|
1531 | + */ |
|
1532 | 1532 | public function countAllMonths($filters = array()) |
1533 | 1533 | { |
1534 | 1534 | global $globalTimezone, $globalDBdriver; |
@@ -1573,11 +1573,11 @@ discard block |
||
1573 | 1573 | |
1574 | 1574 | |
1575 | 1575 | /** |
1576 | - * Counts all dates during the last year |
|
1577 | - * |
|
1578 | - * @return Array the date list |
|
1579 | - * |
|
1580 | - */ |
|
1576 | + * Counts all dates during the last year |
|
1577 | + * |
|
1578 | + * @return Array the date list |
|
1579 | + * |
|
1580 | + */ |
|
1581 | 1581 | public function countAllMonthsLastYear($filters) |
1582 | 1582 | { |
1583 | 1583 | global $globalTimezone, $globalDBdriver; |
@@ -1599,7 +1599,7 @@ discard block |
||
1599 | 1599 | $query .= " GROUP BY year_name, month_name |
1600 | 1600 | ORDER BY year_name, month_name ASC"; |
1601 | 1601 | $query_data = array(':offset' => $offset); |
1602 | - } |
|
1602 | + } |
|
1603 | 1603 | |
1604 | 1604 | $sth = $this->db->prepare($query); |
1605 | 1605 | $sth->execute($query_data); |
@@ -1622,11 +1622,11 @@ discard block |
||
1622 | 1622 | |
1623 | 1623 | |
1624 | 1624 | /** |
1625 | - * Counts all hours |
|
1626 | - * |
|
1627 | - * @return Array the hour list |
|
1628 | - * |
|
1629 | - */ |
|
1625 | + * Counts all hours |
|
1626 | + * |
|
1627 | + * @return Array the hour list |
|
1628 | + * |
|
1629 | + */ |
|
1630 | 1630 | public function countAllHours($orderby,$filters = array()) |
1631 | 1631 | { |
1632 | 1632 | global $globalTimezone, $globalDBdriver; |
@@ -1689,11 +1689,11 @@ discard block |
||
1689 | 1689 | |
1690 | 1690 | |
1691 | 1691 | /** |
1692 | - * Counts all hours by date |
|
1693 | - * |
|
1694 | - * @return Array the hour list |
|
1695 | - * |
|
1696 | - */ |
|
1692 | + * Counts all hours by date |
|
1693 | + * |
|
1694 | + * @return Array the hour list |
|
1695 | + * |
|
1696 | + */ |
|
1697 | 1697 | public function countAllHoursByDate($date, $filters = array()) |
1698 | 1698 | { |
1699 | 1699 | global $globalTimezone, $globalDBdriver; |
@@ -1737,11 +1737,11 @@ discard block |
||
1737 | 1737 | |
1738 | 1738 | |
1739 | 1739 | /** |
1740 | - * Counts all hours by a ident/callsign |
|
1741 | - * |
|
1742 | - * @return Array the hour list |
|
1743 | - * |
|
1744 | - */ |
|
1740 | + * Counts all hours by a ident/callsign |
|
1741 | + * |
|
1742 | + * @return Array the hour list |
|
1743 | + * |
|
1744 | + */ |
|
1745 | 1745 | public function countAllHoursByIdent($ident, $filters = array()) |
1746 | 1746 | { |
1747 | 1747 | global $globalTimezone, $globalDBdriver; |
@@ -1786,11 +1786,11 @@ discard block |
||
1786 | 1786 | |
1787 | 1787 | |
1788 | 1788 | /** |
1789 | - * Counts all vessels |
|
1790 | - * |
|
1791 | - * @return Integer the number of vessels |
|
1792 | - * |
|
1793 | - */ |
|
1789 | + * Counts all vessels |
|
1790 | + * |
|
1791 | + * @return Integer the number of vessels |
|
1792 | + * |
|
1793 | + */ |
|
1794 | 1794 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1795 | 1795 | { |
1796 | 1796 | global $globalDBdriver; |
@@ -1825,11 +1825,11 @@ discard block |
||
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | /** |
1828 | - * Counts all vessel type |
|
1829 | - * |
|
1830 | - * @return Integer the number of vessels |
|
1831 | - * |
|
1832 | - */ |
|
1828 | + * Counts all vessel type |
|
1829 | + * |
|
1830 | + * @return Integer the number of vessels |
|
1831 | + * |
|
1832 | + */ |
|
1833 | 1833 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1834 | 1834 | { |
1835 | 1835 | global $globalDBdriver; |
@@ -1864,11 +1864,11 @@ discard block |
||
1864 | 1864 | |
1865 | 1865 | |
1866 | 1866 | /** |
1867 | - * Counts all hours of today |
|
1868 | - * |
|
1869 | - * @return Array the hour list |
|
1870 | - * |
|
1871 | - */ |
|
1867 | + * Counts all hours of today |
|
1868 | + * |
|
1869 | + * @return Array the hour list |
|
1870 | + * |
|
1871 | + */ |
|
1872 | 1872 | public function countAllHoursFromToday($filters = array()) |
1873 | 1873 | { |
1874 | 1874 | global $globalTimezone, $globalDBdriver; |
@@ -1908,12 +1908,12 @@ discard block |
||
1908 | 1908 | } |
1909 | 1909 | |
1910 | 1910 | |
1911 | - /** |
|
1912 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1913 | - * |
|
1914 | - * @return Integer the Barrie Spotter ID |
|
1911 | + /** |
|
1912 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1913 | + * |
|
1914 | + * @return Integer the Barrie Spotter ID |
|
1915 | 1915 | q * |
1916 | - */ |
|
1916 | + */ |
|
1917 | 1917 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1918 | 1918 | { |
1919 | 1919 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1934,13 +1934,13 @@ discard block |
||
1934 | 1934 | |
1935 | 1935 | |
1936 | 1936 | /** |
1937 | - * Parses a date string |
|
1938 | - * |
|
1939 | - * @param String $dateString the date string |
|
1940 | - * @param String $timezone the timezone of a user |
|
1941 | - * @return Array the time information |
|
1942 | - * |
|
1943 | - */ |
|
1937 | + * Parses a date string |
|
1938 | + * |
|
1939 | + * @param String $dateString the date string |
|
1940 | + * @param String $timezone the timezone of a user |
|
1941 | + * @return Array the time information |
|
1942 | + * |
|
1943 | + */ |
|
1944 | 1944 | public function parseDateString($dateString, $timezone = '') |
1945 | 1945 | { |
1946 | 1946 | $time_array = array(); |
@@ -1973,12 +1973,12 @@ discard block |
||
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | /** |
1976 | - * Parses the direction degrees to working |
|
1977 | - * |
|
1978 | - * @param Float $direction the direction in degrees |
|
1979 | - * @return Array the direction information |
|
1980 | - * |
|
1981 | - */ |
|
1976 | + * Parses the direction degrees to working |
|
1977 | + * |
|
1978 | + * @param Float $direction the direction in degrees |
|
1979 | + * @return Array the direction information |
|
1980 | + * |
|
1981 | + */ |
|
1982 | 1982 | public function parseDirection($direction = 0) |
1983 | 1983 | { |
1984 | 1984 | if ($direction == '') $direction = 0; |
@@ -2057,12 +2057,12 @@ discard block |
||
2057 | 2057 | |
2058 | 2058 | |
2059 | 2059 | /** |
2060 | - * Gets Country from latitude/longitude |
|
2061 | - * |
|
2062 | - * @param Float $latitude latitute of the flight |
|
2063 | - * @param Float $longitude longitute of the flight |
|
2064 | - * @return String the countrie |
|
2065 | - */ |
|
2060 | + * Gets Country from latitude/longitude |
|
2061 | + * |
|
2062 | + * @param Float $latitude latitute of the flight |
|
2063 | + * @param Float $longitude longitute of the flight |
|
2064 | + * @return String the countrie |
|
2065 | + */ |
|
2066 | 2066 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
2067 | 2067 | { |
2068 | 2068 | global $globalDBdriver, $globalDebug; |
@@ -2099,11 +2099,11 @@ discard block |
||
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | /** |
2102 | - * Gets Country from iso2 |
|
2103 | - * |
|
2104 | - * @param String $iso2 ISO2 country code |
|
2105 | - * @return String the countrie |
|
2106 | - */ |
|
2102 | + * Gets Country from iso2 |
|
2103 | + * |
|
2104 | + * @param String $iso2 ISO2 country code |
|
2105 | + * @return String the countrie |
|
2106 | + */ |
|
2107 | 2107 | public function getCountryFromISO2($iso2) |
2108 | 2108 | { |
2109 | 2109 | global $globalDBdriver, $globalDebug; |
@@ -2132,12 +2132,12 @@ discard block |
||
2132 | 2132 | |
2133 | 2133 | |
2134 | 2134 | /** |
2135 | - * Gets the short url from bit.ly |
|
2136 | - * |
|
2137 | - * @param String $url the full url |
|
2138 | - * @return String the bit.ly url |
|
2139 | - * |
|
2140 | - */ |
|
2135 | + * Gets the short url from bit.ly |
|
2136 | + * |
|
2137 | + * @param String $url the full url |
|
2138 | + * @return String the bit.ly url |
|
2139 | + * |
|
2140 | + */ |
|
2141 | 2141 | public function getBitlyURL($url) |
2142 | 2142 | { |
2143 | 2143 | global $globalBitlyAccessToken; |
@@ -2164,11 +2164,11 @@ discard block |
||
2164 | 2164 | |
2165 | 2165 | |
2166 | 2166 | /** |
2167 | - * Gets all vessels types that have flown over |
|
2168 | - * |
|
2169 | - * @return Array the vessel type list |
|
2170 | - * |
|
2171 | - */ |
|
2167 | + * Gets all vessels types that have flown over |
|
2168 | + * |
|
2169 | + * @return Array the vessel type list |
|
2170 | + * |
|
2171 | + */ |
|
2172 | 2172 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
2173 | 2173 | { |
2174 | 2174 | global $globalDBdriver; |
@@ -2234,11 +2234,11 @@ discard block |
||
2234 | 2234 | } |
2235 | 2235 | |
2236 | 2236 | /** |
2237 | - * Gets all the tracker information |
|
2238 | - * |
|
2239 | - * @return Array the tracker information |
|
2240 | - * |
|
2241 | - */ |
|
2237 | + * Gets all the tracker information |
|
2238 | + * |
|
2239 | + * @return Array the tracker information |
|
2240 | + * |
|
2241 | + */ |
|
2242 | 2242 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
2243 | 2243 | { |
2244 | 2244 | global $globalTimezone, $globalDBdriver; |
@@ -2367,11 +2367,11 @@ discard block |
||
2367 | 2367 | } |
2368 | 2368 | |
2369 | 2369 | /** |
2370 | - * Check marine by id |
|
2371 | - * |
|
2372 | - * @return String the ident |
|
2373 | - * |
|
2374 | - */ |
|
2370 | + * Check marine by id |
|
2371 | + * |
|
2372 | + * @return String the ident |
|
2373 | + * |
|
2374 | + */ |
|
2375 | 2375 | public function checkId($id) |
2376 | 2376 | { |
2377 | 2377 | global $globalDBdriver, $globalTimezone; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_marine_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) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $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 | + $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"; |
|
40 | 40 | } else { |
41 | - $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 | + $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"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
82 | 82 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
83 | 83 | if ($filter_query_where != '') { |
84 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
84 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
85 | 85 | } |
86 | 86 | $filter_query = $filter_query_join.$filter_query_where; |
87 | 87 | return $filter_query; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return Array the spotter information |
97 | 97 | * |
98 | 98 | */ |
99 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
99 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
100 | 100 | { |
101 | 101 | date_default_timezone_set('UTC'); |
102 | 102 | if (!is_string($query)) |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | $sth = $this->db->prepare($query.$limitQuery); |
117 | 117 | $sth->execute($params); |
118 | 118 | } catch (PDOException $e) { |
119 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
119 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
120 | 120 | exit(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $num_rows = 0; |
124 | 124 | $spotter_array = array(); |
125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
126 | 126 | { |
127 | 127 | $num_rows++; |
128 | 128 | $temp_array = array(); |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | } |
163 | 163 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
164 | 164 | |
165 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
165 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
166 | 166 | { |
167 | 167 | $Image = new Image($this->db); |
168 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
168 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
169 | 169 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
170 | 170 | unset($Image); |
171 | 171 | if (count($image_array) > 0) { |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | { |
202 | 202 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
203 | 203 | } else { |
204 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
204 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
205 | 205 | } |
206 | 206 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
207 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
208 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
207 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
208 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
209 | 209 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
210 | 210 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
211 | 211 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
212 | 212 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
213 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
214 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
213 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
214 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
215 | 215 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
216 | 216 | } |
217 | 217 | } |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | if ($limit != "") |
245 | 245 | { |
246 | 246 | $limit_array = explode(",", $limit); |
247 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
248 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
247 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
248 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
249 | 249 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
250 | 250 | { |
251 | 251 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | } else { |
260 | 260 | $orderby_query = " ORDER BY marine_output.date DESC"; |
261 | 261 | } |
262 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
263 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
262 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
263 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
264 | 264 | return $spotter_array; |
265 | 265 | } |
266 | 266 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | if ($id == '') return array(); |
279 | 279 | $additional_query = "marine_output.fammarine_id = :id"; |
280 | 280 | $query_values = array(':id' => $id); |
281 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
282 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
281 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
282 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
283 | 283 | return $spotter_array; |
284 | 284 | } |
285 | 285 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $query_values = array(); |
299 | 299 | $limit_query = ''; |
300 | 300 | $additional_query = ''; |
301 | - $filter_query = $this->getFilter($filter,true,true); |
|
301 | + $filter_query = $this->getFilter($filter, true, true); |
|
302 | 302 | if ($ident != "") |
303 | 303 | { |
304 | 304 | if (!is_string($ident)) |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | { |
315 | 315 | $limit_array = explode(",", $limit); |
316 | 316 | |
317 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
318 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
317 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
318 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
319 | 319 | |
320 | 320 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
321 | 321 | { |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $query_values = array(); |
355 | 355 | $limit_query = ''; |
356 | 356 | $additional_query = ''; |
357 | - $filter_query = $this->getFilter($filter,true,true); |
|
357 | + $filter_query = $this->getFilter($filter, true, true); |
|
358 | 358 | if (!is_string($type)) |
359 | 359 | { |
360 | 360 | return false; |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | { |
368 | 368 | $limit_array = explode(",", $limit); |
369 | 369 | |
370 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
371 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
370 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
371 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
372 | 372 | |
373 | 373 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
374 | 374 | { |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | return $spotter_array; |
393 | 393 | } |
394 | 394 | |
395 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
395 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
396 | 396 | { |
397 | 397 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
398 | 398 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | $limit_query = ''; |
401 | 401 | $additional_query = ''; |
402 | 402 | |
403 | - $filter_query = $this->getFilter($filter,true,true); |
|
403 | + $filter_query = $this->getFilter($filter, true, true); |
|
404 | 404 | |
405 | 405 | if ($date != "") |
406 | 406 | { |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | { |
427 | 427 | $limit_array = explode(",", $limit); |
428 | 428 | |
429 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
430 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
429 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
430 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
431 | 431 | |
432 | 432 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
433 | 433 | { |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | $query_values = array(); |
463 | 463 | $limit_query = ''; |
464 | 464 | $additional_query = ''; |
465 | - $filter_query = $this->getFilter($filter,true,true); |
|
466 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
465 | + $filter_query = $this->getFilter($filter, true, true); |
|
466 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
467 | 467 | if ($captain != "") |
468 | 468 | { |
469 | 469 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | if ($limit != "") |
473 | 473 | { |
474 | 474 | $limit_array = explode(",", $limit); |
475 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
476 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
475 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
476 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
477 | 477 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
478 | 478 | { |
479 | 479 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | $query_values = array(); |
506 | 506 | $limit_query = ''; |
507 | 507 | $additional_query = ''; |
508 | - $filter_query = $this->getFilter($filter,true,true); |
|
509 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
508 | + $filter_query = $this->getFilter($filter, true, true); |
|
509 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
510 | 510 | if ($race != "") |
511 | 511 | { |
512 | 512 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | if ($limit != "") |
516 | 516 | { |
517 | 517 | $limit_array = explode(",", $limit); |
518 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
519 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
518 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
519 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
520 | 520 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
521 | 521 | { |
522 | 522 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -541,14 +541,14 @@ discard block |
||
541 | 541 | * @return String Duration of all races |
542 | 542 | * |
543 | 543 | */ |
544 | - public function countRacesByCaptain($captain,$filters = array()) |
|
544 | + public function countRacesByCaptain($captain, $filters = array()) |
|
545 | 545 | { |
546 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
547 | - $filter_query = $this->getFilter($filters,true,true); |
|
548 | - $query = "SELECT COUNT(*) AS nb |
|
546 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
547 | + $filter_query = $this->getFilter($filters, true, true); |
|
548 | + $query = "SELECT COUNT(*) AS nb |
|
549 | 549 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
550 | 550 | $query_values = array(); |
551 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
551 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
552 | 552 | $sth = $this->db->prepare($query); |
553 | 553 | $sth->execute($query_values); |
554 | 554 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | * @return String Duration of all races |
562 | 562 | * |
563 | 563 | */ |
564 | - public function countCaptainsByRace($race,$filters = array()) |
|
564 | + public function countCaptainsByRace($race, $filters = array()) |
|
565 | 565 | { |
566 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
567 | - $filter_query = $this->getFilter($filters,true,true); |
|
568 | - $query = "SELECT COUNT(*) AS nb |
|
566 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
567 | + $filter_query = $this->getFilter($filters, true, true); |
|
568 | + $query = "SELECT COUNT(*) AS nb |
|
569 | 569 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
570 | 570 | $query_values = array(); |
571 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
571 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
572 | 572 | $sth = $this->db->prepare($query); |
573 | 573 | $sth->execute($query_values); |
574 | 574 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -581,44 +581,44 @@ discard block |
||
581 | 581 | * @return Array the boat list |
582 | 582 | * |
583 | 583 | */ |
584 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
584 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
585 | 585 | { |
586 | 586 | global $globalDBdriver; |
587 | - $filter_query = $this->getFilter($filters,true,true); |
|
588 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
589 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
587 | + $filter_query = $this->getFilter($filters, true, true); |
|
588 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
589 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
590 | 590 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
591 | 591 | $query_values = array(); |
592 | 592 | if ($year != '') { |
593 | 593 | if ($globalDBdriver == 'mysql') { |
594 | 594 | $query .= " AND YEAR(marine_output.date) = :year"; |
595 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
595 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
596 | 596 | } else { |
597 | 597 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
598 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
598 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | if ($month != '') { |
602 | 602 | if ($globalDBdriver == 'mysql') { |
603 | 603 | $query .= " AND MONTH(marine_output.date) = :month"; |
604 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
604 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
605 | 605 | } else { |
606 | 606 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
607 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
607 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | if ($day != '') { |
611 | 611 | if ($globalDBdriver == 'mysql') { |
612 | 612 | $query .= " AND DAY(marine_output.date) = :day"; |
613 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
613 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
614 | 614 | } else { |
615 | 615 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
616 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
616 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | $query .= " GROUP BY marine_output.type |
620 | 620 | ORDER BY type_count DESC"; |
621 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
621 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
622 | 622 | $sth = $this->db->prepare($query); |
623 | 623 | $sth->execute($query_values); |
624 | 624 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -630,44 +630,44 @@ discard block |
||
630 | 630 | * @return Array the boat list |
631 | 631 | * |
632 | 632 | */ |
633 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
633 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
634 | 634 | { |
635 | 635 | global $globalDBdriver; |
636 | - $filter_query = $this->getFilter($filters,true,true); |
|
637 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
638 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
636 | + $filter_query = $this->getFilter($filters, true, true); |
|
637 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
638 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
639 | 639 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
640 | 640 | $query_values = array(); |
641 | 641 | if ($year != '') { |
642 | 642 | if ($globalDBdriver == 'mysql') { |
643 | 643 | $query .= " AND YEAR(marine_output.date) = :year"; |
644 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
644 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
645 | 645 | } else { |
646 | 646 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
647 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
647 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | if ($month != '') { |
651 | 651 | if ($globalDBdriver == 'mysql') { |
652 | 652 | $query .= " AND MONTH(marine_output.date) = :month"; |
653 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
653 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
654 | 654 | } else { |
655 | 655 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
656 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
656 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | if ($day != '') { |
660 | 660 | if ($globalDBdriver == 'mysql') { |
661 | 661 | $query .= " AND DAY(marine_output.date) = :day"; |
662 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
662 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
663 | 663 | } else { |
664 | 664 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
665 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
665 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | $query .= " GROUP BY marine_output.type |
669 | 669 | ORDER BY type_count DESC"; |
670 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
670 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
671 | 671 | $sth = $this->db->prepare($query); |
672 | 672 | $sth->execute($query_values); |
673 | 673 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -679,47 +679,47 @@ discard block |
||
679 | 679 | * @return String Duration of all race |
680 | 680 | * |
681 | 681 | */ |
682 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
682 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
683 | 683 | { |
684 | 684 | global $globalDBdriver; |
685 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
686 | - $filter_query = $this->getFilter($filters,true,true); |
|
687 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
685 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
686 | + $filter_query = $this->getFilter($filters, true, true); |
|
687 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
688 | 688 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
689 | 689 | AND last_seen > date"; |
690 | 690 | $query_values = array(); |
691 | 691 | if ($year != '') { |
692 | 692 | if ($globalDBdriver == 'mysql') { |
693 | 693 | $query .= " AND YEAR(marine_output.date) = :year"; |
694 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
694 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
695 | 695 | } else { |
696 | 696 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
697 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
697 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | if ($month != '') { |
701 | 701 | if ($globalDBdriver == 'mysql') { |
702 | 702 | $query .= " AND MONTH(marine_output.date) = :month"; |
703 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
703 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
704 | 704 | } else { |
705 | 705 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
706 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
706 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | if ($day != '') { |
710 | 710 | if ($globalDBdriver == 'mysql') { |
711 | 711 | $query .= " AND DAY(marine_output.date) = :day"; |
712 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
712 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
713 | 713 | } else { |
714 | 714 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
715 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
715 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
716 | 716 | } |
717 | 717 | } |
718 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
718 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
719 | 719 | $sth = $this->db->prepare($query); |
720 | 720 | $sth->execute($query_values); |
721 | 721 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
722 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
722 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
723 | 723 | else return $result[0]['duration']; |
724 | 724 | } |
725 | 725 | |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | */ |
732 | 732 | public function getAllCaptainNames($filters = array()) |
733 | 733 | { |
734 | - $filter_query = $this->getFilter($filters,true,true); |
|
735 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
734 | + $filter_query = $this->getFilter($filters, true, true); |
|
735 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
736 | 736 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
737 | 737 | ORDER BY marine_output.captain_name ASC"; |
738 | 738 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function getAllRaceNames($filters = array()) |
751 | 751 | { |
752 | - $filter_query = $this->getFilter($filters,true,true); |
|
753 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
752 | + $filter_query = $this->getFilter($filters, true, true); |
|
753 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
754 | 754 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
755 | 755 | ORDER BY marine_output.race_name ASC"; |
756 | 756 | |
@@ -766,11 +766,11 @@ discard block |
||
766 | 766 | * @return Array list of source name |
767 | 767 | * |
768 | 768 | */ |
769 | - public function getAllSourceName($type = '',$filters = array()) |
|
769 | + public function getAllSourceName($type = '', $filters = array()) |
|
770 | 770 | { |
771 | - $filter_query = $this->getFilter($filters,true,true); |
|
771 | + $filter_query = $this->getFilter($filters, true, true); |
|
772 | 772 | $query_values = array(); |
773 | - $query = "SELECT DISTINCT marine_output.source_name |
|
773 | + $query = "SELECT DISTINCT marine_output.source_name |
|
774 | 774 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
775 | 775 | if ($type != '') { |
776 | 776 | $query_values = array(':type' => $type); |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | $source_array = array(); |
786 | 786 | $temp_array = array(); |
787 | 787 | |
788 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
788 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
789 | 789 | { |
790 | 790 | $temp_array['source_name'] = $row['source_name']; |
791 | 791 | $source_array[] = $temp_array; |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | */ |
803 | 803 | public function getAllIdents($filters = array()) |
804 | 804 | { |
805 | - $filter_query = $this->getFilter($filters,true,true); |
|
806 | - $query = "SELECT DISTINCT marine_output.ident |
|
805 | + $filter_query = $this->getFilter($filters, true, true); |
|
806 | + $query = "SELECT DISTINCT marine_output.ident |
|
807 | 807 | FROM marine_output".$filter_query." marine_output.ident <> '' |
808 | 808 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
809 | 809 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | $ident_array = array(); |
814 | 814 | $temp_array = array(); |
815 | 815 | |
816 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
816 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
817 | 817 | { |
818 | 818 | $temp_array['ident'] = $row['ident']; |
819 | 819 | $ident_array[] = $temp_array; |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | */ |
831 | 831 | public function getIdentity($mmsi) |
832 | 832 | { |
833 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
833 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
834 | 834 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
835 | 835 | $sth = $this->db->prepare($query); |
836 | 836 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -843,23 +843,23 @@ discard block |
||
843 | 843 | * Add identity |
844 | 844 | * |
845 | 845 | */ |
846 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
846 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
847 | 847 | { |
848 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
848 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
849 | 849 | if ($mmsi != '') { |
850 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
851 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
852 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
853 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
850 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
851 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
852 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
853 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
854 | 854 | $identinfo = $this->getIdentity($mmsi); |
855 | 855 | if (empty($identinfo)) { |
856 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
856 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
857 | 857 | $sth = $this->db->prepare($query); |
858 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
858 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
859 | 859 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
860 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
860 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
861 | 861 | $sth = $this->db->prepare($query); |
862 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
862 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | } |
@@ -880,12 +880,12 @@ discard block |
||
880 | 880 | } else $offset = '+00:00'; |
881 | 881 | |
882 | 882 | if ($globalDBdriver == 'mysql') { |
883 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
883 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
884 | 884 | FROM marine_output |
885 | 885 | WHERE marine_output.date <> '' |
886 | 886 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
887 | 887 | } else { |
888 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
888 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
889 | 889 | FROM marine_output |
890 | 890 | WHERE marine_output.date <> '' |
891 | 891 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $date_array = array(); |
898 | 898 | $temp_array = array(); |
899 | 899 | |
900 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
900 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
901 | 901 | { |
902 | 902 | $temp_array['date'] = $row['date']; |
903 | 903 | |
@@ -915,10 +915,10 @@ discard block |
||
915 | 915 | * @return String success or false |
916 | 916 | * |
917 | 917 | */ |
918 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
918 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
919 | 919 | { |
920 | 920 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
921 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
921 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
922 | 922 | try { |
923 | 923 | $sth = $this->db->prepare($query); |
924 | 924 | $sth->execute($query_values); |
@@ -936,10 +936,10 @@ discard block |
||
936 | 936 | * @return String success or false |
937 | 937 | * |
938 | 938 | */ |
939 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
939 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
940 | 940 | { |
941 | 941 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
942 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
942 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
943 | 943 | try { |
944 | 944 | $sth = $this->db->prepare($query); |
945 | 945 | $sth->execute($query_values); |
@@ -958,11 +958,11 @@ discard block |
||
958 | 958 | * @return String success or false |
959 | 959 | * |
960 | 960 | */ |
961 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
961 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
962 | 962 | { |
963 | 963 | |
964 | 964 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
965 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
965 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
966 | 966 | |
967 | 967 | try { |
968 | 968 | $sth = $this->db->prepare($query); |
@@ -982,10 +982,10 @@ discard block |
||
982 | 982 | * @return String success or false |
983 | 983 | * |
984 | 984 | */ |
985 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL) |
|
985 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL) |
|
986 | 986 | { |
987 | 987 | $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, distance = :distance, race_rank = :race_rank, race_time = :race_time WHERE fammarine_id = :fammarine_id'; |
988 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
988 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
989 | 989 | |
990 | 990 | try { |
991 | 991 | $sth = $this->db->prepare($query); |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | * @param String $verticalrate vertival rate of flight |
1024 | 1024 | * @return String success or false |
1025 | 1025 | */ |
1026 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
|
1026 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
1027 | 1027 | { |
1028 | 1028 | global $globalURL, $globalMarineImageFetch; |
1029 | 1029 | |
@@ -1090,38 +1090,38 @@ discard block |
||
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | |
1093 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
1093 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
1094 | 1094 | { |
1095 | 1095 | $date = date("Y-m-d H:i:s", time()); |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1099 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1100 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1101 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1102 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1103 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1104 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1105 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1106 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
1107 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
1108 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
1109 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
1110 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1111 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1112 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1113 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1114 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1115 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1116 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1117 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
1118 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
1119 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1098 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1099 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1100 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1101 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1102 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1103 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1104 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1105 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1106 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
1107 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
1108 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
1109 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
1110 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1111 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1112 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
1113 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
1114 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
1115 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
1116 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
1117 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
1118 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
1119 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1120 | 1120 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
1121 | 1121 | $Image = new Image($this->db); |
1122 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
1122 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
1123 | 1123 | if (!isset($image_array[0]['mmsi'])) { |
1124 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
1124 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
1125 | 1125 | } |
1126 | 1126 | unset($Image); |
1127 | 1127 | } |
@@ -1137,10 +1137,10 @@ discard block |
||
1137 | 1137 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
1138 | 1138 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
1139 | 1139 | if ($arrival_date == '') $arrival_date = NULL; |
1140 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
1140 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
1141 | 1141 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
1142 | 1142 | |
1143 | - $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,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
1143 | + $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, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
1144 | 1144 | try { |
1145 | 1145 | $sth = $this->db->prepare($query); |
1146 | 1146 | $sth->execute($query_values); |
@@ -1164,13 +1164,13 @@ discard block |
||
1164 | 1164 | { |
1165 | 1165 | global $globalDBdriver, $globalTimezone; |
1166 | 1166 | if ($globalDBdriver == 'mysql') { |
1167 | - $query = "SELECT marine_output.ident FROM marine_output |
|
1167 | + $query = "SELECT marine_output.ident FROM marine_output |
|
1168 | 1168 | WHERE marine_output.ident = :ident |
1169 | 1169 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
1170 | 1170 | AND marine_output.date < UTC_TIMESTAMP()"; |
1171 | 1171 | $query_data = array(':ident' => $ident); |
1172 | 1172 | } else { |
1173 | - $query = "SELECT marine_output.ident FROM marine_output |
|
1173 | + $query = "SELECT marine_output.ident FROM marine_output |
|
1174 | 1174 | WHERE marine_output.ident = :ident |
1175 | 1175 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
1176 | 1176 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1179,8 +1179,8 @@ discard block |
||
1179 | 1179 | |
1180 | 1180 | $sth = $this->db->prepare($query); |
1181 | 1181 | $sth->execute($query_data); |
1182 | - $ident_result=''; |
|
1183 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1182 | + $ident_result = ''; |
|
1183 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1184 | 1184 | { |
1185 | 1185 | $ident_result = $row['ident']; |
1186 | 1186 | } |
@@ -1206,8 +1206,8 @@ discard block |
||
1206 | 1206 | return false; |
1207 | 1207 | } else { |
1208 | 1208 | $q_array = explode(" ", $q); |
1209 | - foreach ($q_array as $q_item){ |
|
1210 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1209 | + foreach ($q_array as $q_item) { |
|
1210 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1211 | 1211 | $additional_query .= " AND ("; |
1212 | 1212 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
1213 | 1213 | $additional_query .= ")"; |
@@ -1215,11 +1215,11 @@ discard block |
||
1215 | 1215 | } |
1216 | 1216 | } |
1217 | 1217 | if ($globalDBdriver == 'mysql') { |
1218 | - $query = "SELECT marine_output.* FROM marine_output |
|
1218 | + $query = "SELECT marine_output.* FROM marine_output |
|
1219 | 1219 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
1220 | 1220 | AND marine_output.date < UTC_TIMESTAMP()"; |
1221 | 1221 | } else { |
1222 | - $query = "SELECT marine_output.* FROM marine_output |
|
1222 | + $query = "SELECT marine_output.* FROM marine_output |
|
1223 | 1223 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
1224 | 1224 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
1225 | 1225 | } |
@@ -1238,16 +1238,16 @@ discard block |
||
1238 | 1238 | * |
1239 | 1239 | */ |
1240 | 1240 | |
1241 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
1241 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
1242 | 1242 | { |
1243 | 1243 | global $globalDBdriver, $globalArchive; |
1244 | 1244 | //$filter_query = $this->getFilter($filters,true,true); |
1245 | - $Connection= new Connection($this->db); |
|
1245 | + $Connection = new Connection($this->db); |
|
1246 | 1246 | if (!$Connection->tableExists('countries')) return array(); |
1247 | 1247 | require_once('class.SpotterLive.php'); |
1248 | 1248 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
1249 | 1249 | $MarineLive = new MarineLive($this->db); |
1250 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
1250 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
1251 | 1251 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
1252 | 1252 | if ($olderthanmonths > 0) { |
1253 | 1253 | if ($globalDBdriver == 'mysql') { |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | } else { |
1268 | 1268 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
1269 | 1269 | $MarineArchive = new MarineArchive($this->db); |
1270 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
1270 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
1271 | 1271 | $filter_query .= " over_country <> ''"; |
1272 | 1272 | if ($olderthanmonths > 0) { |
1273 | 1273 | if ($globalDBdriver == 'mysql') { |
@@ -1295,7 +1295,7 @@ discard block |
||
1295 | 1295 | $flight_array = array(); |
1296 | 1296 | $temp_array = array(); |
1297 | 1297 | |
1298 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1298 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1299 | 1299 | { |
1300 | 1300 | $temp_array['marine_count'] = $row['nb']; |
1301 | 1301 | $temp_array['marine_country'] = $row['name']; |
@@ -1314,11 +1314,11 @@ discard block |
||
1314 | 1314 | * @return Array the callsign list |
1315 | 1315 | * |
1316 | 1316 | */ |
1317 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
1317 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1318 | 1318 | { |
1319 | 1319 | global $globalDBdriver; |
1320 | - $filter_query = $this->getFilter($filters,true,true); |
|
1321 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1320 | + $filter_query = $this->getFilter($filters, true, true); |
|
1321 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1322 | 1322 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1323 | 1323 | if ($olderthanmonths > 0) { |
1324 | 1324 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1332,28 +1332,28 @@ discard block |
||
1332 | 1332 | if ($year != '') { |
1333 | 1333 | if ($globalDBdriver == 'mysql') { |
1334 | 1334 | $query .= " AND YEAR(marine_output.date) = :year"; |
1335 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1335 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1336 | 1336 | } else { |
1337 | 1337 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1338 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1338 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1339 | 1339 | } |
1340 | 1340 | } |
1341 | 1341 | if ($month != '') { |
1342 | 1342 | if ($globalDBdriver == 'mysql') { |
1343 | 1343 | $query .= " AND MONTH(marine_output.date) = :month"; |
1344 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1344 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1345 | 1345 | } else { |
1346 | 1346 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1347 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1347 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1348 | 1348 | } |
1349 | 1349 | } |
1350 | 1350 | if ($day != '') { |
1351 | 1351 | if ($globalDBdriver == 'mysql') { |
1352 | 1352 | $query .= " AND DAY(marine_output.date) = :day"; |
1353 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1353 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1354 | 1354 | } else { |
1355 | 1355 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1356 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1356 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1357 | 1357 | } |
1358 | 1358 | } |
1359 | 1359 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | $callsign_array = array(); |
1366 | 1366 | $temp_array = array(); |
1367 | 1367 | |
1368 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1368 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1369 | 1369 | { |
1370 | 1370 | $temp_array['callsign_icao'] = $row['ident']; |
1371 | 1371 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | $date_array = array(); |
1418 | 1418 | $temp_array = array(); |
1419 | 1419 | |
1420 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1420 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1421 | 1421 | { |
1422 | 1422 | $temp_array['date_name'] = $row['date_name']; |
1423 | 1423 | $temp_array['date_count'] = $row['date_count']; |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | $datetime = new DateTime(); |
1444 | 1444 | $offset = $datetime->format('P'); |
1445 | 1445 | } else $offset = '+00:00'; |
1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
1447 | 1447 | if ($globalDBdriver == 'mysql') { |
1448 | 1448 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1449 | 1449 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | $date_array = array(); |
1465 | 1465 | $temp_array = array(); |
1466 | 1466 | |
1467 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1467 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1468 | 1468 | { |
1469 | 1469 | $temp_array['date_name'] = $row['date_name']; |
1470 | 1470 | $temp_array['date_count'] = $row['date_count']; |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | $datetime = new DateTime(); |
1490 | 1490 | $offset = $datetime->format('P'); |
1491 | 1491 | } else $offset = '+00:00'; |
1492 | - $filter_query = $this->getFilter($filters,true,true); |
|
1492 | + $filter_query = $this->getFilter($filters, true, true); |
|
1493 | 1493 | if ($globalDBdriver == 'mysql') { |
1494 | 1494 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1495 | 1495 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | $date_array = array(); |
1511 | 1511 | $temp_array = array(); |
1512 | 1512 | |
1513 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1513 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1514 | 1514 | { |
1515 | 1515 | $temp_array['date_name'] = $row['date_name']; |
1516 | 1516 | $temp_array['date_count'] = $row['date_count']; |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | $date_array = array(); |
1558 | 1558 | $temp_array = array(); |
1559 | 1559 | |
1560 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1560 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1561 | 1561 | { |
1562 | 1562 | $temp_array['month_name'] = $row['month_name']; |
1563 | 1563 | $temp_array['year_name'] = $row['year_name']; |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | $datetime = new DateTime(); |
1587 | 1587 | $offset = $datetime->format('P'); |
1588 | 1588 | } else $offset = '+00:00'; |
1589 | - $filter_query = $this->getFilter($filters,true,true); |
|
1589 | + $filter_query = $this->getFilter($filters, true, true); |
|
1590 | 1590 | if ($globalDBdriver == 'mysql') { |
1591 | 1591 | $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 |
1592 | 1592 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | $date_array = array(); |
1608 | 1608 | $temp_array = array(); |
1609 | 1609 | |
1610 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1610 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1611 | 1611 | { |
1612 | 1612 | $temp_array['year_name'] = $row['year_name']; |
1613 | 1613 | $temp_array['month_name'] = $row['month_name']; |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | * @return Array the hour list |
1628 | 1628 | * |
1629 | 1629 | */ |
1630 | - public function countAllHours($orderby,$filters = array()) |
|
1630 | + public function countAllHours($orderby, $filters = array()) |
|
1631 | 1631 | { |
1632 | 1632 | global $globalTimezone, $globalDBdriver; |
1633 | 1633 | if ($globalTimezone != '') { |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | $hour_array = array(); |
1676 | 1676 | $temp_array = array(); |
1677 | 1677 | |
1678 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1678 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1679 | 1679 | { |
1680 | 1680 | $temp_array['hour_name'] = $row['hour_name']; |
1681 | 1681 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1697,8 +1697,8 @@ discard block |
||
1697 | 1697 | public function countAllHoursByDate($date, $filters = array()) |
1698 | 1698 | { |
1699 | 1699 | global $globalTimezone, $globalDBdriver; |
1700 | - $filter_query = $this->getFilter($filters,true,true); |
|
1701 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1700 | + $filter_query = $this->getFilter($filters, true, true); |
|
1701 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1702 | 1702 | if ($globalTimezone != '') { |
1703 | 1703 | date_default_timezone_set($globalTimezone); |
1704 | 1704 | $datetime = new DateTime($date); |
@@ -1706,12 +1706,12 @@ discard block |
||
1706 | 1706 | } else $offset = '+00:00'; |
1707 | 1707 | |
1708 | 1708 | if ($globalDBdriver == 'mysql') { |
1709 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1709 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1710 | 1710 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1711 | 1711 | GROUP BY hour_name |
1712 | 1712 | ORDER BY hour_name ASC"; |
1713 | 1713 | } else { |
1714 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1714 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1715 | 1715 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1716 | 1716 | GROUP BY hour_name |
1717 | 1717 | ORDER BY hour_name ASC"; |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | $hour_array = array(); |
1724 | 1724 | $temp_array = array(); |
1725 | 1725 | |
1726 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1726 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1727 | 1727 | { |
1728 | 1728 | $temp_array['hour_name'] = $row['hour_name']; |
1729 | 1729 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1745,8 +1745,8 @@ discard block |
||
1745 | 1745 | public function countAllHoursByIdent($ident, $filters = array()) |
1746 | 1746 | { |
1747 | 1747 | global $globalTimezone, $globalDBdriver; |
1748 | - $filter_query = $this->getFilter($filters,true,true); |
|
1749 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1748 | + $filter_query = $this->getFilter($filters, true, true); |
|
1749 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1750 | 1750 | if ($globalTimezone != '') { |
1751 | 1751 | date_default_timezone_set($globalTimezone); |
1752 | 1752 | $datetime = new DateTime(); |
@@ -1754,12 +1754,12 @@ discard block |
||
1754 | 1754 | } else $offset = '+00:00'; |
1755 | 1755 | |
1756 | 1756 | if ($globalDBdriver == 'mysql') { |
1757 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1757 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1758 | 1758 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1759 | 1759 | GROUP BY hour_name |
1760 | 1760 | ORDER BY hour_name ASC"; |
1761 | 1761 | } else { |
1762 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1762 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1763 | 1763 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1764 | 1764 | GROUP BY hour_name |
1765 | 1765 | ORDER BY hour_name ASC"; |
@@ -1767,12 +1767,12 @@ discard block |
||
1767 | 1767 | |
1768 | 1768 | |
1769 | 1769 | $sth = $this->db->prepare($query); |
1770 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1770 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1771 | 1771 | |
1772 | 1772 | $hour_array = array(); |
1773 | 1773 | $temp_array = array(); |
1774 | 1774 | |
1775 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1775 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1776 | 1776 | { |
1777 | 1777 | $temp_array['hour_name'] = $row['hour_name']; |
1778 | 1778 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1791,33 +1791,33 @@ discard block |
||
1791 | 1791 | * @return Integer the number of vessels |
1792 | 1792 | * |
1793 | 1793 | */ |
1794 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1794 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1795 | 1795 | { |
1796 | 1796 | global $globalDBdriver; |
1797 | 1797 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1798 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1798 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1799 | 1799 | $query_values = array(); |
1800 | 1800 | $query = ''; |
1801 | 1801 | if ($year != '') { |
1802 | 1802 | if ($globalDBdriver == 'mysql') { |
1803 | 1803 | $query .= " AND YEAR(marine_output.date) = :year"; |
1804 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1804 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1805 | 1805 | } else { |
1806 | 1806 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1807 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1807 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1808 | 1808 | } |
1809 | 1809 | } |
1810 | 1810 | if ($month != '') { |
1811 | 1811 | if ($globalDBdriver == 'mysql') { |
1812 | 1812 | $query .= " AND MONTH(marine_output.date) = :month"; |
1813 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1813 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1814 | 1814 | } else { |
1815 | 1815 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1816 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1816 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1817 | 1817 | } |
1818 | 1818 | } |
1819 | 1819 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1820 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1820 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1821 | 1821 | |
1822 | 1822 | $sth = $this->db->prepare($queryi); |
1823 | 1823 | $sth->execute($query_values); |
@@ -1830,32 +1830,32 @@ discard block |
||
1830 | 1830 | * @return Integer the number of vessels |
1831 | 1831 | * |
1832 | 1832 | */ |
1833 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1833 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1834 | 1834 | { |
1835 | 1835 | global $globalDBdriver; |
1836 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1836 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1837 | 1837 | $query_values = array(); |
1838 | 1838 | $query = ''; |
1839 | 1839 | if ($year != '') { |
1840 | 1840 | if ($globalDBdriver == 'mysql') { |
1841 | 1841 | $query .= " AND YEAR(marine_output.date) = :year"; |
1842 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1842 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1843 | 1843 | } else { |
1844 | 1844 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1845 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1845 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1846 | 1846 | } |
1847 | 1847 | } |
1848 | 1848 | if ($month != '') { |
1849 | 1849 | if ($globalDBdriver == 'mysql') { |
1850 | 1850 | $query .= " AND MONTH(marine_output.date) = :month"; |
1851 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1851 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1852 | 1852 | } else { |
1853 | 1853 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1854 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1854 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1855 | 1855 | } |
1856 | 1856 | } |
1857 | 1857 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1858 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1858 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1859 | 1859 | |
1860 | 1860 | $sth = $this->db->prepare($queryi); |
1861 | 1861 | $sth->execute($query_values); |
@@ -1872,7 +1872,7 @@ discard block |
||
1872 | 1872 | public function countAllHoursFromToday($filters = array()) |
1873 | 1873 | { |
1874 | 1874 | global $globalTimezone, $globalDBdriver; |
1875 | - $filter_query = $this->getFilter($filters,true,true); |
|
1875 | + $filter_query = $this->getFilter($filters, true, true); |
|
1876 | 1876 | if ($globalTimezone != '') { |
1877 | 1877 | date_default_timezone_set($globalTimezone); |
1878 | 1878 | $datetime = new DateTime(); |
@@ -1880,12 +1880,12 @@ discard block |
||
1880 | 1880 | } else $offset = '+00:00'; |
1881 | 1881 | |
1882 | 1882 | if ($globalDBdriver == 'mysql') { |
1883 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1883 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1884 | 1884 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1885 | 1885 | GROUP BY hour_name |
1886 | 1886 | ORDER BY hour_name ASC"; |
1887 | 1887 | } else { |
1888 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1888 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1889 | 1889 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1890 | 1890 | GROUP BY hour_name |
1891 | 1891 | ORDER BY hour_name ASC"; |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | $hour_array = array(); |
1898 | 1898 | $temp_array = array(); |
1899 | 1899 | |
1900 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1900 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1901 | 1901 | { |
1902 | 1902 | $temp_array['hour_name'] = $row['hour_name']; |
1903 | 1903 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1916,9 +1916,9 @@ discard block |
||
1916 | 1916 | */ |
1917 | 1917 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1918 | 1918 | { |
1919 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1919 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1920 | 1920 | |
1921 | - $query = "SELECT marine_output.marine_id |
|
1921 | + $query = "SELECT marine_output.marine_id |
|
1922 | 1922 | FROM marine_output |
1923 | 1923 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1924 | 1924 | |
@@ -1926,7 +1926,7 @@ discard block |
||
1926 | 1926 | $sth = $this->db->prepare($query); |
1927 | 1927 | $sth->execute(); |
1928 | 1928 | |
1929 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1929 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1930 | 1930 | { |
1931 | 1931 | return $row['marine_id']; |
1932 | 1932 | } |
@@ -1951,23 +1951,23 @@ discard block |
||
1951 | 1951 | } |
1952 | 1952 | |
1953 | 1953 | $current_date = date("Y-m-d H:i:s"); |
1954 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1954 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1955 | 1955 | |
1956 | 1956 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1957 | 1957 | |
1958 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1958 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1959 | 1959 | $years = $time_array['years']; |
1960 | 1960 | |
1961 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1961 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1962 | 1962 | $months = $time_array['months']; |
1963 | 1963 | |
1964 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1964 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1965 | 1965 | $days = $time_array['days']; |
1966 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1966 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1967 | 1967 | $hours = $time_array['hours']; |
1968 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1968 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1969 | 1969 | $minutes = $time_array['minutes']; |
1970 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1970 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1971 | 1971 | |
1972 | 1972 | return $time_array; |
1973 | 1973 | } |
@@ -1990,63 +1990,63 @@ discard block |
||
1990 | 1990 | $temp_array['direction_degree'] = $direction; |
1991 | 1991 | $temp_array['direction_shortname'] = "N"; |
1992 | 1992 | $temp_array['direction_fullname'] = "North"; |
1993 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1993 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1994 | 1994 | $temp_array['direction_degree'] = $direction; |
1995 | 1995 | $temp_array['direction_shortname'] = "NNE"; |
1996 | 1996 | $temp_array['direction_fullname'] = "North-Northeast"; |
1997 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1997 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1998 | 1998 | $temp_array['direction_degree'] = $direction; |
1999 | 1999 | $temp_array['direction_shortname'] = "NE"; |
2000 | 2000 | $temp_array['direction_fullname'] = "Northeast"; |
2001 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
2001 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
2002 | 2002 | $temp_array['direction_degree'] = $direction; |
2003 | 2003 | $temp_array['direction_shortname'] = "ENE"; |
2004 | 2004 | $temp_array['direction_fullname'] = "East-Northeast"; |
2005 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
2005 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
2006 | 2006 | $temp_array['direction_degree'] = $direction; |
2007 | 2007 | $temp_array['direction_shortname'] = "E"; |
2008 | 2008 | $temp_array['direction_fullname'] = "East"; |
2009 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
2009 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
2010 | 2010 | $temp_array['direction_degree'] = $direction; |
2011 | 2011 | $temp_array['direction_shortname'] = "ESE"; |
2012 | 2012 | $temp_array['direction_fullname'] = "East-Southeast"; |
2013 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
2013 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
2014 | 2014 | $temp_array['direction_degree'] = $direction; |
2015 | 2015 | $temp_array['direction_shortname'] = "SE"; |
2016 | 2016 | $temp_array['direction_fullname'] = "Southeast"; |
2017 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
2017 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
2018 | 2018 | $temp_array['direction_degree'] = $direction; |
2019 | 2019 | $temp_array['direction_shortname'] = "SSE"; |
2020 | 2020 | $temp_array['direction_fullname'] = "South-Southeast"; |
2021 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
2021 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
2022 | 2022 | $temp_array['direction_degree'] = $direction; |
2023 | 2023 | $temp_array['direction_shortname'] = "S"; |
2024 | 2024 | $temp_array['direction_fullname'] = "South"; |
2025 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
2025 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
2026 | 2026 | $temp_array['direction_degree'] = $direction; |
2027 | 2027 | $temp_array['direction_shortname'] = "SSW"; |
2028 | 2028 | $temp_array['direction_fullname'] = "South-Southwest"; |
2029 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
2029 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
2030 | 2030 | $temp_array['direction_degree'] = $direction; |
2031 | 2031 | $temp_array['direction_shortname'] = "SW"; |
2032 | 2032 | $temp_array['direction_fullname'] = "Southwest"; |
2033 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
2033 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
2034 | 2034 | $temp_array['direction_degree'] = $direction; |
2035 | 2035 | $temp_array['direction_shortname'] = "WSW"; |
2036 | 2036 | $temp_array['direction_fullname'] = "West-Southwest"; |
2037 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
2037 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
2038 | 2038 | $temp_array['direction_degree'] = $direction; |
2039 | 2039 | $temp_array['direction_shortname'] = "W"; |
2040 | 2040 | $temp_array['direction_fullname'] = "West"; |
2041 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
2041 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
2042 | 2042 | $temp_array['direction_degree'] = $direction; |
2043 | 2043 | $temp_array['direction_shortname'] = "WNW"; |
2044 | 2044 | $temp_array['direction_fullname'] = "West-Northwest"; |
2045 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
2045 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
2046 | 2046 | $temp_array['direction_degree'] = $direction; |
2047 | 2047 | $temp_array['direction_shortname'] = "NW"; |
2048 | 2048 | $temp_array['direction_fullname'] = "Northwest"; |
2049 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
2049 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
2050 | 2050 | $temp_array['direction_degree'] = $direction; |
2051 | 2051 | $temp_array['direction_shortname'] = "NNW"; |
2052 | 2052 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2063,11 +2063,11 @@ discard block |
||
2063 | 2063 | * @param Float $longitude longitute of the flight |
2064 | 2064 | * @return String the countrie |
2065 | 2065 | */ |
2066 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
2066 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
2067 | 2067 | { |
2068 | 2068 | global $globalDBdriver, $globalDebug; |
2069 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2070 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
2069 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
2070 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
2071 | 2071 | |
2072 | 2072 | $Connection = new Connection($this->db); |
2073 | 2073 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2107,7 +2107,7 @@ discard block |
||
2107 | 2107 | public function getCountryFromISO2($iso2) |
2108 | 2108 | { |
2109 | 2109 | global $globalDBdriver, $globalDebug; |
2110 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
2110 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
2111 | 2111 | |
2112 | 2112 | $Connection = new Connection($this->db); |
2113 | 2113 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | |
2156 | 2156 | $bitly_data = json_decode($bitly_data); |
2157 | 2157 | $bitly_url = ''; |
2158 | - if ($bitly_data->status_txt = "OK"){ |
|
2158 | + if ($bitly_data->status_txt = "OK") { |
|
2159 | 2159 | $bitly_url = $bitly_data->data->url; |
2160 | 2160 | } |
2161 | 2161 | |
@@ -2169,11 +2169,11 @@ discard block |
||
2169 | 2169 | * @return Array the vessel type list |
2170 | 2170 | * |
2171 | 2171 | */ |
2172 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
2172 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
2173 | 2173 | { |
2174 | 2174 | global $globalDBdriver; |
2175 | - $filter_query = $this->getFilter($filters,true,true); |
|
2176 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
2175 | + $filter_query = $this->getFilter($filters, true, true); |
|
2176 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
2177 | 2177 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
2178 | 2178 | if ($olderthanmonths > 0) { |
2179 | 2179 | if ($globalDBdriver == 'mysql') { |
@@ -2193,28 +2193,28 @@ discard block |
||
2193 | 2193 | if ($year != '') { |
2194 | 2194 | if ($globalDBdriver == 'mysql') { |
2195 | 2195 | $query .= " AND YEAR(marine_output.date) = :year"; |
2196 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
2196 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
2197 | 2197 | } else { |
2198 | 2198 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
2199 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
2199 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
2200 | 2200 | } |
2201 | 2201 | } |
2202 | 2202 | if ($month != '') { |
2203 | 2203 | if ($globalDBdriver == 'mysql') { |
2204 | 2204 | $query .= " AND MONTH(marine_output.date) = :month"; |
2205 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2205 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2206 | 2206 | } else { |
2207 | 2207 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
2208 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
2208 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
2209 | 2209 | } |
2210 | 2210 | } |
2211 | 2211 | if ($day != '') { |
2212 | 2212 | if ($globalDBdriver == 'mysql') { |
2213 | 2213 | $query .= " AND DAY(marine_output.date) = :day"; |
2214 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
2214 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
2215 | 2215 | } else { |
2216 | 2216 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
2217 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
2217 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
2218 | 2218 | } |
2219 | 2219 | } |
2220 | 2220 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2223,7 +2223,7 @@ discard block |
||
2223 | 2223 | $sth->execute($query_values); |
2224 | 2224 | $marine_array = array(); |
2225 | 2225 | $temp_array = array(); |
2226 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2226 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2227 | 2227 | { |
2228 | 2228 | $temp_array['marine_type'] = $row['marine_type']; |
2229 | 2229 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -2239,13 +2239,13 @@ discard block |
||
2239 | 2239 | * @return Array the tracker information |
2240 | 2240 | * |
2241 | 2241 | */ |
2242 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
2242 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
2243 | 2243 | { |
2244 | 2244 | global $globalTimezone, $globalDBdriver; |
2245 | 2245 | date_default_timezone_set('UTC'); |
2246 | 2246 | $query_values = array(); |
2247 | 2247 | $additional_query = ''; |
2248 | - $filter_query = $this->getFilter($filters,true,true); |
|
2248 | + $filter_query = $this->getFilter($filters, true, true); |
|
2249 | 2249 | if ($q != "") |
2250 | 2250 | { |
2251 | 2251 | if (!is_string($q)) |
@@ -2253,8 +2253,8 @@ discard block |
||
2253 | 2253 | return false; |
2254 | 2254 | } else { |
2255 | 2255 | $q_array = explode(" ", $q); |
2256 | - foreach ($q_array as $q_item){ |
|
2257 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
2256 | + foreach ($q_array as $q_item) { |
|
2257 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
2258 | 2258 | $additional_query .= " AND ("; |
2259 | 2259 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
2260 | 2260 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2266,42 +2266,42 @@ discard block |
||
2266 | 2266 | } |
2267 | 2267 | if ($callsign != "") |
2268 | 2268 | { |
2269 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
2269 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
2270 | 2270 | if (!is_string($callsign)) |
2271 | 2271 | { |
2272 | 2272 | return false; |
2273 | 2273 | } else { |
2274 | 2274 | $additional_query .= " AND marine_output.ident = :callsign"; |
2275 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
2275 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
2276 | 2276 | } |
2277 | 2277 | } |
2278 | 2278 | if ($mmsi != "") |
2279 | 2279 | { |
2280 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
2280 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
2281 | 2281 | if (!is_numeric($mmsi)) |
2282 | 2282 | { |
2283 | 2283 | return false; |
2284 | 2284 | } else { |
2285 | 2285 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
2286 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
2286 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
2287 | 2287 | } |
2288 | 2288 | } |
2289 | 2289 | if ($imo != "") |
2290 | 2290 | { |
2291 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
2291 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
2292 | 2292 | if (!is_numeric($imo)) |
2293 | 2293 | { |
2294 | 2294 | return false; |
2295 | 2295 | } else { |
2296 | 2296 | $additional_query .= " AND marine_output.imo = :imo"; |
2297 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
2297 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
2298 | 2298 | } |
2299 | 2299 | } |
2300 | 2300 | if ($date_posted != "") |
2301 | 2301 | { |
2302 | 2302 | $date_array = explode(",", $date_posted); |
2303 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
2304 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
2303 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
2304 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
2305 | 2305 | if ($globalTimezone != '') { |
2306 | 2306 | date_default_timezone_set($globalTimezone); |
2307 | 2307 | $datetime = new DateTime(); |
@@ -2328,8 +2328,8 @@ discard block |
||
2328 | 2328 | if ($limit != "") |
2329 | 2329 | { |
2330 | 2330 | $limit_array = explode(",", $limit); |
2331 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2332 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2331 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2332 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2333 | 2333 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2334 | 2334 | { |
2335 | 2335 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2347,22 +2347,22 @@ discard block |
||
2347 | 2347 | } |
2348 | 2348 | } |
2349 | 2349 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2350 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2350 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2351 | 2351 | if ($globalDBdriver == 'mysql') { |
2352 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2352 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
2353 | 2353 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2354 | 2354 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
2355 | 2355 | } else { |
2356 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2356 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
2357 | 2357 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
2358 | 2358 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
2359 | 2359 | } |
2360 | 2360 | } else { |
2361 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2361 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2362 | 2362 | ".$additional_query." |
2363 | 2363 | ".$orderby_query; |
2364 | 2364 | } |
2365 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2365 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2366 | 2366 | return $marine_array; |
2367 | 2367 | } |
2368 | 2368 | |
@@ -2375,13 +2375,13 @@ discard block |
||
2375 | 2375 | public function checkId($id) |
2376 | 2376 | { |
2377 | 2377 | global $globalDBdriver, $globalTimezone; |
2378 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
2378 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
2379 | 2379 | WHERE marine_live.fammarine_id = :id'; |
2380 | 2380 | $query_data = array(':id' => $id); |
2381 | 2381 | $sth = $this->db->prepare($query); |
2382 | 2382 | $sth->execute($query_data); |
2383 | - $ident_result=''; |
|
2384 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2383 | + $ident_result = ''; |
|
2384 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
2385 | 2385 | { |
2386 | 2386 | $ident_result = $row['fammarine_id']; |
2387 | 2387 | } |
@@ -2390,7 +2390,7 @@ discard block |
||
2390 | 2390 | |
2391 | 2391 | public function getOrderBy() |
2392 | 2392 | { |
2393 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
2393 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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")); |
|
2394 | 2394 | |
2395 | 2395 | return $orderby; |
2396 | 2396 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -78,8 +82,11 @@ discard block |
||
78 | 82 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
79 | 83 | } |
80 | 84 | } |
81 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
82 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
85 | + if ($filter_query_where == '' && $where) { |
|
86 | + $filter_query_where = ' WHERE'; |
|
87 | + } elseif ($filter_query_where != '' && $and) { |
|
88 | + $filter_query_where .= ' AND'; |
|
89 | + } |
|
83 | 90 | if ($filter_query_where != '') { |
84 | 91 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
85 | 92 | } |
@@ -133,40 +140,78 @@ discard block |
||
133 | 140 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
134 | 141 | } elseif (isset($row['spotter_archive_output_id'])) { |
135 | 142 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
136 | - */} |
|
137 | - elseif (isset($row['marineid'])) { |
|
143 | + */} elseif (isset($row['marineid'])) { |
|
138 | 144 | $temp_array['marine_id'] = $row['marineid']; |
139 | 145 | } else { |
140 | 146 | $temp_array['marine_id'] = ''; |
141 | 147 | } |
142 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
143 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
144 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
145 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
146 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
147 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
148 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
149 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
150 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
151 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
152 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
153 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
154 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
155 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
156 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
157 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
148 | + if (isset($row['fammarine_id'])) { |
|
149 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
150 | + } |
|
151 | + if (isset($row['mmsi'])) { |
|
152 | + $temp_array['mmsi'] = $row['mmsi']; |
|
153 | + } |
|
154 | + if (isset($row['type'])) { |
|
155 | + $temp_array['type'] = $row['type']; |
|
156 | + } |
|
157 | + if (isset($row['type_id'])) { |
|
158 | + $temp_array['type_id'] = $row['type_id']; |
|
159 | + } |
|
160 | + if (isset($row['status'])) { |
|
161 | + $temp_array['status'] = $row['status']; |
|
162 | + } |
|
163 | + if (isset($row['status_id'])) { |
|
164 | + $temp_array['status_id'] = $row['status_id']; |
|
165 | + } |
|
166 | + if (isset($row['captain_id'])) { |
|
167 | + $temp_array['captain_id'] = $row['captain_id']; |
|
168 | + } |
|
169 | + if (isset($row['captain_name'])) { |
|
170 | + $temp_array['captain_name'] = $row['captain_name']; |
|
171 | + } |
|
172 | + if (isset($row['race_id'])) { |
|
173 | + $temp_array['race_id'] = $row['race_id']; |
|
174 | + } |
|
175 | + if (isset($row['race_name'])) { |
|
176 | + $temp_array['race_name'] = $row['race_name']; |
|
177 | + } |
|
178 | + if (isset($row['ident'])) { |
|
179 | + $temp_array['ident'] = $row['ident']; |
|
180 | + } |
|
181 | + if (isset($row['arrival_port_name'])) { |
|
182 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
183 | + } |
|
184 | + if (isset($row['latitude'])) { |
|
185 | + $temp_array['latitude'] = $row['latitude']; |
|
186 | + } |
|
187 | + if (isset($row['longitude'])) { |
|
188 | + $temp_array['longitude'] = $row['longitude']; |
|
189 | + } |
|
190 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
191 | + $temp_array['distance'] = $row['distance']; |
|
192 | + } |
|
193 | + if (isset($row['format_source'])) { |
|
194 | + $temp_array['format_source'] = $row['format_source']; |
|
195 | + } |
|
158 | 196 | if (isset($row['heading'])) { |
159 | 197 | $temp_array['heading'] = $row['heading']; |
160 | 198 | $heading_direction = $this->parseDirection($row['heading']); |
161 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
199 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
200 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
201 | + } |
|
202 | + } |
|
203 | + if (isset($row['ground_speed'])) { |
|
204 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
162 | 205 | } |
163 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
164 | 206 | |
165 | 207 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
166 | 208 | { |
167 | 209 | $Image = new Image($this->db); |
168 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
169 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
210 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
211 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
212 | + } else { |
|
213 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
214 | + } |
|
170 | 215 | unset($Image); |
171 | 216 | if (count($image_array) > 0) { |
172 | 217 | $temp_array['image'] = $image_array[0]['image']; |
@@ -218,13 +263,21 @@ discard block |
||
218 | 263 | } |
219 | 264 | |
220 | 265 | $fromsource = NULL; |
221 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
222 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
223 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
266 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
267 | + $temp_array['source_name'] = $row['source_name']; |
|
268 | + } |
|
269 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
270 | + $temp_array['over_country'] = $row['over_country']; |
|
271 | + } |
|
272 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
273 | + $temp_array['distance'] = $row['distance']; |
|
274 | + } |
|
224 | 275 | $temp_array['query_number_rows'] = $num_rows; |
225 | 276 | $spotter_array[] = $temp_array; |
226 | 277 | } |
227 | - if ($num_rows == 0) return array(); |
|
278 | + if ($num_rows == 0) { |
|
279 | + return array(); |
|
280 | + } |
|
228 | 281 | $spotter_array[0]['query_number_rows'] = $num_rows; |
229 | 282 | return $spotter_array; |
230 | 283 | } |
@@ -250,8 +303,12 @@ discard block |
||
250 | 303 | { |
251 | 304 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
252 | 305 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
253 | - } else $limit_query = ""; |
|
254 | - } else $limit_query = ""; |
|
306 | + } else { |
|
307 | + $limit_query = ""; |
|
308 | + } |
|
309 | + } else { |
|
310 | + $limit_query = ""; |
|
311 | + } |
|
255 | 312 | if ($sort != "") |
256 | 313 | { |
257 | 314 | $search_orderby_array = $this->getOrderBy(); |
@@ -275,7 +332,9 @@ discard block |
||
275 | 332 | global $global_marine_query; |
276 | 333 | |
277 | 334 | date_default_timezone_set('UTC'); |
278 | - if ($id == '') return array(); |
|
335 | + if ($id == '') { |
|
336 | + return array(); |
|
337 | + } |
|
279 | 338 | $additional_query = "marine_output.fammarine_id = :id"; |
280 | 339 | $query_values = array(':id' => $id); |
281 | 340 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -719,8 +778,11 @@ discard block |
||
719 | 778 | $sth = $this->db->prepare($query); |
720 | 779 | $sth->execute($query_values); |
721 | 780 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
722 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
723 | - else return $result[0]['duration']; |
|
781 | + if (is_int($result[0]['duration'])) { |
|
782 | + return gmdate('H:i:s',$result[0]['duration']); |
|
783 | + } else { |
|
784 | + return $result[0]['duration']; |
|
785 | + } |
|
724 | 786 | } |
725 | 787 | |
726 | 788 | /** |
@@ -779,8 +841,11 @@ discard block |
||
779 | 841 | $query .= " ORDER BY marine_output.source_name ASC"; |
780 | 842 | |
781 | 843 | $sth = $this->db->prepare($query); |
782 | - if (!empty($query_values)) $sth->execute($query_values); |
|
783 | - else $sth->execute(); |
|
844 | + if (!empty($query_values)) { |
|
845 | + $sth->execute($query_values); |
|
846 | + } else { |
|
847 | + $sth->execute(); |
|
848 | + } |
|
784 | 849 | |
785 | 850 | $source_array = array(); |
786 | 851 | $temp_array = array(); |
@@ -835,8 +900,11 @@ discard block |
||
835 | 900 | $sth = $this->db->prepare($query); |
836 | 901 | $sth->execute(array(':mmsi' => $mmsi)); |
837 | 902 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
838 | - if (isset($result[0])) return $result[0]; |
|
839 | - else return array(); |
|
903 | + if (isset($result[0])) { |
|
904 | + return $result[0]; |
|
905 | + } else { |
|
906 | + return array(); |
|
907 | + } |
|
840 | 908 | } |
841 | 909 | |
842 | 910 | /** |
@@ -877,7 +945,9 @@ discard block |
||
877 | 945 | date_default_timezone_set($globalTimezone); |
878 | 946 | $datetime = new DateTime(); |
879 | 947 | $offset = $datetime->format('P'); |
880 | - } else $offset = '+00:00'; |
|
948 | + } else { |
|
949 | + $offset = '+00:00'; |
|
950 | + } |
|
881 | 951 | |
882 | 952 | if ($globalDBdriver == 'mysql') { |
883 | 953 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -1129,14 +1199,28 @@ discard block |
||
1129 | 1199 | $latitude = 0; |
1130 | 1200 | $longitude = 0; |
1131 | 1201 | } |
1132 | - if ($type_id == '') $type_id = NULL; |
|
1133 | - if ($status_id == '') $status_id = NULL; |
|
1134 | - if ($distance == '') $distance = NULL; |
|
1135 | - if ($race_rank == '') $race_rank = NULL; |
|
1136 | - if ($race_time == '') $race_time = NULL; |
|
1137 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1202 | + if ($type_id == '') { |
|
1203 | + $type_id = NULL; |
|
1204 | + } |
|
1205 | + if ($status_id == '') { |
|
1206 | + $status_id = NULL; |
|
1207 | + } |
|
1208 | + if ($distance == '') { |
|
1209 | + $distance = NULL; |
|
1210 | + } |
|
1211 | + if ($race_rank == '') { |
|
1212 | + $race_rank = NULL; |
|
1213 | + } |
|
1214 | + if ($race_time == '') { |
|
1215 | + $race_time = NULL; |
|
1216 | + } |
|
1217 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
1218 | + $heading = 0; |
|
1219 | + } |
|
1138 | 1220 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
1139 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1221 | + if ($arrival_date == '') { |
|
1222 | + $arrival_date = NULL; |
|
1223 | + } |
|
1140 | 1224 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
1141 | 1225 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
1142 | 1226 | |
@@ -1243,7 +1327,9 @@ discard block |
||
1243 | 1327 | global $globalDBdriver, $globalArchive; |
1244 | 1328 | //$filter_query = $this->getFilter($filters,true,true); |
1245 | 1329 | $Connection= new Connection($this->db); |
1246 | - if (!$Connection->tableExists('countries')) return array(); |
|
1330 | + if (!$Connection->tableExists('countries')) { |
|
1331 | + return array(); |
|
1332 | + } |
|
1247 | 1333 | require_once('class.SpotterLive.php'); |
1248 | 1334 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
1249 | 1335 | $MarineLive = new MarineLive($this->db); |
@@ -1287,7 +1373,9 @@ discard block |
||
1287 | 1373 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
1288 | 1374 | } |
1289 | 1375 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
1290 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1376 | + if ($limit) { |
|
1377 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1378 | + } |
|
1291 | 1379 | |
1292 | 1380 | $sth = $this->db->prepare($query); |
1293 | 1381 | $sth->execute(); |
@@ -1321,12 +1409,18 @@ discard block |
||
1321 | 1409 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
1322 | 1410 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1323 | 1411 | if ($olderthanmonths > 0) { |
1324 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1325 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1412 | + if ($globalDBdriver == 'mysql') { |
|
1413 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1414 | + } else { |
|
1415 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1416 | + } |
|
1326 | 1417 | } |
1327 | 1418 | if ($sincedate != '') { |
1328 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1329 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1419 | + if ($globalDBdriver == 'mysql') { |
|
1420 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1421 | + } else { |
|
1422 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1423 | + } |
|
1330 | 1424 | } |
1331 | 1425 | $query_values = array(); |
1332 | 1426 | if ($year != '') { |
@@ -1357,7 +1451,9 @@ discard block |
||
1357 | 1451 | } |
1358 | 1452 | } |
1359 | 1453 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1360 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1454 | + if ($limit) { |
|
1455 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1456 | + } |
|
1361 | 1457 | |
1362 | 1458 | $sth = $this->db->prepare($query); |
1363 | 1459 | $sth->execute($query_values); |
@@ -1392,7 +1488,9 @@ discard block |
||
1392 | 1488 | date_default_timezone_set($globalTimezone); |
1393 | 1489 | $datetime = new DateTime(); |
1394 | 1490 | $offset = $datetime->format('P'); |
1395 | - } else $offset = '+00:00'; |
|
1491 | + } else { |
|
1492 | + $offset = '+00:00'; |
|
1493 | + } |
|
1396 | 1494 | |
1397 | 1495 | if ($globalDBdriver == 'mysql') { |
1398 | 1496 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1442,7 +1540,9 @@ discard block |
||
1442 | 1540 | date_default_timezone_set($globalTimezone); |
1443 | 1541 | $datetime = new DateTime(); |
1444 | 1542 | $offset = $datetime->format('P'); |
1445 | - } else $offset = '+00:00'; |
|
1543 | + } else { |
|
1544 | + $offset = '+00:00'; |
|
1545 | + } |
|
1446 | 1546 | $filter_query = $this->getFilter($filters,true,true); |
1447 | 1547 | if ($globalDBdriver == 'mysql') { |
1448 | 1548 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1488,7 +1588,9 @@ discard block |
||
1488 | 1588 | date_default_timezone_set($globalTimezone); |
1489 | 1589 | $datetime = new DateTime(); |
1490 | 1590 | $offset = $datetime->format('P'); |
1491 | - } else $offset = '+00:00'; |
|
1591 | + } else { |
|
1592 | + $offset = '+00:00'; |
|
1593 | + } |
|
1492 | 1594 | $filter_query = $this->getFilter($filters,true,true); |
1493 | 1595 | if ($globalDBdriver == 'mysql') { |
1494 | 1596 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1536,7 +1638,9 @@ discard block |
||
1536 | 1638 | date_default_timezone_set($globalTimezone); |
1537 | 1639 | $datetime = new DateTime(); |
1538 | 1640 | $offset = $datetime->format('P'); |
1539 | - } else $offset = '+00:00'; |
|
1641 | + } else { |
|
1642 | + $offset = '+00:00'; |
|
1643 | + } |
|
1540 | 1644 | |
1541 | 1645 | if ($globalDBdriver == 'mysql') { |
1542 | 1646 | $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 |
@@ -1585,7 +1689,9 @@ discard block |
||
1585 | 1689 | date_default_timezone_set($globalTimezone); |
1586 | 1690 | $datetime = new DateTime(); |
1587 | 1691 | $offset = $datetime->format('P'); |
1588 | - } else $offset = '+00:00'; |
|
1692 | + } else { |
|
1693 | + $offset = '+00:00'; |
|
1694 | + } |
|
1589 | 1695 | $filter_query = $this->getFilter($filters,true,true); |
1590 | 1696 | if ($globalDBdriver == 'mysql') { |
1591 | 1697 | $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 |
@@ -1634,7 +1740,9 @@ discard block |
||
1634 | 1740 | date_default_timezone_set($globalTimezone); |
1635 | 1741 | $datetime = new DateTime(); |
1636 | 1742 | $offset = $datetime->format('P'); |
1637 | - } else $offset = '+00:00'; |
|
1743 | + } else { |
|
1744 | + $offset = '+00:00'; |
|
1745 | + } |
|
1638 | 1746 | |
1639 | 1747 | $orderby_sql = ''; |
1640 | 1748 | if ($orderby == "hour") |
@@ -1703,7 +1811,9 @@ discard block |
||
1703 | 1811 | date_default_timezone_set($globalTimezone); |
1704 | 1812 | $datetime = new DateTime($date); |
1705 | 1813 | $offset = $datetime->format('P'); |
1706 | - } else $offset = '+00:00'; |
|
1814 | + } else { |
|
1815 | + $offset = '+00:00'; |
|
1816 | + } |
|
1707 | 1817 | |
1708 | 1818 | if ($globalDBdriver == 'mysql') { |
1709 | 1819 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1751,7 +1861,9 @@ discard block |
||
1751 | 1861 | date_default_timezone_set($globalTimezone); |
1752 | 1862 | $datetime = new DateTime(); |
1753 | 1863 | $offset = $datetime->format('P'); |
1754 | - } else $offset = '+00:00'; |
|
1864 | + } else { |
|
1865 | + $offset = '+00:00'; |
|
1866 | + } |
|
1755 | 1867 | |
1756 | 1868 | if ($globalDBdriver == 'mysql') { |
1757 | 1869 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1816,8 +1928,11 @@ discard block |
||
1816 | 1928 | $query_values = array_merge($query_values,array(':month' => $month)); |
1817 | 1929 | } |
1818 | 1930 | } |
1819 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1820 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1931 | + if (empty($query_values)) { |
|
1932 | + $queryi .= $this->getFilter($filters); |
|
1933 | + } else { |
|
1934 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1935 | + } |
|
1821 | 1936 | |
1822 | 1937 | $sth = $this->db->prepare($queryi); |
1823 | 1938 | $sth->execute($query_values); |
@@ -1854,8 +1969,11 @@ discard block |
||
1854 | 1969 | $query_values = array_merge($query_values,array(':month' => $month)); |
1855 | 1970 | } |
1856 | 1971 | } |
1857 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1858 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1972 | + if (empty($query_values)) { |
|
1973 | + $queryi .= $this->getFilter($filters); |
|
1974 | + } else { |
|
1975 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1976 | + } |
|
1859 | 1977 | |
1860 | 1978 | $sth = $this->db->prepare($queryi); |
1861 | 1979 | $sth->execute($query_values); |
@@ -1877,7 +1995,9 @@ discard block |
||
1877 | 1995 | date_default_timezone_set($globalTimezone); |
1878 | 1996 | $datetime = new DateTime(); |
1879 | 1997 | $offset = $datetime->format('P'); |
1880 | - } else $offset = '+00:00'; |
|
1998 | + } else { |
|
1999 | + $offset = '+00:00'; |
|
2000 | + } |
|
1881 | 2001 | |
1882 | 2002 | if ($globalDBdriver == 'mysql') { |
1883 | 2003 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1981,7 +2101,9 @@ discard block |
||
1981 | 2101 | */ |
1982 | 2102 | public function parseDirection($direction = 0) |
1983 | 2103 | { |
1984 | - if ($direction == '') $direction = 0; |
|
2104 | + if ($direction == '') { |
|
2105 | + $direction = 0; |
|
2106 | + } |
|
1985 | 2107 | $direction_array = array(); |
1986 | 2108 | $temp_array = array(); |
1987 | 2109 | |
@@ -2070,7 +2192,9 @@ discard block |
||
2070 | 2192 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2071 | 2193 | |
2072 | 2194 | $Connection = new Connection($this->db); |
2073 | - if (!$Connection->tableExists('countries')) return ''; |
|
2195 | + if (!$Connection->tableExists('countries')) { |
|
2196 | + return ''; |
|
2197 | + } |
|
2074 | 2198 | |
2075 | 2199 | try { |
2076 | 2200 | /* |
@@ -2090,9 +2214,13 @@ discard block |
||
2090 | 2214 | $sth->closeCursor(); |
2091 | 2215 | if (count($row) > 0) { |
2092 | 2216 | return $row; |
2093 | - } else return ''; |
|
2217 | + } else { |
|
2218 | + return ''; |
|
2219 | + } |
|
2094 | 2220 | } catch (PDOException $e) { |
2095 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
2221 | + if (isset($globalDebug) && $globalDebug) { |
|
2222 | + echo 'Error : '.$e->getMessage()."\n"; |
|
2223 | + } |
|
2096 | 2224 | return ''; |
2097 | 2225 | } |
2098 | 2226 | |
@@ -2110,7 +2238,9 @@ discard block |
||
2110 | 2238 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
2111 | 2239 | |
2112 | 2240 | $Connection = new Connection($this->db); |
2113 | - if (!$Connection->tableExists('countries')) return ''; |
|
2241 | + if (!$Connection->tableExists('countries')) { |
|
2242 | + return ''; |
|
2243 | + } |
|
2114 | 2244 | |
2115 | 2245 | try { |
2116 | 2246 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2122,9 +2252,13 @@ discard block |
||
2122 | 2252 | $sth->closeCursor(); |
2123 | 2253 | if (count($row) > 0) { |
2124 | 2254 | return $row; |
2125 | - } else return ''; |
|
2255 | + } else { |
|
2256 | + return ''; |
|
2257 | + } |
|
2126 | 2258 | } catch (PDOException $e) { |
2127 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
2259 | + if (isset($globalDebug) && $globalDebug) { |
|
2260 | + echo 'Error : '.$e->getMessage()."\n"; |
|
2261 | + } |
|
2128 | 2262 | return ''; |
2129 | 2263 | } |
2130 | 2264 | |
@@ -2142,7 +2276,9 @@ discard block |
||
2142 | 2276 | { |
2143 | 2277 | global $globalBitlyAccessToken; |
2144 | 2278 | |
2145 | - if ($globalBitlyAccessToken == '') return $url; |
|
2279 | + if ($globalBitlyAccessToken == '') { |
|
2280 | + return $url; |
|
2281 | + } |
|
2146 | 2282 | |
2147 | 2283 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
2148 | 2284 | |
@@ -2218,7 +2354,9 @@ discard block |
||
2218 | 2354 | } |
2219 | 2355 | } |
2220 | 2356 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
2221 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2357 | + if ($limit) { |
|
2358 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2359 | + } |
|
2222 | 2360 | $sth = $this->db->prepare($query); |
2223 | 2361 | $sth->execute($query_values); |
2224 | 2362 | $marine_array = array(); |
@@ -2256,9 +2394,15 @@ discard block |
||
2256 | 2394 | foreach ($q_array as $q_item){ |
2257 | 2395 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
2258 | 2396 | $additional_query .= " AND ("; |
2259 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2260 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2261 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2397 | + if (is_int($q_item)) { |
|
2398 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2399 | + } |
|
2400 | + if (is_int($q_item)) { |
|
2401 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2402 | + } |
|
2403 | + if (is_int($q_item)) { |
|
2404 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2405 | + } |
|
2262 | 2406 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
2263 | 2407 | $additional_query .= ")"; |
2264 | 2408 | } |
@@ -2306,7 +2450,9 @@ discard block |
||
2306 | 2450 | date_default_timezone_set($globalTimezone); |
2307 | 2451 | $datetime = new DateTime(); |
2308 | 2452 | $offset = $datetime->format('P'); |
2309 | - } else $offset = '+00:00'; |
|
2453 | + } else { |
|
2454 | + $offset = '+00:00'; |
|
2455 | + } |
|
2310 | 2456 | if ($date_array[1] != "") |
2311 | 2457 | { |
2312 | 2458 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2333,8 +2479,12 @@ discard block |
||
2333 | 2479 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2334 | 2480 | { |
2335 | 2481 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2336 | - } else $limit_query = ""; |
|
2337 | - } else $limit_query = ""; |
|
2482 | + } else { |
|
2483 | + $limit_query = ""; |
|
2484 | + } |
|
2485 | + } else { |
|
2486 | + $limit_query = ""; |
|
2487 | + } |
|
2338 | 2488 | if ($sort != "") |
2339 | 2489 | { |
2340 | 2490 | $search_orderby_array = $this->getOrderBy(); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Get SQL query part for filter used |
17 | 17 | * @param Array $filter the filter |
18 | - * @return Array the SQL part |
|
18 | + * @return string the SQL part |
|
19 | 19 | */ |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -923,10 +923,6 @@ discard block |
||
923 | 923 | * |
924 | 924 | * @param String $fammarine_id the ID from flightaware |
925 | 925 | * @param String $ident the flight ident |
926 | - * @param String $aircraft_icao the aircraft type |
|
927 | - * @param String $departure_airport_icao the departure airport |
|
928 | - * @param String $arrival_airport_icao the arrival airport |
|
929 | - * @return String success or false |
|
930 | 926 | * |
931 | 927 | */ |
932 | 928 | 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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Gets all the spotter information based on the latest data entry |
|
100 | - * |
|
101 | - * @return Array the spotter information |
|
102 | - * |
|
103 | - */ |
|
99 | + * Gets all the spotter information based on the latest data entry |
|
100 | + * |
|
101 | + * @return Array the spotter information |
|
102 | + * |
|
103 | + */ |
|
104 | 104 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
105 | 105 | { |
106 | 106 | global $globalDBdriver, $globalLiveInterval; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | - * Gets Minimal Live Spotter data |
|
147 | - * |
|
148 | - * @return Array the spotter information |
|
149 | - * |
|
150 | - */ |
|
146 | + * Gets Minimal Live Spotter data |
|
147 | + * |
|
148 | + * @return Array the spotter information |
|
149 | + * |
|
150 | + */ |
|
151 | 151 | public function getMinLiveMarineData($filter = array()) |
152 | 152 | { |
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | - * Gets Minimal Live Spotter data since xx seconds |
|
181 | - * |
|
182 | - * @return Array the spotter information |
|
183 | - * |
|
184 | - */ |
|
180 | + * Gets Minimal Live Spotter data since xx seconds |
|
181 | + * |
|
182 | + * @return Array the spotter information |
|
183 | + * |
|
184 | + */ |
|
185 | 185 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Gets number of latest data entry |
|
265 | - * |
|
266 | - * @return String number of entry |
|
267 | - * |
|
268 | - */ |
|
264 | + * Gets number of latest data entry |
|
265 | + * |
|
266 | + * @return String number of entry |
|
267 | + * |
|
268 | + */ |
|
269 | 269 | public function getLiveMarineCount($filter = array()) |
270 | 270 | { |
271 | 271 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Gets all the spotter information based on the latest data entry and coord |
|
294 | - * |
|
295 | - * @return Array the spotter information |
|
296 | - * |
|
297 | - */ |
|
293 | + * Gets all the spotter information based on the latest data entry and coord |
|
294 | + * |
|
295 | + * @return Array the spotter information |
|
296 | + * |
|
297 | + */ |
|
298 | 298 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
299 | 299 | { |
300 | 300 | global $globalDBdriver, $globalLiveInterval; |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | - * Gets all the spotter information based on the latest data entry and coord |
|
322 | - * |
|
323 | - * @return Array the spotter information |
|
324 | - * |
|
325 | - */ |
|
321 | + * Gets all the spotter information based on the latest data entry and coord |
|
322 | + * |
|
323 | + * @return Array the spotter information |
|
324 | + * |
|
325 | + */ |
|
326 | 326 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
327 | 327 | { |
328 | 328 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
400 | 400 | { |
401 | 401 | $Marine = new Marine($this->db); |
@@ -408,75 +408,75 @@ discard block |
||
408 | 408 | if ($lng != '') |
409 | 409 | { |
410 | 410 | if (!is_numeric($lng)) |
411 | - { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ($radius != '') |
|
417 | - { |
|
418 | - if (!is_numeric($radius)) |
|
419 | - { |
|
420 | - return false; |
|
421 | - } |
|
422 | - } |
|
411 | + { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ($radius != '') |
|
417 | + { |
|
418 | + if (!is_numeric($radius)) |
|
419 | + { |
|
420 | + return false; |
|
421 | + } |
|
422 | + } |
|
423 | 423 | $additional_query = ''; |
424 | 424 | if ($interval != '') |
425 | - { |
|
426 | - if (!is_string($interval)) |
|
427 | - { |
|
428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
429 | - return false; |
|
430 | - } else { |
|
431 | - if ($interval == '1m') |
|
432 | - { |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
434 | - } else if ($interval == '15m'){ |
|
435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
436 | - } |
|
437 | - } |
|
438 | - } else { |
|
439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
440 | - } |
|
441 | - |
|
442 | - $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 |
|
425 | + { |
|
426 | + if (!is_string($interval)) |
|
427 | + { |
|
428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
429 | + return false; |
|
430 | + } else { |
|
431 | + if ($interval == '1m') |
|
432 | + { |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
434 | + } else if ($interval == '15m'){ |
|
435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
436 | + } |
|
437 | + } |
|
438 | + } else { |
|
439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
440 | + } |
|
441 | + |
|
442 | + $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 |
|
443 | 443 | WHERE marine_live.latitude <> '' |
444 | 444 | AND marine_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
450 | 450 | |
451 | - return $spotter_array; |
|
452 | - } |
|
451 | + return $spotter_array; |
|
452 | + } |
|
453 | 453 | |
454 | 454 | |
455 | - /** |
|
456 | - * Gets all the spotter information based on a particular callsign |
|
457 | - * |
|
458 | - * @return Array the spotter information |
|
459 | - * |
|
460 | - */ |
|
455 | + /** |
|
456 | + * Gets all the spotter information based on a particular callsign |
|
457 | + * |
|
458 | + * @return Array the spotter information |
|
459 | + * |
|
460 | + */ |
|
461 | 461 | public function getLastLiveMarineDataByIdent($ident) |
462 | 462 | { |
463 | 463 | $Marine = new Marine($this->db); |
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | 469 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Gets all the spotter information based on a particular callsign |
|
476 | - * |
|
477 | - * @return Array the spotter information |
|
478 | - * |
|
479 | - */ |
|
474 | + /** |
|
475 | + * Gets all the spotter information based on a particular callsign |
|
476 | + * |
|
477 | + * @return Array the spotter information |
|
478 | + * |
|
479 | + */ |
|
480 | 480 | public function getDateLiveMarineDataByIdent($ident,$date) |
481 | 481 | { |
482 | 482 | $Marine = new Marine($this->db); |
@@ -489,11 +489,11 @@ discard block |
||
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
492 | - * Gets all the spotter information based on a particular MMSI |
|
493 | - * |
|
494 | - * @return Array the spotter information |
|
495 | - * |
|
496 | - */ |
|
492 | + * Gets all the spotter information based on a particular MMSI |
|
493 | + * |
|
494 | + * @return Array the spotter information |
|
495 | + * |
|
496 | + */ |
|
497 | 497 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
498 | 498 | { |
499 | 499 | $Marine = new Marine($this->db); |
@@ -505,51 +505,51 @@ discard block |
||
505 | 505 | return $spotter_array; |
506 | 506 | } |
507 | 507 | |
508 | - /** |
|
509 | - * Gets last spotter information based on a particular callsign |
|
510 | - * |
|
511 | - * @return Array the spotter information |
|
512 | - * |
|
513 | - */ |
|
508 | + /** |
|
509 | + * Gets last spotter information based on a particular callsign |
|
510 | + * |
|
511 | + * @return Array the spotter information |
|
512 | + * |
|
513 | + */ |
|
514 | 514 | public function getLastLiveMarineDataById($id) |
515 | 515 | { |
516 | 516 | $Marine = new Marine($this->db); |
517 | 517 | date_default_timezone_set('UTC'); |
518 | 518 | |
519 | 519 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
520 | - $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'; |
|
520 | + $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'; |
|
521 | 521 | |
522 | 522 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
523 | 523 | |
524 | 524 | return $spotter_array; |
525 | 525 | } |
526 | 526 | |
527 | - /** |
|
528 | - * Gets last spotter information based on a particular callsign |
|
529 | - * |
|
530 | - * @return Array the spotter information |
|
531 | - * |
|
532 | - */ |
|
527 | + /** |
|
528 | + * Gets last spotter information based on a particular callsign |
|
529 | + * |
|
530 | + * @return Array the spotter information |
|
531 | + * |
|
532 | + */ |
|
533 | 533 | public function getDateLiveMarineDataById($id,$date) |
534 | 534 | { |
535 | 535 | $Marine = new Marine($this->db); |
536 | 536 | date_default_timezone_set('UTC'); |
537 | 537 | |
538 | 538 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
539 | - $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'; |
|
540 | - $date = date('c',$date); |
|
539 | + $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'; |
|
540 | + $date = date('c',$date); |
|
541 | 541 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
542 | 542 | |
543 | 543 | return $spotter_array; |
544 | 544 | } |
545 | 545 | |
546 | 546 | |
547 | - /** |
|
548 | - * Gets all the spotter information based on a particular id |
|
549 | - * |
|
550 | - * @return Array the spotter information |
|
551 | - * |
|
552 | - */ |
|
547 | + /** |
|
548 | + * Gets all the spotter information based on a particular id |
|
549 | + * |
|
550 | + * @return Array the spotter information |
|
551 | + * |
|
552 | + */ |
|
553 | 553 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
554 | 554 | { |
555 | 555 | global $globalDBdriver, $globalLiveInterval; |
@@ -577,18 +577,18 @@ discard block |
||
577 | 577 | return $spotter_array; |
578 | 578 | } |
579 | 579 | |
580 | - /** |
|
581 | - * Gets all the spotter information based on a particular ident |
|
582 | - * |
|
583 | - * @return Array the spotter information |
|
584 | - * |
|
585 | - */ |
|
580 | + /** |
|
581 | + * Gets all the spotter information based on a particular ident |
|
582 | + * |
|
583 | + * @return Array the spotter information |
|
584 | + * |
|
585 | + */ |
|
586 | 586 | public function getAllLiveMarineDataByIdent($ident) |
587 | 587 | { |
588 | 588 | date_default_timezone_set('UTC'); |
589 | 589 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
590 | 590 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
591 | - try { |
|
591 | + try { |
|
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(array(':ident' => $ident)); |
@@ -602,23 +602,23 @@ discard block |
||
602 | 602 | |
603 | 603 | |
604 | 604 | /** |
605 | - * Deletes all info in the table |
|
606 | - * |
|
607 | - * @return String success or false |
|
608 | - * |
|
609 | - */ |
|
605 | + * Deletes all info in the table |
|
606 | + * |
|
607 | + * @return String success or false |
|
608 | + * |
|
609 | + */ |
|
610 | 610 | public function deleteLiveMarineData() |
611 | 611 | { |
612 | 612 | global $globalDBdriver; |
613 | 613 | if ($globalDBdriver == 'mysql') { |
614 | 614 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
615 | 615 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
616 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
616 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
617 | 617 | } else { |
618 | 618 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
619 | 619 | } |
620 | 620 | |
621 | - try { |
|
621 | + try { |
|
622 | 622 | |
623 | 623 | $sth = $this->db->prepare($query); |
624 | 624 | $sth->execute(); |
@@ -630,18 +630,18 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
634 | - * |
|
635 | - * @return String success or false |
|
636 | - * |
|
637 | - */ |
|
633 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
634 | + * |
|
635 | + * @return String success or false |
|
636 | + * |
|
637 | + */ |
|
638 | 638 | public function deleteLiveMarineDataNotUpdated() |
639 | 639 | { |
640 | 640 | global $globalDBdriver, $globalDebug; |
641 | 641 | if ($globalDBdriver == 'mysql') { |
642 | 642 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
643 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
644 | - try { |
|
643 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
644 | + try { |
|
645 | 645 | |
646 | 646 | $sth = $this->db->prepare($query); |
647 | 647 | $sth->execute(); |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | return "error"; |
650 | 650 | } |
651 | 651 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
652 | - $i = 0; |
|
653 | - $j =0; |
|
652 | + $i = 0; |
|
653 | + $j =0; |
|
654 | 654 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | 655 | foreach($all as $row) |
656 | 656 | { |
@@ -658,20 +658,20 @@ discard block |
||
658 | 658 | $j++; |
659 | 659 | if ($j == 30) { |
660 | 660 | if ($globalDebug) echo "."; |
661 | - try { |
|
661 | + try { |
|
662 | 662 | |
663 | 663 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
664 | 664 | $sth->execute(); |
665 | 665 | } catch(PDOException $e) { |
666 | 666 | return "error"; |
667 | 667 | } |
668 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
669 | - $j = 0; |
|
668 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
669 | + $j = 0; |
|
670 | 670 | } |
671 | 671 | $query_delete .= "'".$row['fammarine_id']."',"; |
672 | 672 | } |
673 | 673 | if ($i > 0) { |
674 | - try { |
|
674 | + try { |
|
675 | 675 | |
676 | 676 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
677 | 677 | $sth->execute(); |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | return "success"; |
683 | 683 | } elseif ($globalDBdriver == 'pgsql') { |
684 | 684 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
685 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
686 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
687 | - try { |
|
685 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
686 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
687 | + try { |
|
688 | 688 | |
689 | 689 | $sth = $this->db->prepare($query); |
690 | 690 | $sth->execute(); |
@@ -728,17 +728,17 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * Deletes all info in the table for an ident |
|
732 | - * |
|
733 | - * @return String success or false |
|
734 | - * |
|
735 | - */ |
|
731 | + * Deletes all info in the table for an ident |
|
732 | + * |
|
733 | + * @return String success or false |
|
734 | + * |
|
735 | + */ |
|
736 | 736 | public function deleteLiveMarineDataByIdent($ident) |
737 | 737 | { |
738 | 738 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
739 | 739 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
740 | 740 | |
741 | - try { |
|
741 | + try { |
|
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(array(':ident' => $ident)); |
@@ -750,17 +750,17 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
753 | - * Deletes all info in the table for an id |
|
754 | - * |
|
755 | - * @return String success or false |
|
756 | - * |
|
757 | - */ |
|
753 | + * Deletes all info in the table for an id |
|
754 | + * |
|
755 | + * @return String success or false |
|
756 | + * |
|
757 | + */ |
|
758 | 758 | public function deleteLiveMarineDataById($id) |
759 | 759 | { |
760 | 760 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
761 | 761 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
762 | 762 | |
763 | - try { |
|
763 | + try { |
|
764 | 764 | |
765 | 765 | $sth = $this->db->prepare($query); |
766 | 766 | $sth->execute(array(':id' => $id)); |
@@ -773,11 +773,11 @@ discard block |
||
773 | 773 | |
774 | 774 | |
775 | 775 | /** |
776 | - * Gets the marine races |
|
777 | - * |
|
778 | - * @return Array all races |
|
779 | - * |
|
780 | - */ |
|
776 | + * Gets the marine races |
|
777 | + * |
|
778 | + * @return Array all races |
|
779 | + * |
|
780 | + */ |
|
781 | 781 | public function getAllRaces() |
782 | 782 | { |
783 | 783 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -787,11 +787,11 @@ discard block |
||
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
790 | - * Gets the aircraft ident within the last hour |
|
791 | - * |
|
792 | - * @return String the ident |
|
793 | - * |
|
794 | - */ |
|
790 | + * Gets the aircraft ident within the last hour |
|
791 | + * |
|
792 | + * @return String the ident |
|
793 | + * |
|
794 | + */ |
|
795 | 795 | public function getIdentFromLastHour($ident) |
796 | 796 | { |
797 | 797 | global $globalDBdriver, $globalTimezone; |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | $ident_result = $row['ident']; |
818 | 818 | } |
819 | 819 | return $ident_result; |
820 | - } |
|
820 | + } |
|
821 | 821 | |
822 | 822 | /** |
823 | - * Check recent aircraft |
|
824 | - * |
|
825 | - * @return String the ident |
|
826 | - * |
|
827 | - */ |
|
823 | + * Check recent aircraft |
|
824 | + * |
|
825 | + * @return String the ident |
|
826 | + * |
|
827 | + */ |
|
828 | 828 | public function checkIdentRecent($ident) |
829 | 829 | { |
830 | 830 | global $globalDBdriver, $globalTimezone; |
@@ -850,14 +850,14 @@ discard block |
||
850 | 850 | $ident_result = $row['fammarine_id']; |
851 | 851 | } |
852 | 852 | return $ident_result; |
853 | - } |
|
853 | + } |
|
854 | 854 | |
855 | 855 | /** |
856 | - * Check recent aircraft by id |
|
857 | - * |
|
858 | - * @return String the ident |
|
859 | - * |
|
860 | - */ |
|
856 | + * Check recent aircraft by id |
|
857 | + * |
|
858 | + * @return String the ident |
|
859 | + * |
|
860 | + */ |
|
861 | 861 | public function checkIdRecent($id) |
862 | 862 | { |
863 | 863 | global $globalDBdriver, $globalTimezone; |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | $ident_result = $row['fammarine_id']; |
884 | 884 | } |
885 | 885 | return $ident_result; |
886 | - } |
|
886 | + } |
|
887 | 887 | |
888 | 888 | /** |
889 | - * Check recent aircraft by mmsi |
|
890 | - * |
|
891 | - * @return String the ident |
|
892 | - * |
|
893 | - */ |
|
889 | + * Check recent aircraft by mmsi |
|
890 | + * |
|
891 | + * @return String the ident |
|
892 | + * |
|
893 | + */ |
|
894 | 894 | public function checkMMSIRecent($mmsi) |
895 | 895 | { |
896 | 896 | global $globalDBdriver, $globalTimezone; |
@@ -916,19 +916,19 @@ discard block |
||
916 | 916 | $ident_result = $row['fammarine_id']; |
917 | 917 | } |
918 | 918 | return $ident_result; |
919 | - } |
|
919 | + } |
|
920 | 920 | |
921 | 921 | /** |
922 | - * Adds a new spotter data |
|
923 | - * |
|
924 | - * @param String $fammarine_id the ID from flightaware |
|
925 | - * @param String $ident the flight ident |
|
926 | - * @param String $aircraft_icao the aircraft type |
|
927 | - * @param String $departure_airport_icao the departure airport |
|
928 | - * @param String $arrival_airport_icao the arrival airport |
|
929 | - * @return String success or false |
|
930 | - * |
|
931 | - */ |
|
922 | + * Adds a new spotter data |
|
923 | + * |
|
924 | + * @param String $fammarine_id the ID from flightaware |
|
925 | + * @param String $ident the flight ident |
|
926 | + * @param String $aircraft_icao the aircraft type |
|
927 | + * @param String $departure_airport_icao the departure airport |
|
928 | + * @param String $arrival_airport_icao the arrival airport |
|
929 | + * @return String success or false |
|
930 | + * |
|
931 | + */ |
|
932 | 932 | 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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1010,10 +1010,10 @@ discard block |
||
1010 | 1010 | if ($statusid == '') $statusid = NULL; |
1011 | 1011 | if ($distance == '') $distance = NULL; |
1012 | 1012 | |
1013 | - //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1015 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1016 | - $query = ''; |
|
1013 | + //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1014 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1015 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1016 | + $query = ''; |
|
1017 | 1017 | if ($globalArchive) { |
1018 | 1018 | if ($globalDebug) echo '-- Delete previous data -- '; |
1019 | 1019 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $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 | + $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"; |
|
40 | 40 | } else { |
41 | - $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 | + $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"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
82 | 82 | } |
83 | 83 | } |
84 | - $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"; |
|
84 | + $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"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
87 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
88 | 88 | } |
89 | 89 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
90 | 90 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
91 | 91 | if ($filter_query_where != '') { |
92 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
92 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
93 | 93 | } |
94 | 94 | $filter_query = $filter_query_join.$filter_query_where; |
95 | 95 | return $filter_query; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | if ($limit != '') |
113 | 113 | { |
114 | 114 | $limit_array = explode(',', $limit); |
115 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
116 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
115 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
116 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
117 | 117 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
118 | 118 | { |
119 | 119 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 129 | } |
130 | 130 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
131 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
132 | 132 | |
133 | 133 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
134 | 134 | if ($globalDBdriver == 'mysql') { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | $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; |
139 | 139 | } |
140 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
140 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
141 | 141 | |
142 | 142 | return $spotter_array; |
143 | 143 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | global $globalDBdriver, $globalLiveInterval; |
154 | 154 | date_default_timezone_set('UTC'); |
155 | 155 | |
156 | - $filter_query = $this->getFilter($filter,true,true); |
|
156 | + $filter_query = $this->getFilter($filter, true, true); |
|
157 | 157 | |
158 | 158 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
159 | 159 | if ($globalDBdriver == 'mysql') { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | try { |
168 | 168 | $sth = $this->db->prepare($query); |
169 | 169 | $sth->execute(); |
170 | - } catch(PDOException $e) { |
|
170 | + } catch (PDOException $e) { |
|
171 | 171 | echo $e->getMessage(); |
172 | 172 | die; |
173 | 173 | } |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * @return Array the spotter information |
183 | 183 | * |
184 | 184 | */ |
185 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
|
185 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '') |
|
186 | 186 | { |
187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
188 | 188 | date_default_timezone_set('UTC'); |
189 | 189 | $usecoord = false; |
190 | 190 | if (is_array($coord) && !empty($coord)) { |
191 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
192 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
193 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
194 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
191 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
192 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
193 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
194 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
195 | 195 | $usecoord = true; |
196 | 196 | } |
197 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
198 | - $filter_query = $this->getFilter($filter,true,true); |
|
197 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
198 | + $filter_query = $this->getFilter($filter, true, true); |
|
199 | 199 | |
200 | 200 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
201 | 201 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
202 | 202 | if ($globalDBdriver == 'mysql') { |
203 | 203 | if (isset($globalArchive) && $globalArchive === TRUE) { |
204 | - $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
204 | + $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
205 | 205 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
206 | 206 | if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
207 | 207 | if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ORDER BY fammarine_id, date"; |
216 | 216 | if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
217 | 217 | } else { |
218 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
218 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
|
219 | 219 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
220 | 220 | if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
221 | 221 | if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | } else { |
227 | 227 | if (isset($globalArchive) && $globalArchive === TRUE) { |
228 | - $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
228 | + $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
|
229 | 229 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
230 | 230 | if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
231 | 231 | if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | try { |
253 | 253 | $sth = $this->db->prepare($query); |
254 | 254 | $sth->execute($query_values); |
255 | - } catch(PDOException $e) { |
|
255 | + } catch (PDOException $e) { |
|
256 | 256 | echo $e->getMessage(); |
257 | 257 | die; |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function getLiveMarineCount($filter = array()) |
270 | 270 | { |
271 | 271 | global $globalDBdriver, $globalLiveInterval; |
272 | - $filter_query = $this->getFilter($filter,true,true); |
|
272 | + $filter_query = $this->getFilter($filter, true, true); |
|
273 | 273 | |
274 | 274 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
275 | 275 | if ($globalDBdriver == 'mysql') { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | try { |
281 | 281 | $sth = $this->db->prepare($query); |
282 | 282 | $sth->execute(); |
283 | - } catch(PDOException $e) { |
|
283 | + } catch (PDOException $e) { |
|
284 | 284 | echo $e->getMessage(); |
285 | 285 | die; |
286 | 286 | } |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | $filter_query = $this->getFilter($filter); |
304 | 304 | |
305 | 305 | if (is_array($coord)) { |
306 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
307 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
308 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
309 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
306 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
307 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
308 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
309 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
310 | 310 | } else return array(); |
311 | 311 | if ($globalDBdriver == 'mysql') { |
312 | 312 | $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 ORDER BY date DESC'.$filter_query; |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
329 | 329 | $Marine = new Marine($this->db); |
330 | 330 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
331 | - $filter_query = $this->getFilter($filter,true,true); |
|
331 | + $filter_query = $this->getFilter($filter, true, true); |
|
332 | 332 | |
333 | 333 | if (is_array($coord)) { |
334 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
335 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
336 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
337 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
334 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
335 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
336 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
337 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
338 | 338 | } else return array(); |
339 | 339 | /* |
340 | 340 | if ($globalDBdriver == 'mysql') { |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | */ |
350 | 350 | if ($globalDBdriver == 'mysql') { |
351 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
352 | - $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, marine_live.captain_name |
|
352 | + $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, marine_live.captain_name |
|
353 | 353 | FROM marine_live |
354 | 354 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
355 | 355 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
356 | 356 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY date DESC'; |
357 | 357 | } else { |
358 | - $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, marine_live.captain_name |
|
358 | + $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, marine_live.captain_name |
|
359 | 359 | FROM marine_live |
360 | 360 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
361 | 361 | FROM marine_live l |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | } |
368 | 368 | } else { |
369 | 369 | if (isset($globalArchive) && $globalArchive === TRUE) { |
370 | - $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, marine_live.captain_name |
|
370 | + $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, marine_live.captain_name |
|
371 | 371 | FROM marine_live |
372 | 372 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
373 | 373 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
374 | 374 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
375 | 375 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY date DESC"; |
376 | 376 | } else { |
377 | - $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, marine_live.captain_name |
|
377 | + $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, marine_live.captain_name |
|
378 | 378 | FROM marine_live |
379 | 379 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
380 | 380 | FROM marine_live l |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($interval == '1m') |
432 | 432 | { |
433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
434 | - } else if ($interval == '15m'){ |
|
434 | + } else if ($interval == '15m') { |
|
435 | 435 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
436 | 436 | } |
437 | 437 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
440 | 440 | } |
441 | 441 | |
442 | - $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 |
|
442 | + $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 |
|
443 | 443 | WHERE marine_live.latitude <> '' |
444 | 444 | AND marine_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
469 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
@@ -477,14 +477,14 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
480 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
481 | 481 | { |
482 | 482 | $Marine = new Marine($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
485 | 485 | $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'; |
486 | - $date = date('c',$date); |
|
487 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
486 | + $date = date('c', $date); |
|
487 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
488 | 488 | return $spotter_array; |
489 | 489 | } |
490 | 490 | |
@@ -494,14 +494,14 @@ discard block |
||
494 | 494 | * @return Array the spotter information |
495 | 495 | * |
496 | 496 | */ |
497 | - public function getDateLiveMarineDataByMMSI($mmsi,$date) |
|
497 | + public function getDateLiveMarineDataByMMSI($mmsi, $date) |
|
498 | 498 | { |
499 | 499 | $Marine = new Marine($this->db); |
500 | 500 | date_default_timezone_set('UTC'); |
501 | 501 | $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
502 | 502 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi 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'; |
503 | - $date = date('c',$date); |
|
504 | - $spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date)); |
|
503 | + $date = date('c', $date); |
|
504 | + $spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date)); |
|
505 | 505 | return $spotter_array; |
506 | 506 | } |
507 | 507 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | date_default_timezone_set('UTC'); |
518 | 518 | |
519 | 519 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
520 | - $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'; |
|
520 | + $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'; |
|
521 | 521 | |
522 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
522 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
523 | 523 | |
524 | 524 | return $spotter_array; |
525 | 525 | } |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | * @return Array the spotter information |
531 | 531 | * |
532 | 532 | */ |
533 | - public function getDateLiveMarineDataById($id,$date) |
|
533 | + public function getDateLiveMarineDataById($id, $date) |
|
534 | 534 | { |
535 | 535 | $Marine = new Marine($this->db); |
536 | 536 | date_default_timezone_set('UTC'); |
537 | 537 | |
538 | 538 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
539 | - $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'; |
|
540 | - $date = date('c',$date); |
|
541 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
539 | + $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'; |
|
540 | + $date = date('c', $date); |
|
541 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
542 | 542 | |
543 | 543 | return $spotter_array; |
544 | 544 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @return Array the spotter information |
551 | 551 | * |
552 | 552 | */ |
553 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
553 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
554 | 554 | { |
555 | 555 | global $globalDBdriver, $globalLiveInterval; |
556 | 556 | date_default_timezone_set('UTC'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | try { |
570 | 570 | $sth = $this->db->prepare($query); |
571 | 571 | $sth->execute(array(':id' => $id)); |
572 | - } catch(PDOException $e) { |
|
572 | + } catch (PDOException $e) { |
|
573 | 573 | echo $e->getMessage(); |
574 | 574 | die; |
575 | 575 | } |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | { |
588 | 588 | date_default_timezone_set('UTC'); |
589 | 589 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
590 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
590 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
591 | 591 | try { |
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(array(':ident' => $ident)); |
595 | - } catch(PDOException $e) { |
|
595 | + } catch (PDOException $e) { |
|
596 | 596 | echo $e->getMessage(); |
597 | 597 | die; |
598 | 598 | } |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | $sth = $this->db->prepare($query); |
624 | 624 | $sth->execute(); |
625 | - } catch(PDOException $e) { |
|
625 | + } catch (PDOException $e) { |
|
626 | 626 | return "error"; |
627 | 627 | } |
628 | 628 | |
@@ -645,14 +645,14 @@ discard block |
||
645 | 645 | |
646 | 646 | $sth = $this->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error"; |
650 | 650 | } |
651 | 651 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
652 | 652 | $i = 0; |
653 | - $j =0; |
|
653 | + $j = 0; |
|
654 | 654 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
655 | - foreach($all as $row) |
|
655 | + foreach ($all as $row) |
|
656 | 656 | { |
657 | 657 | $i++; |
658 | 658 | $j++; |
@@ -660,9 +660,9 @@ discard block |
||
660 | 660 | if ($globalDebug) echo "."; |
661 | 661 | try { |
662 | 662 | |
663 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
663 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
664 | 664 | $sth->execute(); |
665 | - } catch(PDOException $e) { |
|
665 | + } catch (PDOException $e) { |
|
666 | 666 | return "error"; |
667 | 667 | } |
668 | 668 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | if ($i > 0) { |
674 | 674 | try { |
675 | 675 | |
676 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
676 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error"; |
680 | 680 | } |
681 | 681 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | $sth = $this->db->prepare($query); |
690 | 690 | $sth->execute(); |
691 | - } catch(PDOException $e) { |
|
691 | + } catch (PDOException $e) { |
|
692 | 692 | return "error"; |
693 | 693 | } |
694 | 694 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | public function deleteLiveMarineDataByIdent($ident) |
737 | 737 | { |
738 | 738 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
739 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
739 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
740 | 740 | |
741 | 741 | try { |
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(array(':ident' => $ident)); |
745 | - } catch(PDOException $e) { |
|
745 | + } catch (PDOException $e) { |
|
746 | 746 | return "error"; |
747 | 747 | } |
748 | 748 | |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | public function deleteLiveMarineDataById($id) |
759 | 759 | { |
760 | 760 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
761 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
761 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
762 | 762 | |
763 | 763 | try { |
764 | 764 | |
765 | 765 | $sth = $this->db->prepare($query); |
766 | 766 | $sth->execute(array(':id' => $id)); |
767 | - } catch(PDOException $e) { |
|
767 | + } catch (PDOException $e) { |
|
768 | 768 | return "error"; |
769 | 769 | } |
770 | 770 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function getAllRaces() |
782 | 782 | { |
783 | - $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
783 | + $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
|
784 | 784 | $sth = $this->db->prepare($query); |
785 | 785 | $sth->execute(); |
786 | 786 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -796,13 +796,13 @@ discard block |
||
796 | 796 | { |
797 | 797 | global $globalDBdriver, $globalTimezone; |
798 | 798 | if ($globalDBdriver == 'mysql') { |
799 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
799 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
800 | 800 | WHERE marine_live.ident = :ident |
801 | 801 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
802 | 802 | AND marine_live.date < UTC_TIMESTAMP()'; |
803 | 803 | $query_data = array(':ident' => $ident); |
804 | 804 | } else { |
805 | - $query = "SELECT marine_live.ident FROM marine_live |
|
805 | + $query = "SELECT marine_live.ident FROM marine_live |
|
806 | 806 | WHERE marine_live.ident = :ident |
807 | 807 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
808 | 808 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | |
812 | 812 | $sth = $this->db->prepare($query); |
813 | 813 | $sth->execute($query_data); |
814 | - $ident_result=''; |
|
815 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | + $ident_result = ''; |
|
815 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
816 | 816 | { |
817 | 817 | $ident_result = $row['ident']; |
818 | 818 | } |
@@ -829,13 +829,13 @@ discard block |
||
829 | 829 | { |
830 | 830 | global $globalDBdriver, $globalTimezone; |
831 | 831 | if ($globalDBdriver == 'mysql') { |
832 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
832 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
833 | 833 | WHERE marine_live.ident = :ident |
834 | 834 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
835 | 835 | // AND marine_live.date < UTC_TIMESTAMP()"; |
836 | 836 | $query_data = array(':ident' => $ident); |
837 | 837 | } else { |
838 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
838 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
839 | 839 | WHERE marine_live.ident = :ident |
840 | 840 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
841 | 841 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | |
845 | 845 | $sth = $this->db->prepare($query); |
846 | 846 | $sth->execute($query_data); |
847 | - $ident_result=''; |
|
848 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
847 | + $ident_result = ''; |
|
848 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
849 | 849 | { |
850 | 850 | $ident_result = $row['fammarine_id']; |
851 | 851 | } |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | { |
863 | 863 | global $globalDBdriver, $globalTimezone; |
864 | 864 | if ($globalDBdriver == 'mysql') { |
865 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
865 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
866 | 866 | WHERE marine_live.fammarine_id = :id |
867 | 867 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
868 | 868 | // AND marine_live.date < UTC_TIMESTAMP()"; |
869 | 869 | $query_data = array(':id' => $id); |
870 | 870 | } else { |
871 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
871 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
872 | 872 | WHERE marine_live.fammarine_id = :id |
873 | 873 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
874 | 874 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | |
878 | 878 | $sth = $this->db->prepare($query); |
879 | 879 | $sth->execute($query_data); |
880 | - $ident_result=''; |
|
881 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | + $ident_result = ''; |
|
881 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
882 | 882 | { |
883 | 883 | $ident_result = $row['fammarine_id']; |
884 | 884 | } |
@@ -895,13 +895,13 @@ discard block |
||
895 | 895 | { |
896 | 896 | global $globalDBdriver, $globalTimezone; |
897 | 897 | if ($globalDBdriver == 'mysql') { |
898 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
898 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
899 | 899 | WHERE marine_live.mmsi = :mmsi |
900 | 900 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
901 | 901 | // AND marine_live.date < UTC_TIMESTAMP()"; |
902 | 902 | $query_data = array(':mmsi' => $mmsi); |
903 | 903 | } else { |
904 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
904 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
905 | 905 | WHERE marine_live.mmsi = :mmsi |
906 | 906 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
907 | 907 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | |
911 | 911 | $sth = $this->db->prepare($query); |
912 | 912 | $sth->execute($query_data); |
913 | - $ident_result=''; |
|
914 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | + $ident_result = ''; |
|
914 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
915 | 915 | { |
916 | 916 | $ident_result = $row['fammarine_id']; |
917 | 917 | } |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | * @return String success or false |
930 | 930 | * |
931 | 931 | */ |
932 | - 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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
932 | + 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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
|
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
935 | 935 | $Common = new Common(); |
@@ -981,37 +981,37 @@ discard block |
||
981 | 981 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
982 | 982 | |
983 | 983 | |
984 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
985 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
986 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
987 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
988 | - $distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
989 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
990 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
991 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
992 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
993 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
994 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
995 | - $typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
996 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
997 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
998 | - $statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
999 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1000 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1001 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1002 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1003 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1004 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1005 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1006 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
1007 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
1008 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
984 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
985 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
986 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
987 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
988 | + $distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
989 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
990 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
991 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
992 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
993 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
994 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
995 | + $typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
996 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
997 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
998 | + $statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
999 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1000 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1001 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
1002 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
1003 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
1004 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
1005 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
1006 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
1007 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
1008 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1009 | 1009 | if ($typeid == '') $typeid = NULL; |
1010 | 1010 | if ($statusid == '') $statusid = NULL; |
1011 | 1011 | if ($distance == '') $distance = NULL; |
1012 | 1012 | |
1013 | 1013 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1014 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1015 | 1015 | if ($arrival_date == '') $arrival_date = NULL; |
1016 | 1016 | $query = ''; |
1017 | 1017 | if ($globalArchive) { |
@@ -1020,19 +1020,19 @@ discard block |
||
1020 | 1020 | } |
1021 | 1021 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
1022 | 1022 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
1023 | - $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,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_time' => $race_time,':race_rank' => $race_rank); |
|
1023 | + $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, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_time' => $race_time, ':race_rank' => $race_rank); |
|
1024 | 1024 | try { |
1025 | 1025 | $sth = $this->db->prepare($query); |
1026 | 1026 | $sth->execute($query_values); |
1027 | 1027 | $sth->closeCursor(); |
1028 | - } catch(PDOException $e) { |
|
1028 | + } catch (PDOException $e) { |
|
1029 | 1029 | return "error : ".$e->getMessage(); |
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1033 | 1033 | if ($globalDebug) echo '(Add to Marine archive : '; |
1034 | 1034 | $MarineArchive = new MarineArchive($this->db); |
1035 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time); |
|
1035 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name, $distance, $race_rank, $race_time); |
|
1036 | 1036 | if ($globalDebug) echo $result.')'; |
1037 | 1037 | } |
1038 | 1038 | return "success"; |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | public function getOrderBy() |
1042 | 1042 | { |
1043 | - $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")); |
|
1043 | + $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")); |
|
1044 | 1044 | return $orderby; |
1045 | 1045 | } |
1046 | 1046 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -86,8 +90,11 @@ discard block |
||
86 | 90 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
87 | 91 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
88 | 92 | } |
89 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
90 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
93 | + if ($filter_query_where == '' && $where) { |
|
94 | + $filter_query_where = ' WHERE'; |
|
95 | + } elseif ($filter_query_where != '' && $and) { |
|
96 | + $filter_query_where .= ' AND'; |
|
97 | + } |
|
91 | 98 | if ($filter_query_where != '') { |
92 | 99 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
93 | 100 | } |
@@ -128,9 +135,13 @@ discard block |
||
128 | 135 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
129 | 136 | } |
130 | 137 | } |
131 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
138 | + if ($orderby_query == '') { |
|
139 | + $orderby_query= ' ORDER BY date DESC'; |
|
140 | + } |
|
132 | 141 | |
133 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
142 | + if (!isset($globalLiveInterval)) { |
|
143 | + $globalLiveInterval = '200'; |
|
144 | + } |
|
134 | 145 | if ($globalDBdriver == 'mysql') { |
135 | 146 | //$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"; |
136 | 147 | $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; |
@@ -155,7 +166,9 @@ discard block |
||
155 | 166 | |
156 | 167 | $filter_query = $this->getFilter($filter,true,true); |
157 | 168 | |
158 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
169 | + if (!isset($globalLiveInterval)) { |
|
170 | + $globalLiveInterval = '200'; |
|
171 | + } |
|
159 | 172 | if ($globalDBdriver == 'mysql') { |
160 | 173 | $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, marine_live.captain_name |
161 | 174 | 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"; |
@@ -197,58 +210,96 @@ discard block |
||
197 | 210 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
198 | 211 | $filter_query = $this->getFilter($filter,true,true); |
199 | 212 | |
200 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
201 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
213 | + if (!isset($globalLiveInterval)) { |
|
214 | + $globalLiveInterval = '200'; |
|
215 | + } |
|
216 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
217 | + $globalMap3DMarinesLimit = '300'; |
|
218 | + } |
|
202 | 219 | if ($globalDBdriver == 'mysql') { |
203 | 220 | if (isset($globalArchive) && $globalArchive === TRUE) { |
204 | 221 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
205 | 222 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
206 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
207 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
223 | + if ($usecoord) { |
|
224 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
225 | + } |
|
226 | + if ($id != '') { |
|
227 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
228 | + } |
|
208 | 229 | $query .= "UNION |
209 | 230 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
210 | 231 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
211 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
212 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
232 | + if ($usecoord) { |
|
233 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
234 | + } |
|
235 | + if ($id != '') { |
|
236 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
237 | + } |
|
213 | 238 | $query .= ") AS marine |
214 | 239 | WHERE latitude <> '0' AND longitude <> '0' |
215 | 240 | ORDER BY fammarine_id, date"; |
216 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
241 | + if ($limit) { |
|
242 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
243 | + } |
|
217 | 244 | } else { |
218 | 245 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
219 | 246 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
220 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
221 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
247 | + if ($usecoord) { |
|
248 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
249 | + } |
|
250 | + if ($id != '') { |
|
251 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
252 | + } |
|
222 | 253 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
223 | 254 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } |
226 | 259 | } else { |
227 | 260 | if (isset($globalArchive) && $globalArchive === TRUE) { |
228 | 261 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name |
229 | 262 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
230 | - if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
231 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
263 | + if ($usecoord) { |
|
264 | + $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
265 | + } |
|
266 | + if ($id != '') { |
|
267 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
268 | + } |
|
232 | 269 | $query .= "UNION |
233 | 270 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
234 | 271 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
235 | - if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
236 | - if ($id != '') $query .= " OR marine_live.fammarine_id = :id"; |
|
272 | + if ($usecoord) { |
|
273 | + $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
274 | + } |
|
275 | + if ($id != '') { |
|
276 | + $query .= " OR marine_live.fammarine_id = :id"; |
|
277 | + } |
|
237 | 278 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
238 | 279 | $query .= "ORDER BY fammarine_id, date"; |
239 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
280 | + if ($limit) { |
|
281 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
282 | + } |
|
240 | 283 | } else { |
241 | 284 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name |
242 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
243 | - if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
244 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
286 | + if ($usecoord) { |
|
287 | + $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
288 | + } |
|
289 | + if ($id != '') { |
|
290 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
291 | + } |
|
245 | 292 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
246 | 293 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
247 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
296 | + } |
|
248 | 297 | } |
249 | 298 | } |
250 | 299 | $query_values = array(); |
251 | - if ($id != '') $query_values = array(':id' => $id); |
|
300 | + if ($id != '') { |
|
301 | + $query_values = array(':id' => $id); |
|
302 | + } |
|
252 | 303 | try { |
253 | 304 | $sth = $this->db->prepare($query); |
254 | 305 | $sth->execute($query_values); |
@@ -271,7 +322,9 @@ discard block |
||
271 | 322 | global $globalDBdriver, $globalLiveInterval; |
272 | 323 | $filter_query = $this->getFilter($filter,true,true); |
273 | 324 | |
274 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
325 | + if (!isset($globalLiveInterval)) { |
|
326 | + $globalLiveInterval = '200'; |
|
327 | + } |
|
275 | 328 | if ($globalDBdriver == 'mysql') { |
276 | 329 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
277 | 330 | } else { |
@@ -299,7 +352,9 @@ discard block |
||
299 | 352 | { |
300 | 353 | global $globalDBdriver, $globalLiveInterval; |
301 | 354 | $Marine = new Marine($this->db); |
302 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
303 | 358 | $filter_query = $this->getFilter($filter); |
304 | 359 | |
305 | 360 | if (is_array($coord)) { |
@@ -307,7 +362,9 @@ discard block |
||
307 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
308 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
309 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
310 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
311 | 368 | if ($globalDBdriver == 'mysql') { |
312 | 369 | $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 ORDER BY date DESC'.$filter_query; |
313 | 370 | } else { |
@@ -327,7 +384,9 @@ discard block |
||
327 | 384 | { |
328 | 385 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
329 | 386 | $Marine = new Marine($this->db); |
330 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
387 | + if (!isset($globalLiveInterval)) { |
|
388 | + $globalLiveInterval = '200'; |
|
389 | + } |
|
331 | 390 | $filter_query = $this->getFilter($filter,true,true); |
332 | 391 | |
333 | 392 | if (is_array($coord)) { |
@@ -335,7 +394,9 @@ discard block |
||
335 | 394 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
336 | 395 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
337 | 396 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
338 | - } else return array(); |
|
397 | + } else { |
|
398 | + return array(); |
|
399 | + } |
|
339 | 400 | /* |
340 | 401 | if ($globalDBdriver == 'mysql') { |
341 | 402 | $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 |
@@ -558,11 +619,15 @@ discard block |
||
558 | 619 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
559 | 620 | if ($globalDBdriver == 'mysql') { |
560 | 621 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
561 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
622 | + if ($liveinterval) { |
|
623 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
624 | + } |
|
562 | 625 | $query .= ' ORDER BY date'; |
563 | 626 | } else { |
564 | 627 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
565 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
628 | + if ($liveinterval) { |
|
629 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
630 | + } |
|
566 | 631 | $query .= ' ORDER BY date'; |
567 | 632 | } |
568 | 633 | |
@@ -657,7 +722,9 @@ discard block |
||
657 | 722 | $i++; |
658 | 723 | $j++; |
659 | 724 | if ($j == 30) { |
660 | - if ($globalDebug) echo "."; |
|
725 | + if ($globalDebug) { |
|
726 | + echo "."; |
|
727 | + } |
|
661 | 728 | try { |
662 | 729 | |
663 | 730 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -951,7 +1018,9 @@ discard block |
||
951 | 1018 | { |
952 | 1019 | return false; |
953 | 1020 | } |
954 | - } else return ''; |
|
1021 | + } else { |
|
1022 | + return ''; |
|
1023 | + } |
|
955 | 1024 | |
956 | 1025 | if ($longitude != '') |
957 | 1026 | { |
@@ -959,7 +1028,9 @@ discard block |
||
959 | 1028 | { |
960 | 1029 | return false; |
961 | 1030 | } |
962 | - } else return ''; |
|
1031 | + } else { |
|
1032 | + return ''; |
|
1033 | + } |
|
963 | 1034 | |
964 | 1035 | |
965 | 1036 | if ($heading != '') |
@@ -968,7 +1039,9 @@ discard block |
||
968 | 1039 | { |
969 | 1040 | return false; |
970 | 1041 | } |
971 | - } else $heading = 0; |
|
1042 | + } else { |
|
1043 | + $heading = 0; |
|
1044 | + } |
|
972 | 1045 | |
973 | 1046 | if ($groundspeed != '') |
974 | 1047 | { |
@@ -976,9 +1049,13 @@ discard block |
||
976 | 1049 | { |
977 | 1050 | return false; |
978 | 1051 | } |
979 | - } else $groundspeed = 0; |
|
1052 | + } else { |
|
1053 | + $groundspeed = 0; |
|
1054 | + } |
|
980 | 1055 | date_default_timezone_set('UTC'); |
981 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1056 | + if ($date == '') { |
|
1057 | + $date = date("Y-m-d H:i:s", time()); |
|
1058 | + } |
|
982 | 1059 | |
983 | 1060 | |
984 | 1061 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1006,16 +1083,28 @@ discard block |
||
1006 | 1083 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
1007 | 1084 | $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
1008 | 1085 | $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1009 | - if ($typeid == '') $typeid = NULL; |
|
1010 | - if ($statusid == '') $statusid = NULL; |
|
1011 | - if ($distance == '') $distance = NULL; |
|
1086 | + if ($typeid == '') { |
|
1087 | + $typeid = NULL; |
|
1088 | + } |
|
1089 | + if ($statusid == '') { |
|
1090 | + $statusid = NULL; |
|
1091 | + } |
|
1092 | + if ($distance == '') { |
|
1093 | + $distance = NULL; |
|
1094 | + } |
|
1012 | 1095 | |
1013 | 1096 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1015 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1097 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1098 | + $heading = 0; |
|
1099 | + } |
|
1100 | + if ($arrival_date == '') { |
|
1101 | + $arrival_date = NULL; |
|
1102 | + } |
|
1016 | 1103 | $query = ''; |
1017 | 1104 | if ($globalArchive) { |
1018 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1105 | + if ($globalDebug) { |
|
1106 | + echo '-- Delete previous data -- '; |
|
1107 | + } |
|
1019 | 1108 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
1020 | 1109 | } |
1021 | 1110 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
@@ -1030,10 +1119,14 @@ discard block |
||
1030 | 1119 | } |
1031 | 1120 | |
1032 | 1121 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1033 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1122 | + if ($globalDebug) { |
|
1123 | + echo '(Add to Marine archive : '; |
|
1124 | + } |
|
1034 | 1125 | $MarineArchive = new MarineArchive($this->db); |
1035 | 1126 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time); |
1036 | - if ($globalDebug) echo $result.')'; |
|
1127 | + if ($globalDebug) { |
|
1128 | + echo $result.')'; |
|
1129 | + } |
|
1037 | 1130 | } |
1038 | 1131 | return "success"; |
1039 | 1132 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | - if ($type == 'aircraft') { |
|
350 | + if ($type == 'aircraft') { |
|
351 | 351 | if ((isset($globalUsePilot) && $globalUsePilot) || (!isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)))) { |
352 | 352 | print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>'; |
353 | 353 | } |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
690 | 690 | if ($type == 'aircraft') { |
691 | 691 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
692 | - $spotter_item['squawk'] = '-'; |
|
692 | + $spotter_item['squawk'] = '-'; |
|
693 | 693 | } |
694 | 694 | if ($spotter_item['image_thumbnail'] != "") |
695 | 695 | { |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | print '</td>'."\n"; |
729 | 729 | } else { |
730 | 730 | print '<td class="aircraft_thumbnail">'."\n"; |
731 | - // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
731 | + // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
732 | 732 | //} |
733 | 733 | if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) { |
734 | 734 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n"; |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | require_once(dirname(__FILE__).'/require/class.Common.php'); |
6 | 6 | $Common = new Common(); |
7 | -$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
|
8 | -$showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
7 | +$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop'); |
|
8 | +$showDuration = $Common->multiKeyExists($spotter_array, 'duration'); |
|
9 | 9 | |
10 | 10 | if (!isset($type)) $type = 'aircraft'; |
11 | 11 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | print '<th class="more"></th>'; |
166 | 166 | print '</thead>'; |
167 | -} else if (strtolower($current_page) == "upcoming"){ |
|
167 | +} else if (strtolower($current_page) == "upcoming") { |
|
168 | 168 | print '<thead>'; |
169 | 169 | if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
170 | 170 | if ($_GET['sort'] == "airline_name_asc") |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | */ |
220 | 220 | print '</thead>'; |
221 | -} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){ |
|
221 | +} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
|
222 | 222 | print '<thead>'; |
223 | 223 | print '<th class="aircraft_thumbnail"></th>'; |
224 | 224 | print '<th class="logo">'._("Airline").'</th>'; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | print '</thead>'; |
256 | 256 | } else { |
257 | 257 | |
258 | - if ($hide_th_links === true){ |
|
258 | + if ($hide_th_links === true) { |
|
259 | 259 | print '<thead>'; |
260 | 260 | print '<th class="aircraft_thumbnail"></th>'; |
261 | 261 | if ($type == 'aircraft') { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | print '<tbody>'."\n"; |
563 | -foreach($spotter_array as $spotter_item) |
|
563 | +foreach ($spotter_array as $spotter_item) |
|
564 | 564 | { |
565 | 565 | if (isset($globalTimezone)) |
566 | 566 | { |
@@ -595,13 +595,13 @@ discard block |
||
595 | 595 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
596 | 596 | } |
597 | 597 | if (isset($spotter_item['airline_name'])) { |
598 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
598 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
599 | 599 | } else { |
600 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
600 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
601 | 601 | } |
602 | 602 | } else { |
603 | 603 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
604 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
604 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
605 | 605 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
606 | 606 | if (isset($spotter_item['airline_name'])) { |
607 | 607 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | { |
621 | 621 | print '<td class="aircraft_thumbnail">'."\n"; |
622 | 622 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
623 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
623 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
624 | 624 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
625 | 625 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
626 | 626 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | { |
643 | 643 | print '<td class="aircraft_thumbnail">'."\n"; |
644 | 644 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
645 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
645 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
646 | 646 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
647 | 647 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
648 | 648 | print '</td>'."\n"; |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | print '</td>'."\n"; |
687 | 687 | } |
688 | 688 | } |
689 | - } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
|
689 | + } elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") { |
|
690 | 690 | if ($type == 'aircraft') { |
691 | 691 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
692 | 692 | $spotter_item['squawk'] = '-'; |
@@ -703,17 +703,17 @@ discard block |
||
703 | 703 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
704 | 704 | } |
705 | 705 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
706 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
706 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
707 | 707 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
708 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
708 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
709 | 709 | } elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) { |
710 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
710 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
711 | 711 | } else { |
712 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
712 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
713 | 713 | } |
714 | 714 | } else { |
715 | 715 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
716 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
716 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
717 | 717 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
718 | 718 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
719 | 719 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | { |
747 | 747 | print '<td class="aircraft_thumbnail">'."\n"; |
748 | 748 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
749 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
749 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
750 | 750 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
751 | 751 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
752 | 752 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | { |
769 | 769 | print '<td class="aircraft_thumbnail">'."\n"; |
770 | 770 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
771 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
771 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
772 | 772 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
773 | 773 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
774 | 774 | print '</td>'."\n"; |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | print '</td>'."\n"; |
878 | 878 | } |
879 | 879 | // Aircraft type |
880 | - if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){ |
|
880 | + if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") { |
|
881 | 881 | print '<td class="type">'."\n"; |
882 | 882 | if ($type == 'aircraft') { |
883 | 883 | if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) { |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | //print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'._("Not available").'</a></span>'."\n"; |
887 | 887 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
888 | 888 | } else { |
889 | - $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
|
889 | + $aircraft_names = explode('/', $spotter_item['aircraft_name']); |
|
890 | 890 | if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
891 | 891 | else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
892 | 892 | } |
@@ -930,22 +930,22 @@ discard block |
||
930 | 930 | } |
931 | 931 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
932 | 932 | if ($spotter_item['departure_airport_time'] > 2460) { |
933 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
934 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
933 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
934 | + } else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
935 | 935 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
936 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
936 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
937 | 937 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
938 | 938 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
939 | 939 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
940 | 940 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
941 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
941 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
942 | 942 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
943 | 943 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
944 | 944 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
945 | 945 | if ($spotter_item['departure_airport_time'] > 2460) { |
946 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
946 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
947 | 947 | } else { |
948 | - $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
948 | + $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
949 | 949 | } |
950 | 950 | print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n"; |
951 | 951 | } |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | $latitude = $spotter_item['latitude']; |
961 | 961 | $longitude = $spotter_item['longitude']; |
962 | 962 | } |
963 | - $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
|
963 | + $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude); |
|
964 | 964 | } else $distance = ''; |
965 | 965 | if ($distance != '') { |
966 | 966 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -1003,20 +1003,20 @@ discard block |
||
1003 | 1003 | } |
1004 | 1004 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
1005 | 1005 | if ($spotter_item['arrival_airport_time'] > 2460) { |
1006 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
1006 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
1007 | 1007 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
1008 | 1008 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
1009 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
1009 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
1010 | 1010 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
1011 | 1011 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
1012 | 1012 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
1013 | 1013 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
1014 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
1014 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
1015 | 1015 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
1016 | 1016 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
1017 | 1017 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
1018 | 1018 | if ($spotter_item['arrival_airport_time'] > 2460) { |
1019 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
1019 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
1020 | 1020 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
1021 | 1021 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
1022 | 1022 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $latitude = $spotter_item['latitude']; |
1030 | 1030 | $longitude = $spotter_item['longitude']; |
1031 | 1031 | } |
1032 | - $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
|
1032 | + $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude); |
|
1033 | 1033 | } else $distance = ''; |
1034 | 1034 | if ($distance != '') { |
1035 | 1035 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -1084,19 +1084,19 @@ discard block |
||
1084 | 1084 | print '<span class="mobile">-</span>'."\n"; |
1085 | 1085 | } else { |
1086 | 1086 | if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
1087 | - print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n"; |
|
1088 | - print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n"; |
|
1087 | + print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n"; |
|
1088 | + print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n"; |
|
1089 | 1089 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
1090 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n"; |
|
1091 | - print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n"; |
|
1090 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n"; |
|
1091 | + print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n"; |
|
1092 | 1092 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
1093 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n"; |
|
1094 | - print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n"; |
|
1093 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n"; |
|
1094 | + print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n"; |
|
1095 | 1095 | } |
1096 | 1096 | } |
1097 | 1097 | print '</td>'."\n"; |
1098 | 1098 | } |
1099 | - if(strtolower($current_page) != "upcoming"){ |
|
1099 | + if (strtolower($current_page) != "upcoming") { |
|
1100 | 1100 | if ($type == 'aircraft') { |
1101 | 1101 | //if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
1102 | 1102 | if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
@@ -1140,14 +1140,14 @@ discard block |
||
1140 | 1140 | if (isset($spotter_item['distance'])) { |
1141 | 1141 | print '<td class="distance">'; |
1142 | 1142 | if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
1143 | - print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n"; |
|
1144 | - print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n"; |
|
1143 | + print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n"; |
|
1144 | + print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n"; |
|
1145 | 1145 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
1146 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n"; |
|
1147 | - print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n"; |
|
1146 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n"; |
|
1147 | + print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n"; |
|
1148 | 1148 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
1149 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n"; |
|
1150 | - print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n"; |
|
1149 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n"; |
|
1150 | + print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n"; |
|
1151 | 1151 | } |
1152 | 1152 | print '</td>'."\n"; |
1153 | 1153 | } else { |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | if ($showRouteStop) { |
1179 | 1179 | // Route stop |
1180 | - if(strtolower($current_page) != "upcoming"){ |
|
1180 | + if (strtolower($current_page) != "upcoming") { |
|
1181 | 1181 | print '<td class="route_stop">'."\n"; |
1182 | 1182 | if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') { |
1183 | 1183 | print '<span class="nomobile">-</span>'."\n"; |
@@ -1196,11 +1196,11 @@ discard block |
||
1196 | 1196 | } |
1197 | 1197 | if ($showDuration) { |
1198 | 1198 | // Duration |
1199 | - if(strtolower($current_page) != "upcoming"){ |
|
1199 | + if (strtolower($current_page) != "upcoming") { |
|
1200 | 1200 | print '<td class="duration">'."\n"; |
1201 | 1201 | if (isset($spotter_item['duration'])) { |
1202 | - print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n"; |
|
1203 | - print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n"; |
|
1202 | + print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n"; |
|
1203 | + print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n"; |
|
1204 | 1204 | } else { |
1205 | 1205 | print '<span class="nomobile">-</span>'."\n"; |
1206 | 1206 | print '<span class="mobile">-</span>'."\n"; |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
1214 | 1214 | if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') { |
1215 | 1215 | print '<td class="message"><p>'."\n"; |
1216 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
1216 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
1217 | 1217 | print '</p><p class="decode">'; |
1218 | 1218 | $decode_array = json_decode($spotter_item['decode']); |
1219 | 1219 | foreach ($decode_array as $key => $value) { |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | print '</td>'."\n"; |
1224 | 1224 | } else { |
1225 | 1225 | print '<td class="message">'."\n"; |
1226 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
1226 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
1227 | 1227 | print '</td>'."\n"; |
1228 | 1228 | } |
1229 | 1229 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | print '</td>'."\n"; |
1250 | 1250 | print '<td class="message">'."\n"; |
1251 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
1251 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
1252 | 1252 | print '</td>'."\n"; |
1253 | 1253 | } |
1254 | 1254 | if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") { |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | print '</td>'."\n"; |
1275 | 1275 | */ |
1276 | 1276 | print '<td class="message">'."\n"; |
1277 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
1277 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
1278 | 1278 | print '</td>'."\n"; |
1279 | 1279 | } |
1280 | 1280 |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
8 | 8 | $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
9 | 9 | |
10 | -if (!isset($type)) $type = 'aircraft'; |
|
10 | +if (!isset($type)) { |
|
11 | + $type = 'aircraft'; |
|
12 | +} |
|
11 | 13 | |
12 | 14 | if (!isset($_GET['sort'])) |
13 | 15 | { |
@@ -565,7 +567,9 @@ discard block |
||
565 | 567 | if (isset($globalTimezone)) |
566 | 568 | { |
567 | 569 | date_default_timezone_set($globalTimezone); |
568 | - } else date_default_timezone_set('UTC'); |
|
570 | + } else { |
|
571 | + date_default_timezone_set('UTC'); |
|
572 | + } |
|
569 | 573 | if ($showSpecial === true) |
570 | 574 | { |
571 | 575 | print '<tr class="special">'."\n"; |
@@ -580,7 +584,9 @@ discard block |
||
580 | 584 | print '<tr class="active">'; |
581 | 585 | } elseif (isset($spotter_item['spotted_registration'])) { |
582 | 586 | print '<tr class="info">'; |
583 | - } else print '<tr>'; |
|
587 | + } else { |
|
588 | + print '<tr>'; |
|
589 | + } |
|
584 | 590 | } |
585 | 591 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") { |
586 | 592 | if ($type == 'aircraft') { |
@@ -588,8 +594,9 @@ discard block |
||
588 | 594 | { |
589 | 595 | print '<td class="aircraft_thumbnail">'."\n"; |
590 | 596 | if ($spotter_item['image_source'] == 'planespotters') { |
591 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
592 | - else { |
|
597 | + if ($spotter_item['image_source_website'] != '') { |
|
598 | + $image_src = $spotter_item['image_source_website']; |
|
599 | + } else { |
|
593 | 600 | $planespotter_url_array = explode("_", $spotter_item['image']); |
594 | 601 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
595 | 602 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -602,7 +609,9 @@ discard block |
||
602 | 609 | } else { |
603 | 610 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
604 | 611 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
605 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
612 | + } else { |
|
613 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
614 | + } |
|
606 | 615 | if (isset($spotter_item['airline_name'])) { |
607 | 616 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
608 | 617 | } else { |
@@ -621,7 +630,9 @@ discard block |
||
621 | 630 | print '<td class="aircraft_thumbnail">'."\n"; |
622 | 631 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
623 | 632 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
624 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
633 | + } else { |
|
634 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
635 | + } |
|
625 | 636 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
626 | 637 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
627 | 638 | } else { |
@@ -643,7 +654,9 @@ discard block |
||
643 | 654 | print '<td class="aircraft_thumbnail">'."\n"; |
644 | 655 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
645 | 656 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
646 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
657 | + } else { |
|
658 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
659 | + } |
|
647 | 660 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
648 | 661 | print '</td>'."\n"; |
649 | 662 | } else { |
@@ -696,8 +709,9 @@ discard block |
||
696 | 709 | print '<td class="aircraft_thumbnail">'."\n"; |
697 | 710 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
698 | 711 | if ($spotter_item['image_source'] == 'planespotters') { |
699 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
700 | - else { |
|
712 | + if ($spotter_item['image_source_website'] != '') { |
|
713 | + $image_src = $spotter_item['image_source_website']; |
|
714 | + } else { |
|
701 | 715 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
702 | 716 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
703 | 717 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -714,7 +728,9 @@ discard block |
||
714 | 728 | } else { |
715 | 729 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
716 | 730 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
717 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
731 | + } else { |
|
732 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
733 | + } |
|
718 | 734 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
719 | 735 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
720 | 736 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -747,7 +763,9 @@ discard block |
||
747 | 763 | print '<td class="aircraft_thumbnail">'."\n"; |
748 | 764 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
749 | 765 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
750 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
766 | + } else { |
|
767 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
768 | + } |
|
751 | 769 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
752 | 770 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
753 | 771 | } else { |
@@ -769,7 +787,9 @@ discard block |
||
769 | 787 | print '<td class="aircraft_thumbnail">'."\n"; |
770 | 788 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
771 | 789 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
772 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
790 | + } else { |
|
791 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
792 | + } |
|
773 | 793 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
774 | 794 | print '</td>'."\n"; |
775 | 795 | } else { |
@@ -887,8 +907,11 @@ discard block |
||
887 | 907 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
888 | 908 | } else { |
889 | 909 | $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
890 | - if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
891 | - else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
910 | + if (count($aircraft_names) == 1) { |
|
911 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
912 | + } else { |
|
913 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
914 | + } |
|
892 | 915 | } |
893 | 916 | print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
894 | 917 | } elseif ($type == 'marine') { |
@@ -931,15 +954,21 @@ discard block |
||
931 | 954 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
932 | 955 | if ($spotter_item['departure_airport_time'] > 2460) { |
933 | 956 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
934 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
957 | + } else { |
|
958 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
959 | + } |
|
935 | 960 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
936 | 961 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
937 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
962 | + } else { |
|
963 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
964 | + } |
|
938 | 965 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
939 | 966 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
940 | 967 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
941 | 968 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
942 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
969 | + } else { |
|
970 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
971 | + } |
|
943 | 972 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
944 | 973 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
945 | 974 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -961,7 +990,9 @@ discard block |
||
961 | 990 | $longitude = $spotter_item['longitude']; |
962 | 991 | } |
963 | 992 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
964 | - } else $distance = ''; |
|
993 | + } else { |
|
994 | + $distance = ''; |
|
995 | + } |
|
965 | 996 | if ($distance != '') { |
966 | 997 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
967 | 998 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -988,7 +1019,9 @@ discard block |
||
988 | 1019 | } else { |
989 | 1020 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
990 | 1021 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
991 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
1022 | + if (!isset($Spotter)) { |
|
1023 | + $Spotter = new Spotter(); |
|
1024 | + } |
|
992 | 1025 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
993 | 1026 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
994 | 1027 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -1004,20 +1037,28 @@ discard block |
||
1004 | 1037 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
1005 | 1038 | if ($spotter_item['arrival_airport_time'] > 2460) { |
1006 | 1039 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
1007 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
1040 | + } else { |
|
1041 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
1042 | + } |
|
1008 | 1043 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
1009 | 1044 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
1010 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
1045 | + } else { |
|
1046 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
1047 | + } |
|
1011 | 1048 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
1012 | 1049 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
1013 | 1050 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
1014 | 1051 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
1015 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
1052 | + } else { |
|
1053 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
1054 | + } |
|
1016 | 1055 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
1017 | 1056 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
1018 | 1057 | if ($spotter_item['arrival_airport_time'] > 2460) { |
1019 | 1058 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
1020 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
1059 | + } else { |
|
1060 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
1061 | + } |
|
1021 | 1062 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
1022 | 1063 | } |
1023 | 1064 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -1030,7 +1071,9 @@ discard block |
||
1030 | 1071 | $longitude = $spotter_item['longitude']; |
1031 | 1072 | } |
1032 | 1073 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
1033 | - } else $distance = ''; |
|
1074 | + } else { |
|
1075 | + $distance = ''; |
|
1076 | + } |
|
1034 | 1077 | if ($distance != '') { |
1035 | 1078 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
1036 | 1079 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | require_once('require/class.MarineArchive.php'); |
7 | 7 | |
8 | -if (!isset($_GET['race'])){ |
|
8 | +if (!isset($_GET['race'])) { |
|
9 | 9 | header('Location: '.$globalURL.'/'); |
10 | 10 | } else { |
11 | 11 | $type = 'marine'; |
12 | 12 | $Marine = new Marine(); |
13 | 13 | $MarineArchive = new MarineArchive(); |
14 | 14 | //calculuation for the pagination |
15 | - if(!isset($_GET['limit'])) |
|
15 | + if (!isset($_GET['limit'])) |
|
16 | 16 | { |
17 | 17 | $limit_start = 0; |
18 | 18 | $limit_end = 25; |
@@ -33,29 +33,29 @@ discard block |
||
33 | 33 | |
34 | 34 | $page_url = $globalURL.'/race/'.$_GET['race']; |
35 | 35 | |
36 | - $race = filter_input(INPUT_GET,'race',FILTER_SANITIZE_STRING); |
|
37 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
38 | - $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
39 | - $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
36 | + $race = filter_input(INPUT_GET, 'race', FILTER_SANITIZE_STRING); |
|
37 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
38 | + $year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
39 | + $month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
40 | 40 | $filter = array(); |
41 | - if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
42 | - if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
41 | + if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
42 | + if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
43 | 43 | if ($sort != '') |
44 | 44 | { |
45 | - $spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter); |
|
45 | + $spotter_array = $Marine->getMarineDataByRace($race, $limit_start.",".$absolute_difference, $sort, $filter); |
|
46 | 46 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
47 | - $spotter_array = $MarineArchive->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter); |
|
47 | + $spotter_array = $MarineArchive->getMarineDataByRace($race, $limit_start.",".$absolute_difference, $sort, $filter); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference,'',$filter); |
|
50 | + $spotter_array = $Marine->getMarineDataByRace($race, $limit_start.",".$absolute_difference, '', $filter); |
|
51 | 51 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
52 | - $spotter_array = $MarineArchive->getMarineDataByRace($race,$limit_start.",".$absolute_difference,'',$filter); |
|
52 | + $spotter_array = $MarineArchive->getMarineDataByRace($race, $limit_start.",".$absolute_difference, '', $filter); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | 56 | if (!empty($spotter_array)) |
57 | 57 | { |
58 | - $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['race_name']); |
|
58 | + $title = sprintf(_("Detailed View for %s"), $spotter_array[0]['race_name']); |
|
59 | 59 | $ident = $spotter_array[0]['ident']; |
60 | 60 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
61 | 61 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | } else $flights = 0; |
120 | 120 | if ($flights == 0) |
121 | 121 | */ |
122 | - $flights = $Marine->countCaptainsByRace($race,$filter); |
|
122 | + $flights = $Marine->countCaptainsByRace($race, $filter); |
|
123 | 123 | print '<div><span class="label">'._("Captains").'</span>'.$flights.'</div>'; |
124 | - $aircraft_type = count($Marine->countAllBoatTypesByRace($race,$filter)); |
|
124 | + $aircraft_type = count($Marine->countAllBoatTypesByRace($race, $filter)); |
|
125 | 125 | print '<div><span class="label">'._("Boat type").'</span>'.$aircraft_type.'</div>'; |
126 | 126 | //$aircraft_registration = count($Marine->countAllAircraftRegistrationByrace($race,$filter)); |
127 | 127 | //print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>'; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | //include('race-sub-menu.php'); |
137 | 137 | print '<div class="table column">'; |
138 | - print '<p>'.sprintf(_("The table below shows the detailed information of all races with the race <strong>%s</strong>."),$spotter_array[0]['race_name']).'</p>'; |
|
138 | + print '<p>'.sprintf(_("The table below shows the detailed information of all races with the race <strong>%s</strong>."), $spotter_array[0]['race_name']).'</p>'; |
|
139 | 139 | |
140 | 140 | include('table-output.php'); |
141 | 141 | print '<div class="pagination">'; |
@@ -38,8 +38,12 @@ discard block |
||
38 | 38 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
39 | 39 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
40 | 40 | $filter = array(); |
41 | - if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
42 | - if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
41 | + if ($year != '') { |
|
42 | + $filter = array_merge($filter,array('year' => $year)); |
|
43 | + } |
|
44 | + if ($month != '') { |
|
45 | + $filter = array_merge($filter,array('month' => $month)); |
|
46 | + } |
|
43 | 47 | if ($sort != '') |
44 | 48 | { |
45 | 49 | $spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter); |
@@ -57,8 +61,12 @@ discard block |
||
57 | 61 | { |
58 | 62 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['race_name']); |
59 | 63 | $ident = $spotter_array[0]['ident']; |
60 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
61 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
64 | + if (isset($spotter_array[0]['latitude'])) { |
|
65 | + $latitude = $spotter_array[0]['latitude']; |
|
66 | + } |
|
67 | + if (isset($spotter_array[0]['longitude'])) { |
|
68 | + $longitude = $spotter_array[0]['longitude']; |
|
69 | + } |
|
62 | 70 | require_once('header.php'); |
63 | 71 | /* |
64 | 72 | if (isset($globalArchive) && $globalArchive) { |
@@ -111,7 +119,9 @@ discard block |
||
111 | 119 | */ |
112 | 120 | print '<div class="info column">'; |
113 | 121 | print '<h1>'.$spotter_array[0]['race_name'].'</h1>'; |
114 | - if (isset($spotter_array[0]['race_id']) && $spotter_array[0]['race_id'] != '') print '<div><span class="label">'._("race ID").'</span>'.$spotter_array[0]['race_id'].'</div>'; |
|
122 | + if (isset($spotter_array[0]['race_id']) && $spotter_array[0]['race_id'] != '') { |
|
123 | + print '<div><span class="label">'._("race ID").'</span>'.$spotter_array[0]['race_id'].'</div>'; |
|
124 | + } |
|
115 | 125 | /* |
116 | 126 | if ($year == '' && $month == '') { |
117 | 127 | $Stats = new Stats(); |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $s3 = sin($bank/2); |
60 | 60 | $c1c2 = $c1*$c2; |
61 | 61 | $s1s2 = $s1*$s2; |
62 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
63 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
64 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
62 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
63 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
64 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
65 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
66 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
67 | 67 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
68 | 68 | |
69 | 69 | } |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | $min = false; |
85 | 85 | $allhistory = false; |
86 | 86 | $filter['source'] = array(); |
87 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
88 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
89 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
90 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
91 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
92 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
93 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
94 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
95 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
96 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
97 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
87 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
88 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
89 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
90 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
91 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
92 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
93 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
94 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
95 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
96 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
97 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
98 | 98 | /* |
99 | 99 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
100 | 100 | $min = true; |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $from_archive = true; |
142 | 142 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
143 | 143 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
144 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
145 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
146 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
147 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
148 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
144 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
145 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
146 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
148 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
149 | 149 | if ($tracker) { |
150 | - $spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate,$enddate,$filter); |
|
150 | + $spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate, $enddate, $filter); |
|
151 | 151 | } elseif ($marine) { |
152 | - $spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate,$enddate,$filter); |
|
152 | + $spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate, $enddate, $filter); |
|
153 | 153 | } else { |
154 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
154 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
155 | 155 | } |
156 | 156 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
157 | 157 | $from_archive = true; |
@@ -168,36 +168,36 @@ discard block |
||
168 | 168 | } |
169 | 169 | $enddate = $_COOKIE['archive_end']; |
170 | 170 | $enddateinitial = $_COOKIE['archive_end']; |
171 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
172 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
173 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
171 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
172 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
173 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
174 | 174 | //echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
175 | 175 | if ($tracker) { |
176 | - $spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate,$enddate,$filter); |
|
176 | + $spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate, $enddate, $filter); |
|
177 | 177 | } elseif ($marine) { |
178 | - $spotter_array = $MarineArchive->getMinLiveMarineData($begindate,$enddate,$filter); |
|
178 | + $spotter_array = $MarineArchive->getMinLiveMarineData($begindate, $enddate, $filter); |
|
179 | 179 | } else { |
180 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
180 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
181 | 181 | } |
182 | 182 | } elseif ($tracker) { |
183 | 183 | $coord = array(); |
184 | 184 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
185 | - $coord = explode(',',$_GET['coord']); |
|
186 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
185 | + $coord = explode(',', $_GET['coord']); |
|
186 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
187 | 187 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
188 | 188 | $coord = array(); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | $previous_filter = $filter; |
192 | 192 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackTracker']) && $_COOKIE['MapTrackTracker'] != '')) { |
193 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrackTracker'])); |
|
194 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,false); |
|
193 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrackTracker'])); |
|
194 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, false); |
|
195 | 195 | /* |
196 | 196 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) { |
197 | 197 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true,$_COOKIE['MapTrack']); |
198 | 198 | */ |
199 | 199 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
200 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,false); |
|
200 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, false); |
|
201 | 201 | } else { |
202 | 202 | $spotter_array = array(); |
203 | 203 | } |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | $coord = array(); |
207 | 207 | //if (isset($_GET['coord']) && $_GET['coord'] != '') { |
208 | 208 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
209 | - $coord = explode(',',$_GET['coord']); |
|
210 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
209 | + $coord = explode(',', $_GET['coord']); |
|
210 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
211 | 211 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
212 | 212 | $coord = array(); |
213 | 213 | } |
214 | 214 | } |
215 | 215 | $previous_filter = $filter; |
216 | 216 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) { |
217 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrackMarine'])); |
|
218 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false); |
|
217 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrackMarine'])); |
|
218 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, false); |
|
219 | 219 | } elseif (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '' && !empty($coord)) { |
220 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false,$_COOKIE['MapTrack']); |
|
220 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, false, $_COOKIE['MapTrack']); |
|
221 | 221 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
222 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false); |
|
222 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, false); |
|
223 | 223 | } else { |
224 | 224 | $spotter_array = array(); |
225 | 225 | } |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | } else { |
228 | 228 | $coord = array(); |
229 | 229 | if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') { |
230 | - $coord = explode(',',$_GET['coord']); |
|
231 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
230 | + $coord = explode(',', $_GET['coord']); |
|
231 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
232 | 232 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
233 | 233 | $coord = array(); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | $previous_filter = $filter; |
237 | 237 | if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) { |
238 | - $filter = array_merge($filter,array('id' => $_COOKIE['MapTrack'])); |
|
239 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,false); |
|
238 | + $filter = array_merge($filter, array('id' => $_COOKIE['MapTrack'])); |
|
239 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, false); |
|
240 | 240 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) { |
241 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,false,$_COOKIE['MapTrack']); |
|
241 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, false, $_COOKIE['MapTrack']); |
|
242 | 242 | } elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') { |
243 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,false); |
|
243 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, false); |
|
244 | 244 | } else { |
245 | 245 | $spotter_array = array(); |
246 | 246 | } |
@@ -250,19 +250,19 @@ discard block |
||
250 | 250 | if (!empty($spotter_array) && isset($coord)) { |
251 | 251 | if ($tracker) { |
252 | 252 | if (isset($_GET['archive'])) { |
253 | - $flightcnt = $TrackerArchive->getLiveTrackerCount($begindate,$enddate,$filter); |
|
253 | + $flightcnt = $TrackerArchive->getLiveTrackerCount($begindate, $enddate, $filter); |
|
254 | 254 | } else { |
255 | 255 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
256 | 256 | } |
257 | 257 | } elseif ($marine) { |
258 | 258 | if (isset($_GET['archive'])) { |
259 | - $flightcnt = $MarineArchive->getLiveMarineCount($begindate,$enddate,$filter); |
|
259 | + $flightcnt = $MarineArchive->getLiveMarineCount($begindate, $enddate, $filter); |
|
260 | 260 | } else { |
261 | 261 | $flightcnt = $MarineLive->getLiveMarineCount($filter); |
262 | 262 | } |
263 | 263 | } else { |
264 | 264 | if (isset($_GET['archive'])) { |
265 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
265 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
266 | 266 | } else { |
267 | 267 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
268 | 268 | } |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | if ($flightcnt == '') $flightcnt = 0; |
271 | 271 | } else $flightcnt = 0; |
272 | 272 | |
273 | -$sqltime = round(microtime(true)-$begintime,2); |
|
273 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
274 | 274 | $minitime = time(); |
275 | 275 | $minitracktime_begin = time(); |
276 | 276 | $minitracktime = $minitracktime_begin; |
277 | 277 | $maxitime = 0; |
278 | -$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT); |
|
278 | +$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT); |
|
279 | 279 | $modelsdb = array(); |
280 | 280 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
281 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
282 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
283 | - if (isset($row[1]) ){ |
|
281 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
282 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
283 | + if (isset($row[1])) { |
|
284 | 284 | $model = $row[0]; |
285 | 285 | $modelsdb[$model] = $row[1]; |
286 | 286 | } |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | $modelsdb2 = array(); |
292 | 292 | if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) { |
293 | - if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) { |
|
294 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
295 | - if (isset($row[1]) ){ |
|
293 | + if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) { |
|
294 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
295 | + if (isset($row[1])) { |
|
296 | 296 | $model = $row[0]; |
297 | 297 | $glb = $row[1]; |
298 | 298 | if (isset($row[2])) { |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if (!empty($spotter_array) && is_array($spotter_array)) |
339 | 339 | { |
340 | 340 | $nblatlong = 0; |
341 | - foreach($spotter_array as $spotter_item) |
|
341 | + foreach ($spotter_array as $spotter_item) |
|
342 | 342 | { |
343 | 343 | $j++; |
344 | 344 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | } |
393 | 393 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
394 | 394 | if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",'; |
395 | - if (isset($spotter_item['ident'])) $output.= '"ident": "'.$spotter_item['ident'].'",'; |
|
395 | + if (isset($spotter_item['ident'])) $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
396 | 396 | if ($tracker) { |
397 | 397 | if (isset($spotter_item['type'])) $output .= '"tracker_type": "'.$spotter_item['type'].'",'; |
398 | - $output.= '"type": "tracker"'; |
|
398 | + $output .= '"type": "tracker"'; |
|
399 | 399 | } elseif ($marine) { |
400 | 400 | if (isset($spotter_item['type'])) $output .= '"marine_type": "'.$spotter_item['type'].'",'; |
401 | - $output.= '"type": "marine"'; |
|
401 | + $output .= '"type": "marine"'; |
|
402 | 402 | } else { |
403 | 403 | if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) { |
404 | 404 | $aircraft_icao = $spotter_item['aircraft_icao']; |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | if (isset($airline_icao)) { |
413 | 413 | $imagefile = $aircraft_icao.'-'.$airline_icao.'.png'; |
414 | 414 | if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) { |
415 | - $output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
415 | + $output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | } |
419 | 419 | //if ($ident != '') $output.= '"ident": "'.$ident.'",'; |
420 | 420 | } |
421 | - $output.= '"gltf2": %gltf2%,'; |
|
422 | - $output.= '"type": "flight"'; |
|
421 | + $output .= '"gltf2": %gltf2%,'; |
|
422 | + $output .= '"type": "flight"'; |
|
423 | 423 | } |
424 | 424 | $output .= '},'; |
425 | 425 | |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | $output .= '},'; |
795 | 795 | } |
796 | 796 | } |
797 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
798 | - else $output = str_replace('%onground%','false',$output); |
|
797 | + if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output); |
|
798 | + else $output = str_replace('%onground%', 'false', $output); |
|
799 | 799 | |
800 | 800 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
801 | 801 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
812 | 812 | if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']); |
813 | 813 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
814 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
814 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
815 | 815 | $output .= $spotter_item['longitude'].', '; |
816 | 816 | $output .= $spotter_item['latitude']; |
817 | 817 | $prevlong = $spotter_item['longitude']; |
@@ -839,8 +839,8 @@ discard block |
||
839 | 839 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
840 | 840 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
841 | 841 | } else { |
842 | - $nblatlong = $nblatlong+1; |
|
843 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
842 | + $nblatlong = $nblatlong + 1; |
|
843 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
844 | 844 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
845 | 845 | if ($spotter_item['ground_speed'] == 0) { |
846 | 846 | $output .= $prevlong.', '; |
@@ -881,26 +881,26 @@ discard block |
||
881 | 881 | $output .= ']'; |
882 | 882 | if (isset($globalArchive) && $globalArchive === TRUE) { |
883 | 883 | if (isset($begindateinitial)) { |
884 | - $output = str_replace('%minitime%',date("c",$begindateinitial),$output); |
|
885 | - } elseif ((time()-$globalLiveInterval) > $minitime) { |
|
886 | - if (time()-$globalLiveInterval > $maxitime) { |
|
887 | - $output = str_replace('%minitime%',date("c",$maxitime),$output); |
|
884 | + $output = str_replace('%minitime%', date("c", $begindateinitial), $output); |
|
885 | + } elseif ((time() - $globalLiveInterval) > $minitime) { |
|
886 | + if (time() - $globalLiveInterval > $maxitime) { |
|
887 | + $output = str_replace('%minitime%', date("c", $maxitime), $output); |
|
888 | 888 | } else { |
889 | - $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
889 | + $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
890 | 890 | } |
891 | 891 | } |
892 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
892 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
893 | 893 | } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) { |
894 | - $output = str_replace('%minitime%',date("c",$minitracktime),$output); |
|
894 | + $output = str_replace('%minitime%', date("c", $minitracktime), $output); |
|
895 | 895 | } else { |
896 | - $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
896 | + $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
897 | 897 | } |
898 | 898 | if (isset($enddateinitial)) { |
899 | - $output = str_replace('%maxitime%',date("c",$enddateinitial),$output); |
|
899 | + $output = str_replace('%maxitime%', date("c", $enddateinitial), $output); |
|
900 | 900 | } else { |
901 | - $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
901 | + $output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
902 | 902 | } |
903 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
904 | -else $output = str_replace('%gltf2%','false',$output); |
|
903 | +if ($gltf2) $output = str_replace('%gltf2%', 'true', $output); |
|
904 | +else $output = str_replace('%gltf2%', 'false', $output); |
|
905 | 905 | print $output; |
906 | 906 | ?> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | if (isset($_POST['race'])) |
9 | 9 | { |
10 | - header('Location: '.$globalURL.'/race/'.filter_input(INPUT_POST,'race',FILTER_SANITIZE_STRING)); |
|
10 | + header('Location: '.$globalURL.'/race/'.filter_input(INPUT_POST, 'race', FILTER_SANITIZE_STRING)); |
|
11 | 11 | //} else if (isset($_GET['airport'])){ |
12 | 12 | } else { |
13 | 13 | $Marine = new Marine(); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | //ksort($race_names); |
25 | 25 | $previous = null; |
26 | 26 | print '<div class="alphabet-legend">'; |
27 | - foreach($race_names as $value) { |
|
27 | + foreach ($race_names as $value) { |
|
28 | 28 | $firstLetter = strtoupper($Common->replace_mb_substr($value['race_name'], 0, 1)); |
29 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
29 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
30 | 30 | { |
31 | - if ($previous !== null){ |
|
31 | + if ($previous !== null) { |
|
32 | 32 | print ' | '; |
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | } |
38 | 38 | print '</div>'; |
39 | 39 | $previous = null; |
40 | - foreach($race_names as $value) { |
|
40 | + foreach ($race_names as $value) { |
|
41 | 41 | $firstLetter = strtoupper($Common->replace_mb_substr($value['race_name'], 0, 1)); |
42 | 42 | if ($firstLetter != "") |
43 | 43 | { |
44 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
44 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
45 | 45 | { |
46 | - if ($previous !== null){ |
|
46 | + if ($previous !== null) { |
|
47 | 47 | print '</div>'; |
48 | 48 | } |
49 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
35 | 35 | } |
36 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
36 | + if ($firstLetter != "'") { |
|
37 | + $previous = $firstLetter; |
|
38 | + } |
|
37 | 39 | } |
38 | 40 | print '</div>'; |
39 | 41 | $previous = null; |
@@ -48,10 +50,15 @@ discard block |
||
48 | 50 | } |
49 | 51 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
50 | 52 | } |
51 | - if ($firstLetter != "'") $previous = $firstLetter; |
|
53 | + if ($firstLetter != "'") { |
|
54 | + $previous = $firstLetter; |
|
55 | + } |
|
52 | 56 | print '<div class="alphabet-item">'; |
53 | - if (isset($value['race_id']) && $value['race_id'] != '') print '<a href="'.$globalURL.'/marine/race/'.$value['race_id'].'">'.$value['race_name'].' ('.$value['race_id'].')'; |
|
54 | - else print '<a href="'.$globalURL.'/race/'.$value['race_name'].'">'.$value['race_name']; |
|
57 | + if (isset($value['race_id']) && $value['race_id'] != '') { |
|
58 | + print '<a href="'.$globalURL.'/marine/race/'.$value['race_id'].'">'.$value['race_name'].' ('.$value['race_id'].')'; |
|
59 | + } else { |
|
60 | + print '<a href="'.$globalURL.'/race/'.$value['race_name'].'">'.$value['race_name']; |
|
61 | + } |
|
55 | 62 | print '</a>'; |
56 | 63 | print '</div>'; |
57 | 64 | } |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,40 +68,40 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // marine_archive |
86 | - public function addMarineArchiveData($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 = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$distance = '',$race_rank = '', $race_time = '') { |
|
86 | + public function addMarineArchiveData($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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Marine = new Marine($this->db); |
90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | |
95 | 95 | //$country = $over_country; |
96 | 96 | // Route is not added in marine_archive |
97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
99 | - $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' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
99 | + $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' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
100 | 100 | try { |
101 | 101 | $sth = $this->db->prepare($query); |
102 | 102 | $sth->execute($query_values); |
103 | 103 | $sth->closeCursor(); |
104 | - } catch(PDOException $e) { |
|
104 | + } catch (PDOException $e) { |
|
105 | 105 | return "error : ".$e->getMessage(); |
106 | 106 | } |
107 | 107 | return "success"; |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
123 | 123 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
124 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
125 | 125 | |
126 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
126 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
127 | 127 | |
128 | 128 | return $spotter_array; |
129 | 129 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
143 | 143 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
144 | 144 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
145 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
145 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
146 | 146 | |
147 | 147 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
148 | 148 | /* |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
157 | 157 | */ |
158 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
158 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
159 | 159 | |
160 | 160 | return $spotter_array; |
161 | 161 | } |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | { |
171 | 171 | date_default_timezone_set('UTC'); |
172 | 172 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
173 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
174 | 174 | |
175 | 175 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
176 | 176 | |
177 | 177 | try { |
178 | 178 | $sth = $this->db->prepare($query); |
179 | 179 | $sth->execute(array(':id' => $id)); |
180 | - } catch(PDOException $e) { |
|
180 | + } catch (PDOException $e) { |
|
181 | 181 | echo $e->getMessage(); |
182 | 182 | die; |
183 | 183 | } |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | { |
197 | 197 | date_default_timezone_set('UTC'); |
198 | 198 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
199 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
199 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
200 | 200 | |
201 | 201 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
202 | 202 | |
203 | 203 | try { |
204 | 204 | $sth = $this->db->prepare($query); |
205 | 205 | $sth->execute(array(':id' => $id)); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | echo $e->getMessage(); |
208 | 208 | die; |
209 | 209 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | date_default_timezone_set('UTC'); |
226 | 226 | |
227 | 227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
228 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
228 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | 229 | |
230 | 230 | try { |
231 | 231 | $sth = $this->db->prepare($query); |
232 | 232 | $sth->execute(array(':ident' => $ident)); |
233 | - } catch(PDOException $e) { |
|
233 | + } catch (PDOException $e) { |
|
234 | 234 | echo $e->getMessage(); |
235 | 235 | die; |
236 | 236 | } |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | date_default_timezone_set('UTC'); |
252 | 252 | |
253 | 253 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
254 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
254 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | 255 | |
256 | 256 | try { |
257 | 257 | $sth = $this->db->prepare($query); |
258 | 258 | $sth->execute(array(':id' => $id)); |
259 | - } catch(PDOException $e) { |
|
259 | + } catch (PDOException $e) { |
|
260 | 260 | echo $e->getMessage(); |
261 | 261 | die; |
262 | 262 | } |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | date_default_timezone_set('UTC'); |
278 | 278 | |
279 | 279 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
280 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
280 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | 281 | |
282 | 282 | try { |
283 | 283 | $sth = $this->db->prepare($query); |
284 | 284 | $sth->execute(array(':id' => $id)); |
285 | - } catch(PDOException $e) { |
|
285 | + } catch (PDOException $e) { |
|
286 | 286 | echo $e->getMessage(); |
287 | 287 | die; |
288 | 288 | } |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | date_default_timezone_set('UTC'); |
305 | 305 | |
306 | 306 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
307 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
307 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | 308 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
309 | 309 | |
310 | 310 | try { |
311 | 311 | $sth = $this->db->prepare($query); |
312 | 312 | $sth->execute(array(':ident' => $ident)); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | echo $e->getMessage(); |
315 | 315 | die; |
316 | 316 | } |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @return Array the spotter information |
328 | 328 | * |
329 | 329 | */ |
330 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
330 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
331 | 331 | { |
332 | 332 | $Marine = new Marine($this->db); |
333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
334 | 334 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
335 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
335 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
336 | 336 | return $spotter_array; |
337 | 337 | } |
338 | 338 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | try { |
352 | 352 | $sth = $this->db->prepare($query); |
353 | 353 | $sth->execute(); |
354 | - } catch(PDOException $e) { |
|
354 | + } catch (PDOException $e) { |
|
355 | 355 | echo $e->getMessage(); |
356 | 356 | die; |
357 | 357 | } |
@@ -363,24 +363,24 @@ discard block |
||
363 | 363 | * @return Array the spotter information |
364 | 364 | * |
365 | 365 | */ |
366 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
366 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
367 | 367 | { |
368 | 368 | global $globalDBdriver, $globalLiveInterval; |
369 | 369 | date_default_timezone_set('UTC'); |
370 | 370 | |
371 | 371 | $filter_query = ''; |
372 | 372 | if (isset($filter['source']) && !empty($filter['source'])) { |
373 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
373 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
374 | 374 | } |
375 | 375 | // Use spotter_output also ? |
376 | 376 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
377 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
377 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
378 | 378 | } |
379 | 379 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
380 | 380 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
381 | 381 | } |
382 | 382 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
383 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
383 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
400 | 400 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
401 | 401 | */ |
402 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
402 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | 403 | FROM marine_archive |
404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
405 | 405 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
406 | 406 | '.$filter_query.' ORDER BY fammarine_id'; |
407 | 407 | } else { |
408 | 408 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
409 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
409 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
410 | 410 | FROM marine_archive |
411 | 411 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
412 | 412 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | try { |
417 | 417 | $sth = $this->db->prepare($query); |
418 | 418 | $sth->execute(); |
419 | - } catch(PDOException $e) { |
|
419 | + } catch (PDOException $e) { |
|
420 | 420 | echo $e->getMessage(); |
421 | 421 | die; |
422 | 422 | } |
@@ -431,24 +431,24 @@ discard block |
||
431 | 431 | * @return Array the spotter information |
432 | 432 | * |
433 | 433 | */ |
434 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
434 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
435 | 435 | { |
436 | 436 | global $globalDBdriver, $globalLiveInterval; |
437 | 437 | date_default_timezone_set('UTC'); |
438 | 438 | |
439 | 439 | $filter_query = ''; |
440 | 440 | if (isset($filter['source']) && !empty($filter['source'])) { |
441 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
441 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
442 | 442 | } |
443 | 443 | // Should use spotter_output also ? |
444 | 444 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
445 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
445 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
446 | 446 | } |
447 | 447 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
448 | 448 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
449 | 449 | } |
450 | 450 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
451 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
451 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | FROM marine_archive |
459 | 459 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
460 | 460 | */ |
461 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
461 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
462 | 462 | FROM marine_archive_output |
463 | 463 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
464 | 464 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
474 | 474 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
475 | 475 | */ |
476 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
476 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
477 | 477 | FROM marine_archive_output |
478 | 478 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
479 | 479 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | try { |
486 | 486 | $sth = $this->db->prepare($query); |
487 | 487 | $sth->execute(); |
488 | - } catch(PDOException $e) { |
|
488 | + } catch (PDOException $e) { |
|
489 | 489 | echo $e->getMessage(); |
490 | 490 | die; |
491 | 491 | } |
@@ -500,23 +500,23 @@ discard block |
||
500 | 500 | * @return Array the spotter information |
501 | 501 | * |
502 | 502 | */ |
503 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
503 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
504 | 504 | { |
505 | 505 | global $globalDBdriver, $globalLiveInterval; |
506 | 506 | date_default_timezone_set('UTC'); |
507 | 507 | |
508 | 508 | $filter_query = ''; |
509 | 509 | if (isset($filter['source']) && !empty($filter['source'])) { |
510 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
510 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
511 | 511 | } |
512 | 512 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
513 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
513 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
514 | 514 | } |
515 | 515 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
516 | 516 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
517 | 517 | } |
518 | 518 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
519 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
519 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | try { |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(); |
534 | - } catch(PDOException $e) { |
|
534 | + } catch (PDOException $e) { |
|
535 | 535 | echo $e->getMessage(); |
536 | 536 | die; |
537 | 537 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @return Array the spotter information |
552 | 552 | * |
553 | 553 | */ |
554 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
554 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
555 | 555 | { |
556 | 556 | global $globalTimezone, $globalDBdriver; |
557 | 557 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | $q_array = explode(" ", $q); |
575 | 575 | |
576 | - foreach ($q_array as $q_item){ |
|
576 | + foreach ($q_array as $q_item) { |
|
577 | 577 | $additional_query .= " AND ("; |
578 | 578 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
579 | 579 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | if ($registration != "") |
607 | 607 | { |
608 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
608 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
609 | 609 | if (!is_string($registration)) |
610 | 610 | { |
611 | 611 | return false; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | |
617 | 617 | if ($aircraft_icao != "") |
618 | 618 | { |
619 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
619 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
620 | 620 | if (!is_string($aircraft_icao)) |
621 | 621 | { |
622 | 622 | return false; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | |
628 | 628 | if ($aircraft_manufacturer != "") |
629 | 629 | { |
630 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
630 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
631 | 631 | if (!is_string($aircraft_manufacturer)) |
632 | 632 | { |
633 | 633 | return false; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | if ($airline_icao != "") |
650 | 650 | { |
651 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
651 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
652 | 652 | if (!is_string($airline_icao)) |
653 | 653 | { |
654 | 654 | return false; |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | |
660 | 660 | if ($airline_country != "") |
661 | 661 | { |
662 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
662 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
663 | 663 | if (!is_string($airline_country)) |
664 | 664 | { |
665 | 665 | return false; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | |
671 | 671 | if ($airline_type != "") |
672 | 672 | { |
673 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
673 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
674 | 674 | if (!is_string($airline_type)) |
675 | 675 | { |
676 | 676 | return false; |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | if ($airport != "") |
694 | 694 | { |
695 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
695 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
696 | 696 | if (!is_string($airport)) |
697 | 697 | { |
698 | 698 | return false; |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | |
704 | 704 | if ($airport_country != "") |
705 | 705 | { |
706 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
706 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
707 | 707 | if (!is_string($airport_country)) |
708 | 708 | { |
709 | 709 | return false; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | |
715 | 715 | if ($callsign != "") |
716 | 716 | { |
717 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
717 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
718 | 718 | if (!is_string($callsign)) |
719 | 719 | { |
720 | 720 | return false; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | $translate = $Translation->ident2icao($callsign); |
723 | 723 | if ($translate != $callsign) { |
724 | 724 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
725 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
725 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
726 | 726 | } else { |
727 | 727 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
728 | 728 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | |
732 | 732 | if ($owner != "") |
733 | 733 | { |
734 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
734 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
735 | 735 | if (!is_string($owner)) |
736 | 736 | { |
737 | 737 | return false; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | if ($pilot_name != "") |
744 | 744 | { |
745 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
745 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
746 | 746 | if (!is_string($pilot_name)) |
747 | 747 | { |
748 | 748 | return false; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | |
754 | 754 | if ($pilot_id != "") |
755 | 755 | { |
756 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
756 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
757 | 757 | if (!is_string($pilot_id)) |
758 | 758 | { |
759 | 759 | return false; |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | if ($departure_airport_route != "") |
766 | 766 | { |
767 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
767 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
768 | 768 | if (!is_string($departure_airport_route)) |
769 | 769 | { |
770 | 770 | return false; |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | if ($arrival_airport_route != "") |
777 | 777 | { |
778 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
778 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
779 | 779 | if (!is_string($arrival_airport_route)) |
780 | 780 | { |
781 | 781 | return false; |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | { |
789 | 789 | $altitude_array = explode(",", $altitude); |
790 | 790 | |
791 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
792 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
791 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
792 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
793 | 793 | |
794 | 794 | |
795 | 795 | if ($altitude_array[1] != "") |
@@ -807,8 +807,8 @@ discard block |
||
807 | 807 | { |
808 | 808 | $date_array = explode(",", $date_posted); |
809 | 809 | |
810 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
811 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
810 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
811 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
812 | 812 | |
813 | 813 | if ($globalTimezone != '') { |
814 | 814 | date_default_timezone_set($globalTimezone); |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | { |
841 | 841 | $limit_array = explode(",", $limit); |
842 | 842 | |
843 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
844 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
843 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
844 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
845 | 845 | |
846 | 846 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
847 | 847 | { |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | |
853 | 853 | |
854 | 854 | if ($origLat != "" && $origLon != "" && $dist != "") { |
855 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
856 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
855 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
856 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
857 | 857 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
858 | 858 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
859 | 859 | } else { |
@@ -870,12 +870,12 @@ discard block |
||
870 | 870 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
871 | 871 | } |
872 | 872 | |
873 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
873 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
874 | 874 | WHERE marine_archive_output.ident <> '' |
875 | 875 | ".$additional_query." |
876 | 876 | ".$filter_query.$orderby_query; |
877 | 877 | } |
878 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
878 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
879 | 879 | |
880 | 880 | return $spotter_array; |
881 | 881 | } |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | try { |
893 | 893 | $sth = $this->db->prepare($query); |
894 | 894 | $sth->execute(); |
895 | - } catch(PDOException $e) { |
|
895 | + } catch (PDOException $e) { |
|
896 | 896 | return "error"; |
897 | 897 | } |
898 | 898 | } |
@@ -929,8 +929,8 @@ discard block |
||
929 | 929 | { |
930 | 930 | $limit_array = explode(",", $limit); |
931 | 931 | |
932 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
933 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
932 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
933 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
934 | 934 | |
935 | 935 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
936 | 936 | { |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | $query_values = array(); |
972 | 972 | $limit_query = ''; |
973 | 973 | $additional_query = ''; |
974 | - $filter_query = $this->getFilter($filter,true,true); |
|
974 | + $filter_query = $this->getFilter($filter, true, true); |
|
975 | 975 | |
976 | 976 | if ($owner != "") |
977 | 977 | { |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | { |
989 | 989 | $limit_array = explode(",", $limit); |
990 | 990 | |
991 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
992 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
991 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
992 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
993 | 993 | |
994 | 994 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
995 | 995 | { |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $query_values = array(); |
1030 | 1030 | $limit_query = ''; |
1031 | 1031 | $additional_query = ''; |
1032 | - $filter_query = $this->getFilter($filter,true,true); |
|
1032 | + $filter_query = $this->getFilter($filter, true, true); |
|
1033 | 1033 | |
1034 | 1034 | if ($pilot != "") |
1035 | 1035 | { |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | { |
1042 | 1042 | $limit_array = explode(",", $limit); |
1043 | 1043 | |
1044 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1045 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1044 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1045 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1046 | 1046 | |
1047 | 1047 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1048 | 1048 | { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | * @return Array the airline country list |
1073 | 1073 | * |
1074 | 1074 | */ |
1075 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1075 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1076 | 1076 | { |
1077 | 1077 | global $globalDBdriver; |
1078 | 1078 | /* |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | $flight_array = array(); |
1102 | 1102 | $temp_array = array(); |
1103 | 1103 | |
1104 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1104 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1105 | 1105 | { |
1106 | 1106 | $temp_array['flight_count'] = $row['nb']; |
1107 | 1107 | $temp_array['flight_country'] = $row['name']; |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | * @return Array the airline country list |
1119 | 1119 | * |
1120 | 1120 | */ |
1121 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1121 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1122 | 1122 | { |
1123 | 1123 | global $globalDBdriver; |
1124 | 1124 | /* |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $flight_array = array(); |
1148 | 1148 | $temp_array = array(); |
1149 | 1149 | |
1150 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1150 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1151 | 1151 | { |
1152 | 1152 | $temp_array['airline_icao'] = $row['airline_icao']; |
1153 | 1153 | $temp_array['flight_count'] = $row['nb']; |
@@ -1165,14 +1165,14 @@ discard block |
||
1165 | 1165 | * @return Array the spotter information |
1166 | 1166 | * |
1167 | 1167 | */ |
1168 | - public function getDateArchiveMarineDataById($id,$date) |
|
1168 | + public function getDateArchiveMarineDataById($id, $date) |
|
1169 | 1169 | { |
1170 | 1170 | $Marine = new Marine($this->db); |
1171 | 1171 | date_default_timezone_set('UTC'); |
1172 | 1172 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1173 | 1173 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1174 | - $date = date('c',$date); |
|
1175 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1174 | + $date = date('c', $date); |
|
1175 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1176 | 1176 | return $spotter_array; |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1182,14 +1182,14 @@ discard block |
||
1182 | 1182 | * @return Array the spotter information |
1183 | 1183 | * |
1184 | 1184 | */ |
1185 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1185 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1186 | 1186 | { |
1187 | 1187 | $Marine = new Marine($this->db); |
1188 | 1188 | date_default_timezone_set('UTC'); |
1189 | 1189 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1190 | 1190 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1191 | - $date = date('c',$date); |
|
1192 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1191 | + $date = date('c', $date); |
|
1192 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1193 | 1193 | return $spotter_array; |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | * @return Array the spotter information |
1200 | 1200 | * |
1201 | 1201 | */ |
1202 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1202 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1203 | 1203 | { |
1204 | 1204 | global $global_query; |
1205 | 1205 | $Marine = new Marine($this->db); |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | $query_values = array(); |
1208 | 1208 | $limit_query = ''; |
1209 | 1209 | $additional_query = ''; |
1210 | - $filter_query = $this->getFilter($filters,true,true); |
|
1210 | + $filter_query = $this->getFilter($filters, true, true); |
|
1211 | 1211 | |
1212 | 1212 | if ($airport != "") |
1213 | 1213 | { |
@@ -1224,8 +1224,8 @@ discard block |
||
1224 | 1224 | { |
1225 | 1225 | $limit_array = explode(",", $limit); |
1226 | 1226 | |
1227 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1228 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1227 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1228 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1229 | 1229 | |
1230 | 1230 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1231 | 1231 | { |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | } |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,106 +105,106 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
154 | 154 | //$dataFound = true; |
155 | - } |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
166 | 166 | } |
167 | 167 | if (isset($line['status']) && $line['status'] != '') { |
168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
169 | 169 | } |
170 | 170 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
171 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
172 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
171 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
172 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
173 | 173 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
174 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
174 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
175 | 175 | $Marine = new Marine($this->db); |
176 | 176 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
177 | 177 | unset($Marine); |
178 | - } |
|
178 | + } |
|
179 | + } |
|
179 | 180 | } |
180 | - } |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
185 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
185 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
186 | 186 | } |
187 | 187 | if (isset($line['imo']) && $line['imo'] != '') { |
188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
189 | 189 | } |
190 | 190 | if (isset($line['callsign']) && $line['callsign'] != '') { |
191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
192 | 192 | } |
193 | 193 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
194 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
195 | 195 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
196 | 196 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
197 | 197 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
198 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
199 | 199 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
200 | - $Marine = new Marine($this->db); |
|
201 | - $fromsource = NULL; |
|
202 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
203 | - $Marine->db = null; |
|
200 | + $Marine = new Marine($this->db); |
|
201 | + $fromsource = NULL; |
|
202 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
203 | + $Marine->db = null; |
|
204 | + } |
|
204 | 205 | } |
205 | - } |
|
206 | 206 | } |
207 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
207 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
208 | 208 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
209 | 209 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
210 | 210 | if (!isset($line['id'])) { |
@@ -212,47 +212,47 @@ discard block |
||
212 | 212 | $this->all_tracked[$id]['forcenew'] = 1; |
213 | 213 | $this->all_tracked[$id]['addedMarine'] = 0; |
214 | 214 | } |
215 | - } |
|
215 | + } |
|
216 | 216 | } |
217 | 217 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
218 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
219 | 219 | } |
220 | 220 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
222 | 222 | } |
223 | 223 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
225 | 225 | } |
226 | 226 | if (isset($line['race_id']) && $line['race_id'] != '') { |
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['race_name']) && $line['race_name'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['race_time']) && $line['race_time'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['distance']) && $line['distance'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
243 | 243 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
244 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
244 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
245 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
246 | - $timeelapsed = microtime(true); |
|
247 | - $Marine = new Marine($this->db); |
|
248 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
249 | - $Marine->db = null; |
|
246 | + $timeelapsed = microtime(true); |
|
247 | + $Marine = new Marine($this->db); |
|
248 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
249 | + $Marine->db = null; |
|
250 | + } |
|
250 | 251 | } |
251 | - } |
|
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
253 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
253 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
254 | 254 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
255 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
255 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
256 | 256 | $timeelapsed = microtime(true); |
257 | 257 | $Marine = new Marine($this->db); |
258 | 258 | $fromsource = NULL; |
@@ -260,20 +260,20 @@ discard block |
||
260 | 260 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
261 | 261 | $Marine->db = null; |
262 | 262 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
263 | - } |
|
263 | + } |
|
264 | + } |
|
264 | 265 | } |
265 | - } |
|
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
266 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
270 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
270 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
271 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
272 | - } else { |
|
272 | + } else { |
|
273 | 273 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
274 | 274 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
275 | 275 | return ''; |
276 | - } |
|
276 | + } |
|
277 | 277 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
278 | 278 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
279 | 279 | return ''; |
@@ -290,33 +290,33 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | if (isset($line['speed'])) { |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
295 | 295 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
296 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
297 | - if ($distance > 1000 && $distance < 10000) { |
|
296 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
297 | + if ($distance > 1000 && $distance < 10000) { |
|
298 | 298 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 299 | $speed = $speed*3.6; |
300 | 300 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
301 | 301 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
302 | - } |
|
302 | + } |
|
303 | 303 | } |
304 | 304 | |
305 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | - else unset($timediff); |
|
308 | - if ($this->tmd > 5 || |
|
309 | - !isset($timediff) || |
|
310 | - $timediff > $globalLiveInterval || |
|
311 | - ( |
|
312 | - $timediff > 30 && |
|
313 | - isset($this->all_tracked[$id]['latitude']) && |
|
314 | - isset($this->all_tracked[$id]['longitude']) && |
|
315 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
316 | - ) |
|
317 | - ) { |
|
305 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
306 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | + else unset($timediff); |
|
308 | + if ($this->tmd > 5 || |
|
309 | + !isset($timediff) || |
|
310 | + $timediff > $globalLiveInterval || |
|
311 | + ( |
|
312 | + $timediff > 30 && |
|
313 | + isset($this->all_tracked[$id]['latitude']) && |
|
314 | + isset($this->all_tracked[$id]['longitude']) && |
|
315 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
316 | + ) |
|
317 | + ) { |
|
318 | 318 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
319 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
319 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
320 | 320 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
321 | 321 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 322 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -324,200 +324,200 @@ discard block |
||
324 | 324 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
325 | 325 | $timeelapsed = microtime(true); |
326 | 326 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | - $Marine = new Marine($this->db); |
|
328 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
329 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
330 | - $Marine->db = null; |
|
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
327 | + $Marine = new Marine($this->db); |
|
328 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
329 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
330 | + $Marine->db = null; |
|
331 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
332 | 332 | } |
333 | 333 | $this->tmd = 0; |
334 | 334 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
335 | - } |
|
335 | + } |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | 339 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
340 | 340 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
341 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
342 | - $dataFound = true; |
|
343 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
341 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
342 | + $dataFound = true; |
|
343 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
344 | 344 | } |
345 | 345 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
346 | 346 | } |
347 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
348 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
349 | 349 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
350 | 350 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
351 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
352 | - $dataFound = true; |
|
353 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
351 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
352 | + $dataFound = true; |
|
353 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
354 | 354 | } |
355 | 355 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
356 | 356 | } |
357 | 357 | |
358 | - } else if ($globalDebug && $timediff > 20) { |
|
358 | + } else if ($globalDebug && $timediff > 20) { |
|
359 | 359 | $this->tmd = $this->tmd + 1; |
360 | 360 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
361 | 361 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
362 | 362 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
363 | 363 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
368 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
367 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
368 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
369 | 369 | } |
370 | 370 | if (isset($line['format_source']) && $line['format_source'] != '') { |
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
372 | 372 | } |
373 | 373 | if (isset($line['source_name']) && $line['source_name'] != '') { |
374 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
374 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
375 | 375 | } |
376 | 376 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
377 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
377 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
384 | - //$dataFound = true; |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
384 | + //$dataFound = true; |
|
385 | 385 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
386 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
386 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
390 | 390 | } |
391 | 391 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
392 | 392 | |
393 | 393 | |
394 | 394 | |
395 | 395 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
396 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
397 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
398 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
399 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
396 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
397 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
398 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
399 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
402 | - $timeelapsed = microtime(true); |
|
403 | - $MarineLive = new MarineLive($this->db); |
|
404 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
401 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
402 | + $timeelapsed = microtime(true); |
|
403 | + $MarineLive = new MarineLive($this->db); |
|
404 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
405 | 405 | $Marine = new Marine($this->db); |
406 | 406 | $recent_ident = $Marine->checkId($line['id']); |
407 | 407 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
408 | 408 | $Marine->db=null; |
409 | - } elseif (isset($line['id'])) { |
|
409 | + } elseif (isset($line['id'])) { |
|
410 | 410 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | 411 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
412 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
412 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
413 | 413 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | 414 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
415 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
415 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
416 | 416 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | 417 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
418 | - } else $recent_ident = ''; |
|
419 | - $MarineLive->db=null; |
|
420 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
418 | + } else $recent_ident = ''; |
|
419 | + $MarineLive->db=null; |
|
420 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
422 | 422 | } else $recent_ident = ''; |
423 | - } else { |
|
423 | + } else { |
|
424 | 424 | $recent_ident = ''; |
425 | 425 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
426 | - } |
|
427 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
428 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | - { |
|
426 | + } |
|
427 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
428 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | + { |
|
430 | 430 | if ($globalDebug) { |
431 | 431 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
432 | 432 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
433 | 433 | } |
434 | 434 | //adds the spotter data for the archive |
435 | - $highlight = ''; |
|
436 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
437 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
435 | + $highlight = ''; |
|
436 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
437 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
438 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | - $timeelapsed = microtime(true); |
|
440 | - $Marine = new Marine($this->db); |
|
441 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
442 | - $Marine->db = null; |
|
443 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
439 | + $timeelapsed = microtime(true); |
|
440 | + $Marine = new Marine($this->db); |
|
441 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
442 | + $Marine->db = null; |
|
443 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
445 | + } |
|
445 | 446 | } |
446 | - } |
|
447 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
447 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
448 | 448 | // Add source stat in DB |
449 | 449 | $Stats = new Stats($this->db); |
450 | 450 | if (!empty($this->stats)) { |
451 | - if ($globalDebug) echo 'Add source stats : '; |
|
452 | - foreach($this->stats as $date => $data) { |
|
451 | + if ($globalDebug) echo 'Add source stats : '; |
|
452 | + foreach($this->stats as $date => $data) { |
|
453 | 453 | foreach($data as $source => $sourced) { |
454 | - //print_r($sourced); |
|
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
457 | - if (isset($sourced['msg'])) { |
|
458 | - if (time() - $sourced['msg']['date'] > 10) { |
|
459 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
460 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
461 | - unset($this->stats[$date][$source]['msg']); |
|
462 | - } |
|
463 | - } |
|
464 | - } |
|
465 | - if ($date != date('Y-m-d')) { |
|
466 | - unset($this->stats[$date]); |
|
467 | - } |
|
468 | - } |
|
469 | - if ($globalDebug) echo 'Done'."\n"; |
|
454 | + //print_r($sourced); |
|
455 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
457 | + if (isset($sourced['msg'])) { |
|
458 | + if (time() - $sourced['msg']['date'] > 10) { |
|
459 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
460 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
461 | + unset($this->stats[$date][$source]['msg']); |
|
462 | + } |
|
463 | + } |
|
464 | + } |
|
465 | + if ($date != date('Y-m-d')) { |
|
466 | + unset($this->stats[$date]); |
|
467 | + } |
|
468 | + } |
|
469 | + if ($globalDebug) echo 'Done'."\n"; |
|
470 | 470 | } |
471 | 471 | $Stats->db = null; |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - $this->del(); |
|
474 | + $this->del(); |
|
475 | 475 | //$ignoreImport = false; |
476 | 476 | $this->all_tracked[$id]['addedMarine'] = 1; |
477 | 477 | //print_r($this->all_tracked[$id]); |
478 | 478 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
479 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
480 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
481 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
479 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
480 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
481 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
482 | 482 | $MarineLive = new MarineLive($this->db); |
483 | 483 | $MarineLive->deleteLiveMarineData(); |
484 | 484 | $MarineLive->db=null; |
485 | 485 | if ($globalDebug) echo " Done\n"; |
486 | - } |
|
487 | - $this->last_delete = time(); |
|
486 | + } |
|
487 | + $this->last_delete = time(); |
|
488 | 488 | } |
489 | - } elseif ($recent_ident != '') { |
|
489 | + } elseif ($recent_ident != '') { |
|
490 | 490 | $this->all_tracked[$id]['id'] = $recent_ident; |
491 | 491 | $this->all_tracked[$id]['addedMarine'] = 1; |
492 | 492 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
493 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
493 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
494 | 494 | $Marine = new Marine($this->db); |
495 | 495 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
496 | 496 | $Marine->db = null; |
497 | - } |
|
497 | + } |
|
498 | 498 | } |
499 | 499 | |
500 | - } |
|
500 | + } |
|
501 | 501 | } |
502 | - } |
|
503 | - //adds the spotter LIVE data |
|
504 | - if ($globalDebug) { |
|
502 | + } |
|
503 | + //adds the spotter LIVE data |
|
504 | + if ($globalDebug) { |
|
505 | 505 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
506 | - } |
|
507 | - $ignoreImport = false; |
|
506 | + } |
|
507 | + $ignoreImport = false; |
|
508 | 508 | |
509 | - if (!$ignoreImport) { |
|
509 | + if (!$ignoreImport) { |
|
510 | 510 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
511 | 511 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
512 | 512 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
513 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
514 | 514 | $timeelapsed = microtime(true); |
515 | 515 | $MarineLive = new MarineLive($this->db); |
516 | 516 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
517 | 517 | $MarineLive->db = null; |
518 | 518 | if ($globalDebug) echo $result."\n"; |
519 | 519 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
520 | - } |
|
520 | + } |
|
521 | 521 | } |
522 | 522 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
523 | 523 | $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | if ($stats_heading == 16) $stats_heading = 0; |
553 | 553 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | 554 | for ($i=0;$i<=15;$i++) { |
555 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
555 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
556 | 556 | } |
557 | 557 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
558 | 558 | } else { |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | //var_dump($this->stats); |
566 | 566 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
567 | 567 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | - end($this->stats[$current_date][$source]['hist']); |
|
569 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
568 | + end($this->stats[$current_date][$source]['hist']); |
|
569 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
570 | 570 | } else $mini = 0; |
571 | 571 | for ($i=$mini;$i<=$distance;$i+=10) { |
572 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
572 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
573 | 573 | } |
574 | 574 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
575 | 575 | } else { |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | |
586 | 586 | |
587 | 587 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
588 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
588 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
589 | 589 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
590 | 590 | $MarineLive = new MarineLive($this->db); |
591 | 591 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
592 | 592 | $MarineLive->db = null; |
593 | 593 | //MarineLive->deleteLiveMarineData(); |
594 | 594 | if ($globalDebug) echo " Done\n"; |
595 | - } |
|
596 | - $this->last_delete_hourly = time(); |
|
595 | + } |
|
596 | + $this->last_delete_hourly = time(); |
|
597 | 597 | } |
598 | 598 | |
599 | - } |
|
600 | - //$ignoreImport = false; |
|
599 | + } |
|
600 | + //$ignoreImport = false; |
|
601 | 601 | } |
602 | 602 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
603 | 603 | if ($send) return $this->all_tracked[$id]; |
604 | - } |
|
604 | + } |
|
605 | + } |
|
605 | 606 | } |
606 | - } |
|
607 | 607 | } |
608 | 608 | ?> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
107 | + if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi']) || isset($line['id'])) { |
110 | 110 | |
@@ -129,25 +129,25 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '', 'distance' => NULL)); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | 148 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
149 | 149 | $this->all_tracked[$id]['type'] = $identity['type']; |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
151 | 151 | } |
152 | 152 | //print_r($identity); |
153 | 153 | unset($Marine); |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (isset($line['type_id'])) { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
160 | 160 | } |
161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
164 | 164 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
166 | 166 | } |
167 | 167 | if (isset($line['status']) && $line['status'] != '') { |
168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
169 | 169 | } |
170 | 170 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
171 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
171 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
172 | 172 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
173 | 173 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
174 | 174 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
175 | 175 | $Marine = new Marine($this->db); |
176 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
176 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
177 | 177 | unset($Marine); |
178 | 178 | } |
179 | 179 | } |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
185 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
185 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
186 | 186 | } |
187 | 187 | if (isset($line['imo']) && $line['imo'] != '') { |
188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
189 | 189 | } |
190 | 190 | if (isset($line['callsign']) && $line['callsign'] != '') { |
191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
192 | 192 | } |
193 | 193 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | 194 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
195 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
195 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
196 | 196 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
197 | 197 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | 198 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
199 | 199 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
200 | 200 | $Marine = new Marine($this->db); |
201 | 201 | $fromsource = NULL; |
202 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
202 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
203 | 203 | $Marine->db = null; |
204 | 204 | } |
205 | 205 | } |
@@ -215,28 +215,28 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
218 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
219 | 219 | } |
220 | 220 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
222 | 222 | } |
223 | 223 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
225 | 225 | } |
226 | 226 | if (isset($line['race_id']) && $line['race_id'] != '') { |
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['race_name']) && $line['race_name'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['race_time']) && $line['race_time'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['distance']) && $line['distance'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance'])); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -245,44 +245,44 @@ discard block |
||
245 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | $Marine = new Marine($this->db); |
248 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
248 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
249 | 249 | $Marine->db = null; |
250 | 250 | } |
251 | 251 | } |
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
253 | 253 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
254 | 254 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
255 | 255 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
256 | 256 | $timeelapsed = microtime(true); |
257 | 257 | $Marine = new Marine($this->db); |
258 | 258 | $fromsource = NULL; |
259 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
259 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
260 | 260 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
261 | 261 | $Marine->db = null; |
262 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
262 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
266 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
267 | 267 | } |
268 | 268 | |
269 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
269 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
270 | 270 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
272 | 272 | } else { |
273 | 273 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
274 | 274 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
275 | 275 | return ''; |
276 | 276 | } |
277 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
277 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
278 | 278 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
279 | 279 | return ''; |
280 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
280 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
281 | 281 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
282 | 282 | return ''; |
283 | 283 | } elseif (!isset($line['datetime'])) { |
284 | 284 | date_default_timezone_set('UTC'); |
285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
286 | 286 | } else { |
287 | 287 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
288 | 288 | return ''; |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | if (isset($line['speed'])) { |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2))); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
295 | 295 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
296 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
296 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
297 | 297 | if ($distance > 1000 && $distance < 10000) { |
298 | 298 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 299 | $speed = $speed*3.6; |
300 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
300 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2))); |
|
301 | 301 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | 305 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
306 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
307 | 307 | else unset($timediff); |
308 | 308 | if ($this->tmd > 5 || |
309 | 309 | !isset($timediff) || |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | $timediff > 30 && |
313 | 313 | isset($this->all_tracked[$id]['latitude']) && |
314 | 314 | isset($this->all_tracked[$id]['longitude']) && |
315 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
315 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
316 | 316 | ) |
317 | 317 | ) { |
318 | 318 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
319 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
319 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
320 | 320 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
321 | 321 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 322 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | $timeelapsed = microtime(true); |
326 | 326 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | 327 | $Marine = new Marine($this->db); |
328 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
328 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
329 | 329 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
330 | 330 | $Marine->db = null; |
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
331 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
332 | 332 | } |
333 | 333 | $this->tmd = 0; |
334 | 334 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -337,55 +337,55 @@ discard block |
||
337 | 337 | |
338 | 338 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | 339 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
340 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
340 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
341 | 341 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
342 | 342 | $dataFound = true; |
343 | 343 | $this->all_tracked[$id]['time_last_coord'] = time(); |
344 | 344 | } |
345 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
345 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
346 | 346 | } |
347 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | 348 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
349 | 349 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
350 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
350 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
351 | 351 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
352 | 352 | $dataFound = true; |
353 | 353 | $this->all_tracked[$id]['time_last_coord'] = time(); |
354 | 354 | } |
355 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
355 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } else if ($globalDebug && $timediff > 20) { |
359 | 359 | $this->tmd = $this->tmd + 1; |
360 | 360 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
361 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
362 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
361 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
362 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
363 | 363 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
364 | 364 | } |
365 | 365 | } |
366 | 366 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | 367 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
368 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
368 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
369 | 369 | } |
370 | 370 | if (isset($line['format_source']) && $line['format_source'] != '') { |
371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
372 | 372 | } |
373 | 373 | if (isset($line['source_name']) && $line['source_name'] != '') { |
374 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
374 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
375 | 375 | } |
376 | 376 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
377 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
377 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
383 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
383 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
384 | 384 | //$dataFound = true; |
385 | 385 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
386 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
387 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
386 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
387 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
388 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | 389 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
390 | 390 | } |
391 | 391 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
396 | 396 | $this->all_tracked[$id]['lastupdate'] = time(); |
397 | 397 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
398 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
398 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
399 | 399 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | 401 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -404,28 +404,28 @@ discard block |
||
404 | 404 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
405 | 405 | $Marine = new Marine($this->db); |
406 | 406 | $recent_ident = $Marine->checkId($line['id']); |
407 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
408 | - $Marine->db=null; |
|
407 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
408 | + $Marine->db = null; |
|
409 | 409 | } elseif (isset($line['id'])) { |
410 | 410 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
411 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
412 | 412 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
413 | 413 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
415 | 415 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
416 | 416 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
418 | 418 | } else $recent_ident = ''; |
419 | - $MarineLive->db=null; |
|
419 | + $MarineLive->db = null; |
|
420 | 420 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
421 | 421 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
422 | 422 | } else $recent_ident = ''; |
423 | 423 | } else { |
424 | 424 | $recent_ident = ''; |
425 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
425 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
426 | 426 | } |
427 | 427 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
428 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
428 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
429 | 429 | { |
430 | 430 | if ($globalDebug) { |
431 | 431 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | } |
434 | 434 | //adds the spotter data for the archive |
435 | 435 | $highlight = ''; |
436 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
436 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
437 | 437 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
438 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | 439 | $timeelapsed = microtime(true); |
440 | 440 | $Marine = new Marine($this->db); |
441 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
441 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
442 | 442 | $Marine->db = null; |
443 | 443 | if ($globalDebug && isset($result)) echo $result."\n"; |
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | $Stats = new Stats($this->db); |
450 | 450 | if (!empty($this->stats)) { |
451 | 451 | if ($globalDebug) echo 'Add source stats : '; |
452 | - foreach($this->stats as $date => $data) { |
|
453 | - foreach($data as $source => $sourced) { |
|
452 | + foreach ($this->stats as $date => $data) { |
|
453 | + foreach ($data as $source => $sourced) { |
|
454 | 454 | //print_r($sourced); |
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
455 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
456 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
457 | 457 | if (isset($sourced['msg'])) { |
458 | 458 | if (time() - $sourced['msg']['date'] > 10) { |
459 | 459 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
460 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
460 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
461 | 461 | unset($this->stats[$date][$source]['msg']); |
462 | 462 | } |
463 | 463 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
482 | 482 | $MarineLive = new MarineLive($this->db); |
483 | 483 | $MarineLive->deleteLiveMarineData(); |
484 | - $MarineLive->db=null; |
|
484 | + $MarineLive->db = null; |
|
485 | 485 | if ($globalDebug) echo " Done\n"; |
486 | 486 | } |
487 | 487 | $this->last_delete = time(); |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
493 | 493 | if (isset($globalDaemon) && !$globalDaemon) { |
494 | 494 | $Marine = new Marine($this->db); |
495 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
495 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
496 | 496 | $Marine->db = null; |
497 | 497 | } |
498 | 498 | } |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | $ignoreImport = false; |
508 | 508 | |
509 | 509 | if (!$ignoreImport) { |
510 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
510 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
511 | 511 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
512 | 512 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | 513 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
514 | 514 | $timeelapsed = microtime(true); |
515 | 515 | $MarineLive = new MarineLive($this->db); |
516 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
516 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']); |
|
517 | 517 | $MarineLive->db = null; |
518 | 518 | if ($globalDebug) echo $result."\n"; |
519 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
519 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
523 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
523 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
524 | 524 | } |
525 | 525 | $this->all_tracked[$id]['putinarchive'] = false; |
526 | 526 | |
@@ -539,19 +539,19 @@ discard block |
||
539 | 539 | $latitude = $globalCenterLatitude; |
540 | 540 | $longitude = $globalCenterLongitude; |
541 | 541 | } |
542 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
542 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
543 | 543 | } else { |
544 | 544 | $latitude = $this->source_location[$source]['latitude']; |
545 | 545 | $longitude = $this->source_location[$source]['longitude']; |
546 | 546 | } |
547 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
547 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
548 | 548 | //$stats_heading = $stats_heading%22.5; |
549 | 549 | $stats_heading = round($stats_heading/22.5); |
550 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
550 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
551 | 551 | $current_date = date('Y-m-d'); |
552 | 552 | if ($stats_heading == 16) $stats_heading = 0; |
553 | 553 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | - for ($i=0;$i<=15;$i++) { |
|
554 | + for ($i = 0; $i <= 15; $i++) { |
|
555 | 555 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
556 | 556 | } |
557 | 557 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
567 | 567 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | 568 | end($this->stats[$current_date][$source]['hist']); |
569 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
569 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
570 | 570 | } else $mini = 0; |
571 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
571 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
572 | 572 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
573 | 573 | } |
574 | 574 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | $this->all_tracked[$id]['lastupdate'] = time(); |
582 | 582 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
583 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
583 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
584 | 584 | //$this->del(); |
585 | 585 | |
586 | 586 |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -193,7 +219,9 @@ discard block |
||
193 | 219 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
194 | 220 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
195 | 221 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
196 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
224 | + } |
|
197 | 225 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
198 | 226 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
199 | 227 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -206,7 +234,9 @@ discard block |
||
206 | 234 | } |
207 | 235 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
208 | 236 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
209 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + if ($globalDebug) { |
|
238 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
239 | + } |
|
210 | 240 | if (!isset($line['id'])) { |
211 | 241 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
212 | 242 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -215,7 +245,9 @@ discard block |
||
215 | 245 | } |
216 | 246 | } |
217 | 247 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + if (strtotime($line['arrival_date']) > time()) { |
|
249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
250 | + } |
|
219 | 251 | } |
220 | 252 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
221 | 253 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -257,34 +289,49 @@ discard block |
||
257 | 289 | $Marine = new Marine($this->db); |
258 | 290 | $fromsource = NULL; |
259 | 291 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
260 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
292 | + if ($globalDebug && $result != 'success') { |
|
293 | + echo '!!! ERROR : '.$result."\n"; |
|
294 | + } |
|
261 | 295 | $Marine->db = null; |
262 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
296 | + if ($globalDebugTimeElapsed) { |
|
297 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
298 | + } |
|
263 | 299 | } |
264 | 300 | } |
265 | 301 | } |
266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
303 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
304 | + } |
|
267 | 305 | } |
268 | 306 | |
269 | 307 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
270 | 308 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
271 | 309 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
272 | 310 | } else { |
273 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
274 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
311 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
312 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
313 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
314 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
315 | + } |
|
275 | 316 | return ''; |
276 | 317 | } |
277 | 318 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
278 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
319 | + if ($globalDebug) { |
|
320 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
321 | + } |
|
279 | 322 | return ''; |
280 | 323 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
281 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
324 | + if ($globalDebug) { |
|
325 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
326 | + } |
|
282 | 327 | return ''; |
283 | 328 | } elseif (!isset($line['datetime'])) { |
284 | 329 | date_default_timezone_set('UTC'); |
285 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
286 | 331 | } else { |
287 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
332 | + if ($globalDebug) { |
|
333 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
334 | + } |
|
288 | 335 | return ''; |
289 | 336 | } |
290 | 337 | |
@@ -297,14 +344,21 @@ discard block |
||
297 | 344 | if ($distance > 1000 && $distance < 10000) { |
298 | 345 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
299 | 346 | $speed = $speed*3.6; |
300 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
301 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
347 | + if ($speed < 1000) { |
|
348 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
349 | + } |
|
350 | + if ($globalDebug) { |
|
351 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
352 | + } |
|
302 | 353 | } |
303 | 354 | } |
304 | 355 | |
305 | 356 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
307 | - else unset($timediff); |
|
357 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
358 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
359 | + } else { |
|
360 | + unset($timediff); |
|
361 | + } |
|
308 | 362 | if ($this->tmd > 5 || |
309 | 363 | !isset($timediff) || |
310 | 364 | $timediff > $globalLiveInterval || |
@@ -321,22 +375,32 @@ discard block |
||
321 | 375 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
322 | 376 | $this->all_tracked[$id]['putinarchive'] = true; |
323 | 377 | |
324 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
378 | + if ($globalDebug) { |
|
379 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
380 | + } |
|
325 | 381 | $timeelapsed = microtime(true); |
326 | 382 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
327 | 383 | $Marine = new Marine($this->db); |
328 | 384 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
329 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
385 | + if (!empty($all_country)) { |
|
386 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
387 | + } |
|
330 | 388 | $Marine->db = null; |
331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
389 | + if ($globalDebugTimeElapsed) { |
|
390 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
391 | + } |
|
332 | 392 | } |
333 | 393 | $this->tmd = 0; |
334 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
394 | + if ($globalDebug) { |
|
395 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
396 | + } |
|
335 | 397 | } |
336 | 398 | } |
337 | 399 | |
338 | 400 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
339 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
401 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
402 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
403 | + } |
|
340 | 404 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
341 | 405 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
342 | 406 | $dataFound = true; |
@@ -345,8 +409,12 @@ discard block |
||
345 | 409 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
346 | 410 | } |
347 | 411 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
348 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
349 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
412 | + if ($line['longitude'] > 180) { |
|
413 | + $line['longitude'] = $line['longitude'] - 360; |
|
414 | + } |
|
415 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
416 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
417 | + } |
|
350 | 418 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
351 | 419 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
352 | 420 | $dataFound = true; |
@@ -364,7 +432,9 @@ discard block |
||
364 | 432 | } |
365 | 433 | } |
366 | 434 | if (isset($line['last_update']) && $line['last_update'] != '') { |
367 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
435 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
436 | + $dataFound = true; |
|
437 | + } |
|
368 | 438 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
369 | 439 | } |
370 | 440 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -378,15 +448,21 @@ discard block |
||
378 | 448 | } |
379 | 449 | |
380 | 450 | if (isset($line['heading']) && $line['heading'] != '') { |
381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
451 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
452 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
453 | + } |
|
382 | 454 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
383 | 455 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
384 | 456 | //$dataFound = true; |
385 | 457 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
386 | 458 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
387 | 459 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
389 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
460 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
461 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
462 | + } |
|
463 | + if ($globalDebug) { |
|
464 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
465 | + } |
|
390 | 466 | } |
391 | 467 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
392 | 468 | |
@@ -398,28 +474,45 @@ discard block |
||
398 | 474 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
399 | 475 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
400 | 476 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
477 | + if ($globalDebug) { |
|
478 | + echo "Check if vessel is already in DB..."; |
|
479 | + } |
|
402 | 480 | $timeelapsed = microtime(true); |
403 | 481 | $MarineLive = new MarineLive($this->db); |
404 | 482 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
405 | 483 | $Marine = new Marine($this->db); |
406 | 484 | $recent_ident = $Marine->checkId($line['id']); |
407 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
485 | + if ($globalDebugTimeElapsed) { |
|
486 | + echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
487 | + } |
|
408 | 488 | $Marine->db=null; |
409 | 489 | } elseif (isset($line['id'])) { |
410 | 490 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
491 | + if ($globalDebugTimeElapsed) { |
|
492 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
493 | + } |
|
412 | 494 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
413 | 495 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
496 | + if ($globalDebugTimeElapsed) { |
|
497 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
498 | + } |
|
415 | 499 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
416 | 500 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
417 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
418 | - } else $recent_ident = ''; |
|
501 | + if ($globalDebugTimeElapsed) { |
|
502 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
503 | + } |
|
504 | + } else { |
|
505 | + $recent_ident = ''; |
|
506 | + } |
|
419 | 507 | $MarineLive->db=null; |
420 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
421 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
422 | - } else $recent_ident = ''; |
|
508 | + if ($globalDebug && $recent_ident == '') { |
|
509 | + echo " Not in DB.\n"; |
|
510 | + } elseif ($globalDebug && $recent_ident != '') { |
|
511 | + echo " Already in DB.\n"; |
|
512 | + } |
|
513 | + } else { |
|
514 | + $recent_ident = ''; |
|
515 | + } |
|
423 | 516 | } else { |
424 | 517 | $recent_ident = ''; |
425 | 518 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -428,32 +521,47 @@ discard block |
||
428 | 521 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
429 | 522 | { |
430 | 523 | if ($globalDebug) { |
431 | - if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
432 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
524 | + if ($this->all_tracked[$id]['mmsi'] == '') { |
|
525 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
526 | + } else { |
|
527 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
528 | + } |
|
433 | 529 | } |
434 | 530 | //adds the spotter data for the archive |
435 | 531 | $highlight = ''; |
436 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
532 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
533 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
534 | + } |
|
437 | 535 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
438 | 536 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
439 | 537 | $timeelapsed = microtime(true); |
440 | 538 | $Marine = new Marine($this->db); |
441 | 539 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
442 | 540 | $Marine->db = null; |
443 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
541 | + if ($globalDebug && isset($result)) { |
|
542 | + echo $result."\n"; |
|
543 | + } |
|
544 | + if ($globalDebugTimeElapsed) { |
|
545 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
546 | + } |
|
445 | 547 | } |
446 | 548 | } |
447 | 549 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
448 | 550 | // Add source stat in DB |
449 | 551 | $Stats = new Stats($this->db); |
450 | 552 | if (!empty($this->stats)) { |
451 | - if ($globalDebug) echo 'Add source stats : '; |
|
553 | + if ($globalDebug) { |
|
554 | + echo 'Add source stats : '; |
|
555 | + } |
|
452 | 556 | foreach($this->stats as $date => $data) { |
453 | 557 | foreach($data as $source => $sourced) { |
454 | 558 | //print_r($sourced); |
455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
559 | + if (isset($sourced['polar'])) { |
|
560 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
561 | + } |
|
562 | + if (isset($sourced['hist'])) { |
|
563 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
564 | + } |
|
457 | 565 | if (isset($sourced['msg'])) { |
458 | 566 | if (time() - $sourced['msg']['date'] > 10) { |
459 | 567 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -466,7 +574,9 @@ discard block |
||
466 | 574 | unset($this->stats[$date]); |
467 | 575 | } |
468 | 576 | } |
469 | - if ($globalDebug) echo 'Done'."\n"; |
|
577 | + if ($globalDebug) { |
|
578 | + echo 'Done'."\n"; |
|
579 | + } |
|
470 | 580 | } |
471 | 581 | $Stats->db = null; |
472 | 582 | } |
@@ -476,13 +586,17 @@ discard block |
||
476 | 586 | $this->all_tracked[$id]['addedMarine'] = 1; |
477 | 587 | //print_r($this->all_tracked[$id]); |
478 | 588 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
479 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
589 | + if ($globalDebug) { |
|
590 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
591 | + } |
|
480 | 592 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
481 | 593 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
482 | 594 | $MarineLive = new MarineLive($this->db); |
483 | 595 | $MarineLive->deleteLiveMarineData(); |
484 | 596 | $MarineLive->db=null; |
485 | - if ($globalDebug) echo " Done\n"; |
|
597 | + if ($globalDebug) { |
|
598 | + echo " Done\n"; |
|
599 | + } |
|
486 | 600 | } |
487 | 601 | $this->last_delete = time(); |
488 | 602 | } |
@@ -508,15 +622,21 @@ discard block |
||
508 | 622 | |
509 | 623 | if (!$ignoreImport) { |
510 | 624 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
511 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
625 | + if ($globalDebug) { |
|
626 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
627 | + } |
|
512 | 628 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
513 | 629 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
514 | 630 | $timeelapsed = microtime(true); |
515 | 631 | $MarineLive = new MarineLive($this->db); |
516 | 632 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
517 | 633 | $MarineLive->db = null; |
518 | - if ($globalDebug) echo $result."\n"; |
|
519 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
634 | + if ($globalDebug) { |
|
635 | + echo $result."\n"; |
|
636 | + } |
|
637 | + if ($globalDebugTimeElapsed) { |
|
638 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
639 | + } |
|
520 | 640 | } |
521 | 641 | } |
522 | 642 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -528,7 +648,9 @@ discard block |
||
528 | 648 | |
529 | 649 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
530 | 650 | $source = $this->all_tracked[$id]['source_name']; |
531 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
651 | + if ($source == '') { |
|
652 | + $source = $this->all_tracked[$id]['format_source']; |
|
653 | + } |
|
532 | 654 | if (!isset($this->source_location[$source])) { |
533 | 655 | $Location = new Source($this->db); |
534 | 656 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -549,7 +671,9 @@ discard block |
||
549 | 671 | $stats_heading = round($stats_heading/22.5); |
550 | 672 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
551 | 673 | $current_date = date('Y-m-d'); |
552 | - if ($stats_heading == 16) $stats_heading = 0; |
|
674 | + if ($stats_heading == 16) { |
|
675 | + $stats_heading = 0; |
|
676 | + } |
|
553 | 677 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
554 | 678 | for ($i=0;$i<=15;$i++) { |
555 | 679 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -567,7 +691,9 @@ discard block |
||
567 | 691 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
568 | 692 | end($this->stats[$current_date][$source]['hist']); |
569 | 693 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
570 | - } else $mini = 0; |
|
694 | + } else { |
|
695 | + $mini = 0; |
|
696 | + } |
|
571 | 697 | for ($i=$mini;$i<=$distance;$i+=10) { |
572 | 698 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
573 | 699 | } |
@@ -579,19 +705,27 @@ discard block |
||
579 | 705 | |
580 | 706 | |
581 | 707 | $this->all_tracked[$id]['lastupdate'] = time(); |
582 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
583 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
708 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
709 | + $send = true; |
|
710 | + } |
|
711 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
712 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
713 | + } |
|
584 | 714 | //$this->del(); |
585 | 715 | |
586 | 716 | |
587 | 717 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
588 | 718 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
589 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
719 | + if ($globalDebug) { |
|
720 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
721 | + } |
|
590 | 722 | $MarineLive = new MarineLive($this->db); |
591 | 723 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
592 | 724 | $MarineLive->db = null; |
593 | 725 | //MarineLive->deleteLiveMarineData(); |
594 | - if ($globalDebug) echo " Done\n"; |
|
726 | + if ($globalDebug) { |
|
727 | + echo " Done\n"; |
|
728 | + } |
|
595 | 729 | } |
596 | 730 | $this->last_delete_hourly = time(); |
597 | 731 | } |
@@ -600,7 +734,9 @@ discard block |
||
600 | 734 | //$ignoreImport = false; |
601 | 735 | } |
602 | 736 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
603 | - if ($send) return $this->all_tracked[$id]; |
|
737 | + if ($send) { |
|
738 | + return $this->all_tracked[$id]; |
|
739 | + } |
|
604 | 740 | } |
605 | 741 | } |
606 | 742 | } |