@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 53; |
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; |
@@ -192,6 +198,11 @@ discard block |
||
192 | 198 | /* |
193 | 199 | * Check if index exist |
194 | 200 | */ |
201 | + |
|
202 | + /** |
|
203 | + * @param string $table |
|
204 | + * @param string $index |
|
205 | + */ |
|
195 | 206 | public function indexExists($table,$index) |
196 | 207 | { |
197 | 208 | global $globalDBdriver, $globalDBname; |
@@ -234,6 +245,10 @@ discard block |
||
234 | 245 | return $columns; |
235 | 246 | } |
236 | 247 | |
248 | + /** |
|
249 | + * @param string $table |
|
250 | + * @param string $column |
|
251 | + */ |
|
237 | 252 | public function getColumnType($table,$column) { |
238 | 253 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
239 | 254 | $tomet = $select->getColumnMeta(0); |
@@ -244,6 +259,11 @@ discard block |
||
244 | 259 | * Check if a column name exist in a table |
245 | 260 | * @return Boolean column exist or not |
246 | 261 | */ |
262 | + |
|
263 | + /** |
|
264 | + * @param string $table |
|
265 | + * @param string $name |
|
266 | + */ |
|
247 | 267 | public function checkColumnName($table,$name) |
248 | 268 | { |
249 | 269 | 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 = 53; |
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); |
@@ -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 = '') |
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1006,10 +1006,10 @@ discard block |
||
1006 | 1006 | if ($typeid == '') $typeid = NULL; |
1007 | 1007 | if ($statusid == '') $statusid = NULL; |
1008 | 1008 | |
1009 | - //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1012 | - $query = ''; |
|
1009 | + //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1010 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1012 | + $query = ''; |
|
1013 | 1013 | if ($globalArchive) { |
1014 | 1014 | if ($globalDebug) echo '-- Delete previous data -- '; |
1015 | 1015 | $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 = '') |
|
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 = '') |
|
933 | 933 | { |
934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
935 | 935 | $Common = new Common(); |
@@ -981,33 +981,33 @@ 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 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
990 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
991 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
992 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
993 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
994 | - $typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
995 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
996 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
997 | - $statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
998 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
999 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1000 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
1001 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
1002 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
1003 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
1004 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
1005 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
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 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
990 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
991 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
992 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
993 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
994 | + $typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
995 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
996 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
997 | + $statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
998 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
999 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1000 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
1001 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
1002 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
1003 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
1004 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
1005 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
1006 | 1006 | if ($typeid == '') $typeid = NULL; |
1007 | 1007 | if ($statusid == '') $statusid = NULL; |
1008 | 1008 | |
1009 | 1009 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1010 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1011 | 1011 | if ($arrival_date == '') $arrival_date = NULL; |
1012 | 1012 | $query = ''; |
1013 | 1013 | if ($globalArchive) { |
@@ -1016,19 +1016,19 @@ discard block |
||
1016 | 1016 | } |
1017 | 1017 | $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) |
1018 | 1018 | 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)'; |
1019 | - $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); |
|
1019 | + $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); |
|
1020 | 1020 | try { |
1021 | 1021 | $sth = $this->db->prepare($query); |
1022 | 1022 | $sth->execute($query_values); |
1023 | 1023 | $sth->closeCursor(); |
1024 | - } catch(PDOException $e) { |
|
1024 | + } catch (PDOException $e) { |
|
1025 | 1025 | return "error : ".$e->getMessage(); |
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1029 | 1029 | if ($globalDebug) echo '(Add to Marine archive : '; |
1030 | 1030 | $MarineArchive = new MarineArchive($this->db); |
1031 | - $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); |
|
1031 | + $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); |
|
1032 | 1032 | if ($globalDebug) echo $result.')'; |
1033 | 1033 | } |
1034 | 1034 | return "success"; |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | public function getOrderBy() |
1038 | 1038 | { |
1039 | - $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")); |
|
1039 | + $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")); |
|
1040 | 1040 | return $orderby; |
1041 | 1041 | } |
1042 | 1042 |
@@ -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); |
@@ -1003,15 +1080,25 @@ discard block |
||
1003 | 1080 | $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
1004 | 1081 | $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
1005 | 1082 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
1006 | - if ($typeid == '') $typeid = NULL; |
|
1007 | - if ($statusid == '') $statusid = NULL; |
|
1083 | + if ($typeid == '') { |
|
1084 | + $typeid = NULL; |
|
1085 | + } |
|
1086 | + if ($statusid == '') { |
|
1087 | + $statusid = NULL; |
|
1088 | + } |
|
1008 | 1089 | |
1009 | 1090 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
1010 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1091 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1092 | + $heading = 0; |
|
1093 | + } |
|
1094 | + if ($arrival_date == '') { |
|
1095 | + $arrival_date = NULL; |
|
1096 | + } |
|
1012 | 1097 | $query = ''; |
1013 | 1098 | if ($globalArchive) { |
1014 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1099 | + if ($globalDebug) { |
|
1100 | + echo '-- Delete previous data -- '; |
|
1101 | + } |
|
1015 | 1102 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
1016 | 1103 | } |
1017 | 1104 | $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) |
@@ -1026,10 +1113,14 @@ discard block |
||
1026 | 1113 | } |
1027 | 1114 | |
1028 | 1115 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1029 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1116 | + if ($globalDebug) { |
|
1117 | + echo '(Add to Marine archive : '; |
|
1118 | + } |
|
1030 | 1119 | $MarineArchive = new MarineArchive($this->db); |
1031 | 1120 | $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); |
1032 | - if ($globalDebug) echo $result.')'; |
|
1121 | + if ($globalDebug) { |
|
1122 | + echo $result.')'; |
|
1123 | + } |
|
1033 | 1124 | } |
1034 | 1125 | return "success"; |
1035 | 1126 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -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(); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | } |
162 | 162 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
163 | 163 | |
164 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
164 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
165 | 165 | { |
166 | 166 | $Image = new Image($this->db); |
167 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
167 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
168 | 168 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
169 | 169 | unset($Image); |
170 | 170 | if (count($image_array) > 0) { |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | { |
201 | 201 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
202 | 202 | } else { |
203 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
203 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
204 | 204 | } |
205 | 205 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
206 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
207 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
206 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
207 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
208 | 208 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
209 | 209 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
210 | 210 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
211 | 211 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
212 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
213 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
212 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
213 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
214 | 214 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
215 | 215 | } |
216 | 216 | } |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | if ($limit != "") |
244 | 244 | { |
245 | 245 | $limit_array = explode(",", $limit); |
246 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
247 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
246 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
247 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
248 | 248 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
249 | 249 | { |
250 | 250 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | } else { |
259 | 259 | $orderby_query = " ORDER BY marine_output.date DESC"; |
260 | 260 | } |
261 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
262 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
261 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
262 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
263 | 263 | return $spotter_array; |
264 | 264 | } |
265 | 265 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | if ($id == '') return array(); |
278 | 278 | $additional_query = "marine_output.fammarine_id = :id"; |
279 | 279 | $query_values = array(':id' => $id); |
280 | - $query = $global_query." WHERE ".$additional_query." "; |
|
281 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
280 | + $query = $global_query." WHERE ".$additional_query." "; |
|
281 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
282 | 282 | return $spotter_array; |
283 | 283 | } |
284 | 284 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $query_values = array(); |
298 | 298 | $limit_query = ''; |
299 | 299 | $additional_query = ''; |
300 | - $filter_query = $this->getFilter($filter,true,true); |
|
300 | + $filter_query = $this->getFilter($filter, true, true); |
|
301 | 301 | if ($ident != "") |
302 | 302 | { |
303 | 303 | if (!is_string($ident)) |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | { |
314 | 314 | $limit_array = explode(",", $limit); |
315 | 315 | |
316 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
317 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
316 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
317 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
318 | 318 | |
319 | 319 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
320 | 320 | { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $query_values = array(); |
354 | 354 | $limit_query = ''; |
355 | 355 | $additional_query = ''; |
356 | - $filter_query = $this->getFilter($filter,true,true); |
|
356 | + $filter_query = $this->getFilter($filter, true, true); |
|
357 | 357 | if (!is_string($type)) |
358 | 358 | { |
359 | 359 | return false; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | { |
367 | 367 | $limit_array = explode(",", $limit); |
368 | 368 | |
369 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
370 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
369 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
370 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
371 | 371 | |
372 | 372 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
373 | 373 | { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | return $spotter_array; |
392 | 392 | } |
393 | 393 | |
394 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
394 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
395 | 395 | { |
396 | 396 | global $global_query, $globalTimezone, $globalDBdriver; |
397 | 397 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $limit_query = ''; |
400 | 400 | $additional_query = ''; |
401 | 401 | |
402 | - $filter_query = $this->getFilter($filter,true,true); |
|
402 | + $filter_query = $this->getFilter($filter, true, true); |
|
403 | 403 | |
404 | 404 | if ($date != "") |
405 | 405 | { |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | { |
426 | 426 | $limit_array = explode(",", $limit); |
427 | 427 | |
428 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
429 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
428 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
429 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
430 | 430 | |
431 | 431 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
432 | 432 | { |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | * @return Array list of source name |
458 | 458 | * |
459 | 459 | */ |
460 | - public function getAllSourceName($type = '',$filters = array()) |
|
460 | + public function getAllSourceName($type = '', $filters = array()) |
|
461 | 461 | { |
462 | - $filter_query = $this->getFilter($filters,true,true); |
|
462 | + $filter_query = $this->getFilter($filters, true, true); |
|
463 | 463 | $query_values = array(); |
464 | - $query = "SELECT DISTINCT marine_output.source_name |
|
464 | + $query = "SELECT DISTINCT marine_output.source_name |
|
465 | 465 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
466 | 466 | if ($type != '') { |
467 | 467 | $query_values = array(':type' => $type); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $source_array = array(); |
477 | 477 | $temp_array = array(); |
478 | 478 | |
479 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
479 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
480 | 480 | { |
481 | 481 | $temp_array['source_name'] = $row['source_name']; |
482 | 482 | $source_array[] = $temp_array; |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | */ |
494 | 494 | public function getAllIdents($filters = array()) |
495 | 495 | { |
496 | - $filter_query = $this->getFilter($filters,true,true); |
|
497 | - $query = "SELECT DISTINCT marine_output.ident |
|
496 | + $filter_query = $this->getFilter($filters, true, true); |
|
497 | + $query = "SELECT DISTINCT marine_output.ident |
|
498 | 498 | FROM marine_output".$filter_query." marine_output.ident <> '' |
499 | 499 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
500 | 500 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | $ident_array = array(); |
505 | 505 | $temp_array = array(); |
506 | 506 | |
507 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
507 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
508 | 508 | { |
509 | 509 | $temp_array['ident'] = $row['ident']; |
510 | 510 | $ident_array[] = $temp_array; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function getIdentity($mmsi) |
523 | 523 | { |
524 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
524 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
525 | 525 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
526 | 526 | $sth = $this->db->prepare($query); |
527 | 527 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -534,23 +534,23 @@ discard block |
||
534 | 534 | * Add identity |
535 | 535 | * |
536 | 536 | */ |
537 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
537 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
538 | 538 | { |
539 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
539 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
540 | 540 | if ($mmsi != '') { |
541 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
542 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
543 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
544 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
541 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
542 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
543 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
544 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
545 | 545 | $identinfo = $this->getIdentity($mmsi); |
546 | 546 | if (empty($identinfo)) { |
547 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
547 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
548 | 548 | $sth = $this->db->prepare($query); |
549 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
549 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
550 | 550 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
551 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
551 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
552 | 552 | $sth = $this->db->prepare($query); |
553 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
553 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | } |
@@ -571,12 +571,12 @@ discard block |
||
571 | 571 | } else $offset = '+00:00'; |
572 | 572 | |
573 | 573 | if ($globalDBdriver == 'mysql') { |
574 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
574 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
575 | 575 | FROM marine_output |
576 | 576 | WHERE marine_output.date <> '' |
577 | 577 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
578 | 578 | } else { |
579 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
579 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
580 | 580 | FROM marine_output |
581 | 581 | WHERE marine_output.date <> '' |
582 | 582 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $date_array = array(); |
589 | 589 | $temp_array = array(); |
590 | 590 | |
591 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
591 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
592 | 592 | { |
593 | 593 | $temp_array['date'] = $row['date']; |
594 | 594 | |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | * @return String success or false |
607 | 607 | * |
608 | 608 | */ |
609 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
609 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
610 | 610 | { |
611 | 611 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
612 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
612 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
613 | 613 | try { |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute($query_values); |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | * @return String success or false |
628 | 628 | * |
629 | 629 | */ |
630 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
630 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
631 | 631 | { |
632 | 632 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
633 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
633 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
634 | 634 | try { |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute($query_values); |
@@ -649,11 +649,11 @@ discard block |
||
649 | 649 | * @return String success or false |
650 | 650 | * |
651 | 651 | */ |
652 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
652 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
653 | 653 | { |
654 | 654 | |
655 | 655 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
656 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
656 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
657 | 657 | |
658 | 658 | try { |
659 | 659 | $sth = $this->db->prepare($query); |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
677 | 677 | { |
678 | 678 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
679 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
679 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
680 | 680 | |
681 | 681 | try { |
682 | 682 | $sth = $this->db->prepare($query); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param String $verticalrate vertival rate of flight |
715 | 715 | * @return String success or false |
716 | 716 | */ |
717 | - 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 = '') |
|
717 | + 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 = '') |
|
718 | 718 | { |
719 | 719 | global $globalURL, $globalMarineImageFetch; |
720 | 720 | |
@@ -781,36 +781,36 @@ discard block |
||
781 | 781 | } |
782 | 782 | |
783 | 783 | |
784 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
784 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
785 | 785 | { |
786 | 786 | $date = date("Y-m-d H:i:s", time()); |
787 | 787 | } |
788 | 788 | |
789 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
790 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
791 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
792 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
794 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
795 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
796 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
797 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
798 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
799 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
800 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
801 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
802 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
803 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
804 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
805 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
806 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
807 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
808 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
789 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
790 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
791 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
792 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
794 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
795 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
796 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
797 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
798 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
799 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
800 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
801 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
802 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
803 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
804 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
805 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
806 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
807 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
808 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
809 | 809 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
810 | 810 | $Image = new Image($this->db); |
811 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
811 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
812 | 812 | if (!isset($image_array[0]['mmsi'])) { |
813 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
813 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
814 | 814 | } |
815 | 815 | unset($Image); |
816 | 816 | } |
@@ -823,10 +823,10 @@ discard block |
||
823 | 823 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
824 | 824 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
825 | 825 | if ($arrival_date == '') $arrival_date = NULL; |
826 | - $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) |
|
826 | + $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) |
|
827 | 827 | 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)"; |
828 | 828 | |
829 | - $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); |
|
829 | + $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); |
|
830 | 830 | try { |
831 | 831 | $sth = $this->db->prepare($query); |
832 | 832 | $sth->execute($query_values); |
@@ -850,13 +850,13 @@ discard block |
||
850 | 850 | { |
851 | 851 | global $globalDBdriver, $globalTimezone; |
852 | 852 | if ($globalDBdriver == 'mysql') { |
853 | - $query = "SELECT marine_output.ident FROM marine_output |
|
853 | + $query = "SELECT marine_output.ident FROM marine_output |
|
854 | 854 | WHERE marine_output.ident = :ident |
855 | 855 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
856 | 856 | AND marine_output.date < UTC_TIMESTAMP()"; |
857 | 857 | $query_data = array(':ident' => $ident); |
858 | 858 | } else { |
859 | - $query = "SELECT marine_output.ident FROM marine_output |
|
859 | + $query = "SELECT marine_output.ident FROM marine_output |
|
860 | 860 | WHERE marine_output.ident = :ident |
861 | 861 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
862 | 862 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | |
866 | 866 | $sth = $this->db->prepare($query); |
867 | 867 | $sth->execute($query_data); |
868 | - $ident_result=''; |
|
869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
868 | + $ident_result = ''; |
|
869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
870 | 870 | { |
871 | 871 | $ident_result = $row['ident']; |
872 | 872 | } |
@@ -892,8 +892,8 @@ discard block |
||
892 | 892 | return false; |
893 | 893 | } else { |
894 | 894 | $q_array = explode(" ", $q); |
895 | - foreach ($q_array as $q_item){ |
|
896 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
895 | + foreach ($q_array as $q_item) { |
|
896 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
897 | 897 | $additional_query .= " AND ("; |
898 | 898 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
899 | 899 | $additional_query .= ")"; |
@@ -901,11 +901,11 @@ discard block |
||
901 | 901 | } |
902 | 902 | } |
903 | 903 | if ($globalDBdriver == 'mysql') { |
904 | - $query = "SELECT marine_output.* FROM marine_output |
|
904 | + $query = "SELECT marine_output.* FROM marine_output |
|
905 | 905 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
906 | 906 | AND marine_output.date < UTC_TIMESTAMP()"; |
907 | 907 | } else { |
908 | - $query = "SELECT marine_output.* FROM marine_output |
|
908 | + $query = "SELECT marine_output.* FROM marine_output |
|
909 | 909 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
910 | 910 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
911 | 911 | } |
@@ -924,16 +924,16 @@ discard block |
||
924 | 924 | * |
925 | 925 | */ |
926 | 926 | |
927 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
927 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
928 | 928 | { |
929 | 929 | global $globalDBdriver, $globalArchive; |
930 | 930 | //$filter_query = $this->getFilter($filters,true,true); |
931 | - $Connection= new Connection($this->db); |
|
931 | + $Connection = new Connection($this->db); |
|
932 | 932 | if (!$Connection->tableExists('countries')) return array(); |
933 | 933 | require_once('class.SpotterLive.php'); |
934 | 934 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
935 | 935 | $MarineLive = new MarineLive($this->db); |
936 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
936 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
937 | 937 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
938 | 938 | if ($olderthanmonths > 0) { |
939 | 939 | if ($globalDBdriver == 'mysql') { |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | } else { |
954 | 954 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
955 | 955 | $MarineArchive = new MarineArchive($this->db); |
956 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
956 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
957 | 957 | $filter_query .= " over_country <> ''"; |
958 | 958 | if ($olderthanmonths > 0) { |
959 | 959 | if ($globalDBdriver == 'mysql') { |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $flight_array = array(); |
982 | 982 | $temp_array = array(); |
983 | 983 | |
984 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
984 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
985 | 985 | { |
986 | 986 | $temp_array['marine_count'] = $row['nb']; |
987 | 987 | $temp_array['marine_country'] = $row['name']; |
@@ -1000,11 +1000,11 @@ discard block |
||
1000 | 1000 | * @return Array the callsign list |
1001 | 1001 | * |
1002 | 1002 | */ |
1003 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
1003 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1004 | 1004 | { |
1005 | 1005 | global $globalDBdriver; |
1006 | - $filter_query = $this->getFilter($filters,true,true); |
|
1007 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1006 | + $filter_query = $this->getFilter($filters, true, true); |
|
1007 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
1008 | 1008 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1009 | 1009 | if ($olderthanmonths > 0) { |
1010 | 1010 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1018,28 +1018,28 @@ discard block |
||
1018 | 1018 | if ($year != '') { |
1019 | 1019 | if ($globalDBdriver == 'mysql') { |
1020 | 1020 | $query .= " AND YEAR(marine_output.date) = :year"; |
1021 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1021 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1022 | 1022 | } else { |
1023 | 1023 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1024 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1024 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | if ($month != '') { |
1028 | 1028 | if ($globalDBdriver == 'mysql') { |
1029 | 1029 | $query .= " AND MONTH(marine_output.date) = :month"; |
1030 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1030 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1031 | 1031 | } else { |
1032 | 1032 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1033 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1033 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | if ($day != '') { |
1037 | 1037 | if ($globalDBdriver == 'mysql') { |
1038 | 1038 | $query .= " AND DAY(marine_output.date) = :day"; |
1039 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1039 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1040 | 1040 | } else { |
1041 | 1041 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1042 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1042 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1043 | 1043 | } |
1044 | 1044 | } |
1045 | 1045 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $callsign_array = array(); |
1052 | 1052 | $temp_array = array(); |
1053 | 1053 | |
1054 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1054 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1055 | 1055 | { |
1056 | 1056 | $temp_array['callsign_icao'] = $row['ident']; |
1057 | 1057 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $date_array = array(); |
1104 | 1104 | $temp_array = array(); |
1105 | 1105 | |
1106 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1106 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1107 | 1107 | { |
1108 | 1108 | $temp_array['date_name'] = $row['date_name']; |
1109 | 1109 | $temp_array['date_count'] = $row['date_count']; |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | $datetime = new DateTime(); |
1130 | 1130 | $offset = $datetime->format('P'); |
1131 | 1131 | } else $offset = '+00:00'; |
1132 | - $filter_query = $this->getFilter($filters,true,true); |
|
1132 | + $filter_query = $this->getFilter($filters, true, true); |
|
1133 | 1133 | if ($globalDBdriver == 'mysql') { |
1134 | 1134 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1135 | 1135 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | $date_array = array(); |
1151 | 1151 | $temp_array = array(); |
1152 | 1152 | |
1153 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1153 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1154 | 1154 | { |
1155 | 1155 | $temp_array['date_name'] = $row['date_name']; |
1156 | 1156 | $temp_array['date_count'] = $row['date_count']; |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | $datetime = new DateTime(); |
1176 | 1176 | $offset = $datetime->format('P'); |
1177 | 1177 | } else $offset = '+00:00'; |
1178 | - $filter_query = $this->getFilter($filters,true,true); |
|
1178 | + $filter_query = $this->getFilter($filters, true, true); |
|
1179 | 1179 | if ($globalDBdriver == 'mysql') { |
1180 | 1180 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1181 | 1181 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | $date_array = array(); |
1197 | 1197 | $temp_array = array(); |
1198 | 1198 | |
1199 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1199 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1200 | 1200 | { |
1201 | 1201 | $temp_array['date_name'] = $row['date_name']; |
1202 | 1202 | $temp_array['date_count'] = $row['date_count']; |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | $date_array = array(); |
1244 | 1244 | $temp_array = array(); |
1245 | 1245 | |
1246 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1246 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1247 | 1247 | { |
1248 | 1248 | $temp_array['month_name'] = $row['month_name']; |
1249 | 1249 | $temp_array['year_name'] = $row['year_name']; |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | $datetime = new DateTime(); |
1273 | 1273 | $offset = $datetime->format('P'); |
1274 | 1274 | } else $offset = '+00:00'; |
1275 | - $filter_query = $this->getFilter($filters,true,true); |
|
1275 | + $filter_query = $this->getFilter($filters, true, true); |
|
1276 | 1276 | if ($globalDBdriver == 'mysql') { |
1277 | 1277 | $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 |
1278 | 1278 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | $date_array = array(); |
1294 | 1294 | $temp_array = array(); |
1295 | 1295 | |
1296 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1296 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1297 | 1297 | { |
1298 | 1298 | $temp_array['year_name'] = $row['year_name']; |
1299 | 1299 | $temp_array['month_name'] = $row['month_name']; |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | * @return Array the hour list |
1314 | 1314 | * |
1315 | 1315 | */ |
1316 | - public function countAllHours($orderby,$filters = array()) |
|
1316 | + public function countAllHours($orderby, $filters = array()) |
|
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
1319 | 1319 | if ($globalTimezone != '') { |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | $hour_array = array(); |
1362 | 1362 | $temp_array = array(); |
1363 | 1363 | |
1364 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1364 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1365 | 1365 | { |
1366 | 1366 | $temp_array['hour_name'] = $row['hour_name']; |
1367 | 1367 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | public function countAllHoursByDate($date, $filters = array()) |
1384 | 1384 | { |
1385 | 1385 | global $globalTimezone, $globalDBdriver; |
1386 | - $filter_query = $this->getFilter($filters,true,true); |
|
1387 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1386 | + $filter_query = $this->getFilter($filters, true, true); |
|
1387 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1388 | 1388 | if ($globalTimezone != '') { |
1389 | 1389 | date_default_timezone_set($globalTimezone); |
1390 | 1390 | $datetime = new DateTime($date); |
@@ -1392,12 +1392,12 @@ discard block |
||
1392 | 1392 | } else $offset = '+00:00'; |
1393 | 1393 | |
1394 | 1394 | if ($globalDBdriver == 'mysql') { |
1395 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1395 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1396 | 1396 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1397 | 1397 | GROUP BY hour_name |
1398 | 1398 | ORDER BY hour_name ASC"; |
1399 | 1399 | } else { |
1400 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1400 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1401 | 1401 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1402 | 1402 | GROUP BY hour_name |
1403 | 1403 | ORDER BY hour_name ASC"; |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $hour_array = array(); |
1410 | 1410 | $temp_array = array(); |
1411 | 1411 | |
1412 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1412 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1413 | 1413 | { |
1414 | 1414 | $temp_array['hour_name'] = $row['hour_name']; |
1415 | 1415 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1431,8 +1431,8 @@ discard block |
||
1431 | 1431 | public function countAllHoursByIdent($ident, $filters = array()) |
1432 | 1432 | { |
1433 | 1433 | global $globalTimezone, $globalDBdriver; |
1434 | - $filter_query = $this->getFilter($filters,true,true); |
|
1435 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1434 | + $filter_query = $this->getFilter($filters, true, true); |
|
1435 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1436 | 1436 | if ($globalTimezone != '') { |
1437 | 1437 | date_default_timezone_set($globalTimezone); |
1438 | 1438 | $datetime = new DateTime(); |
@@ -1440,12 +1440,12 @@ discard block |
||
1440 | 1440 | } else $offset = '+00:00'; |
1441 | 1441 | |
1442 | 1442 | if ($globalDBdriver == 'mysql') { |
1443 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1443 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1444 | 1444 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1445 | 1445 | GROUP BY hour_name |
1446 | 1446 | ORDER BY hour_name ASC"; |
1447 | 1447 | } else { |
1448 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1448 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1449 | 1449 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1450 | 1450 | GROUP BY hour_name |
1451 | 1451 | ORDER BY hour_name ASC"; |
@@ -1453,12 +1453,12 @@ discard block |
||
1453 | 1453 | |
1454 | 1454 | |
1455 | 1455 | $sth = $this->db->prepare($query); |
1456 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1456 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1457 | 1457 | |
1458 | 1458 | $hour_array = array(); |
1459 | 1459 | $temp_array = array(); |
1460 | 1460 | |
1461 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1461 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1462 | 1462 | { |
1463 | 1463 | $temp_array['hour_name'] = $row['hour_name']; |
1464 | 1464 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1477,33 +1477,33 @@ discard block |
||
1477 | 1477 | * @return Integer the number of vessels |
1478 | 1478 | * |
1479 | 1479 | */ |
1480 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1480 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1481 | 1481 | { |
1482 | 1482 | global $globalDBdriver; |
1483 | 1483 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1484 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1484 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1485 | 1485 | $query_values = array(); |
1486 | 1486 | $query = ''; |
1487 | 1487 | if ($year != '') { |
1488 | 1488 | if ($globalDBdriver == 'mysql') { |
1489 | 1489 | $query .= " AND YEAR(marine_output.date) = :year"; |
1490 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1490 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1491 | 1491 | } else { |
1492 | 1492 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1493 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1493 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1494 | 1494 | } |
1495 | 1495 | } |
1496 | 1496 | if ($month != '') { |
1497 | 1497 | if ($globalDBdriver == 'mysql') { |
1498 | 1498 | $query .= " AND MONTH(marine_output.date) = :month"; |
1499 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1499 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1500 | 1500 | } else { |
1501 | 1501 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1502 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1502 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1503 | 1503 | } |
1504 | 1504 | } |
1505 | 1505 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1506 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1506 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1507 | 1507 | |
1508 | 1508 | $sth = $this->db->prepare($queryi); |
1509 | 1509 | $sth->execute($query_values); |
@@ -1516,32 +1516,32 @@ discard block |
||
1516 | 1516 | * @return Integer the number of vessels |
1517 | 1517 | * |
1518 | 1518 | */ |
1519 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1519 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1520 | 1520 | { |
1521 | 1521 | global $globalDBdriver; |
1522 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1522 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1523 | 1523 | $query_values = array(); |
1524 | 1524 | $query = ''; |
1525 | 1525 | if ($year != '') { |
1526 | 1526 | if ($globalDBdriver == 'mysql') { |
1527 | 1527 | $query .= " AND YEAR(marine_output.date) = :year"; |
1528 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1528 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1529 | 1529 | } else { |
1530 | 1530 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1531 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1531 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | if ($month != '') { |
1535 | 1535 | if ($globalDBdriver == 'mysql') { |
1536 | 1536 | $query .= " AND MONTH(marine_output.date) = :month"; |
1537 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1537 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1538 | 1538 | } else { |
1539 | 1539 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1540 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1540 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1544 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1544 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1545 | 1545 | |
1546 | 1546 | $sth = $this->db->prepare($queryi); |
1547 | 1547 | $sth->execute($query_values); |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | public function countAllHoursFromToday($filters = array()) |
1559 | 1559 | { |
1560 | 1560 | global $globalTimezone, $globalDBdriver; |
1561 | - $filter_query = $this->getFilter($filters,true,true); |
|
1561 | + $filter_query = $this->getFilter($filters, true, true); |
|
1562 | 1562 | if ($globalTimezone != '') { |
1563 | 1563 | date_default_timezone_set($globalTimezone); |
1564 | 1564 | $datetime = new DateTime(); |
@@ -1566,12 +1566,12 @@ discard block |
||
1566 | 1566 | } else $offset = '+00:00'; |
1567 | 1567 | |
1568 | 1568 | if ($globalDBdriver == 'mysql') { |
1569 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1569 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1570 | 1570 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1571 | 1571 | GROUP BY hour_name |
1572 | 1572 | ORDER BY hour_name ASC"; |
1573 | 1573 | } else { |
1574 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1574 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1575 | 1575 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1576 | 1576 | GROUP BY hour_name |
1577 | 1577 | ORDER BY hour_name ASC"; |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | $hour_array = array(); |
1584 | 1584 | $temp_array = array(); |
1585 | 1585 | |
1586 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1586 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1587 | 1587 | { |
1588 | 1588 | $temp_array['hour_name'] = $row['hour_name']; |
1589 | 1589 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1602,9 +1602,9 @@ discard block |
||
1602 | 1602 | */ |
1603 | 1603 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1604 | 1604 | { |
1605 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1605 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1606 | 1606 | |
1607 | - $query = "SELECT marine_output.marine_id |
|
1607 | + $query = "SELECT marine_output.marine_id |
|
1608 | 1608 | FROM marine_output |
1609 | 1609 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1610 | 1610 | |
@@ -1612,7 +1612,7 @@ discard block |
||
1612 | 1612 | $sth = $this->db->prepare($query); |
1613 | 1613 | $sth->execute(); |
1614 | 1614 | |
1615 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1615 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1616 | 1616 | { |
1617 | 1617 | return $row['marine_id']; |
1618 | 1618 | } |
@@ -1637,23 +1637,23 @@ discard block |
||
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | $current_date = date("Y-m-d H:i:s"); |
1640 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1640 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1641 | 1641 | |
1642 | 1642 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1643 | 1643 | |
1644 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1644 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1645 | 1645 | $years = $time_array['years']; |
1646 | 1646 | |
1647 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1647 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1648 | 1648 | $months = $time_array['months']; |
1649 | 1649 | |
1650 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1650 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1651 | 1651 | $days = $time_array['days']; |
1652 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1652 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1653 | 1653 | $hours = $time_array['hours']; |
1654 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1654 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1655 | 1655 | $minutes = $time_array['minutes']; |
1656 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1656 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1657 | 1657 | |
1658 | 1658 | return $time_array; |
1659 | 1659 | } |
@@ -1676,63 +1676,63 @@ discard block |
||
1676 | 1676 | $temp_array['direction_degree'] = $direction; |
1677 | 1677 | $temp_array['direction_shortname'] = "N"; |
1678 | 1678 | $temp_array['direction_fullname'] = "North"; |
1679 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1679 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1680 | 1680 | $temp_array['direction_degree'] = $direction; |
1681 | 1681 | $temp_array['direction_shortname'] = "NNE"; |
1682 | 1682 | $temp_array['direction_fullname'] = "North-Northeast"; |
1683 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1683 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1684 | 1684 | $temp_array['direction_degree'] = $direction; |
1685 | 1685 | $temp_array['direction_shortname'] = "NE"; |
1686 | 1686 | $temp_array['direction_fullname'] = "Northeast"; |
1687 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1687 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1688 | 1688 | $temp_array['direction_degree'] = $direction; |
1689 | 1689 | $temp_array['direction_shortname'] = "ENE"; |
1690 | 1690 | $temp_array['direction_fullname'] = "East-Northeast"; |
1691 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1691 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1692 | 1692 | $temp_array['direction_degree'] = $direction; |
1693 | 1693 | $temp_array['direction_shortname'] = "E"; |
1694 | 1694 | $temp_array['direction_fullname'] = "East"; |
1695 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1695 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1696 | 1696 | $temp_array['direction_degree'] = $direction; |
1697 | 1697 | $temp_array['direction_shortname'] = "ESE"; |
1698 | 1698 | $temp_array['direction_fullname'] = "East-Southeast"; |
1699 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1699 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1700 | 1700 | $temp_array['direction_degree'] = $direction; |
1701 | 1701 | $temp_array['direction_shortname'] = "SE"; |
1702 | 1702 | $temp_array['direction_fullname'] = "Southeast"; |
1703 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1703 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1704 | 1704 | $temp_array['direction_degree'] = $direction; |
1705 | 1705 | $temp_array['direction_shortname'] = "SSE"; |
1706 | 1706 | $temp_array['direction_fullname'] = "South-Southeast"; |
1707 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1707 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1708 | 1708 | $temp_array['direction_degree'] = $direction; |
1709 | 1709 | $temp_array['direction_shortname'] = "S"; |
1710 | 1710 | $temp_array['direction_fullname'] = "South"; |
1711 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1711 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1712 | 1712 | $temp_array['direction_degree'] = $direction; |
1713 | 1713 | $temp_array['direction_shortname'] = "SSW"; |
1714 | 1714 | $temp_array['direction_fullname'] = "South-Southwest"; |
1715 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1715 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1716 | 1716 | $temp_array['direction_degree'] = $direction; |
1717 | 1717 | $temp_array['direction_shortname'] = "SW"; |
1718 | 1718 | $temp_array['direction_fullname'] = "Southwest"; |
1719 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1719 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1720 | 1720 | $temp_array['direction_degree'] = $direction; |
1721 | 1721 | $temp_array['direction_shortname'] = "WSW"; |
1722 | 1722 | $temp_array['direction_fullname'] = "West-Southwest"; |
1723 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1723 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1724 | 1724 | $temp_array['direction_degree'] = $direction; |
1725 | 1725 | $temp_array['direction_shortname'] = "W"; |
1726 | 1726 | $temp_array['direction_fullname'] = "West"; |
1727 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1727 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1728 | 1728 | $temp_array['direction_degree'] = $direction; |
1729 | 1729 | $temp_array['direction_shortname'] = "WNW"; |
1730 | 1730 | $temp_array['direction_fullname'] = "West-Northwest"; |
1731 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1731 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1732 | 1732 | $temp_array['direction_degree'] = $direction; |
1733 | 1733 | $temp_array['direction_shortname'] = "NW"; |
1734 | 1734 | $temp_array['direction_fullname'] = "Northwest"; |
1735 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1735 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1736 | 1736 | $temp_array['direction_degree'] = $direction; |
1737 | 1737 | $temp_array['direction_shortname'] = "NNW"; |
1738 | 1738 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1749,11 +1749,11 @@ discard block |
||
1749 | 1749 | * @param Float $longitude longitute of the flight |
1750 | 1750 | * @return String the countrie |
1751 | 1751 | */ |
1752 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1752 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1753 | 1753 | { |
1754 | 1754 | global $globalDBdriver, $globalDebug; |
1755 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1756 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1755 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1756 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1757 | 1757 | |
1758 | 1758 | $Connection = new Connection($this->db); |
1759 | 1759 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | public function getCountryFromISO2($iso2) |
1794 | 1794 | { |
1795 | 1795 | global $globalDBdriver, $globalDebug; |
1796 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1796 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1797 | 1797 | |
1798 | 1798 | $Connection = new Connection($this->db); |
1799 | 1799 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1841,7 +1841,7 @@ discard block |
||
1841 | 1841 | |
1842 | 1842 | $bitly_data = json_decode($bitly_data); |
1843 | 1843 | $bitly_url = ''; |
1844 | - if ($bitly_data->status_txt = "OK"){ |
|
1844 | + if ($bitly_data->status_txt = "OK") { |
|
1845 | 1845 | $bitly_url = $bitly_data->data->url; |
1846 | 1846 | } |
1847 | 1847 | |
@@ -1855,11 +1855,11 @@ discard block |
||
1855 | 1855 | * @return Array the vessel type list |
1856 | 1856 | * |
1857 | 1857 | */ |
1858 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1858 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1859 | 1859 | { |
1860 | 1860 | global $globalDBdriver; |
1861 | - $filter_query = $this->getFilter($filters,true,true); |
|
1862 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1861 | + $filter_query = $this->getFilter($filters, true, true); |
|
1862 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
1863 | 1863 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
1864 | 1864 | if ($olderthanmonths > 0) { |
1865 | 1865 | if ($globalDBdriver == 'mysql') { |
@@ -1879,28 +1879,28 @@ discard block |
||
1879 | 1879 | if ($year != '') { |
1880 | 1880 | if ($globalDBdriver == 'mysql') { |
1881 | 1881 | $query .= " AND YEAR(marine_output.date) = :year"; |
1882 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1882 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1883 | 1883 | } else { |
1884 | 1884 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1885 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1885 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1886 | 1886 | } |
1887 | 1887 | } |
1888 | 1888 | if ($month != '') { |
1889 | 1889 | if ($globalDBdriver == 'mysql') { |
1890 | 1890 | $query .= " AND MONTH(marine_output.date) = :month"; |
1891 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1891 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1892 | 1892 | } else { |
1893 | 1893 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1894 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1894 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1895 | 1895 | } |
1896 | 1896 | } |
1897 | 1897 | if ($day != '') { |
1898 | 1898 | if ($globalDBdriver == 'mysql') { |
1899 | 1899 | $query .= " AND DAY(marine_output.date) = :day"; |
1900 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1900 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1901 | 1901 | } else { |
1902 | 1902 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1903 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1903 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1904 | 1904 | } |
1905 | 1905 | } |
1906 | 1906 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -1909,7 +1909,7 @@ discard block |
||
1909 | 1909 | $sth->execute($query_values); |
1910 | 1910 | $marine_array = array(); |
1911 | 1911 | $temp_array = array(); |
1912 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1912 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1913 | 1913 | { |
1914 | 1914 | $temp_array['marine_type'] = $row['marine_type']; |
1915 | 1915 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -1925,13 +1925,13 @@ discard block |
||
1925 | 1925 | * @return Array the tracker information |
1926 | 1926 | * |
1927 | 1927 | */ |
1928 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1928 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1929 | 1929 | { |
1930 | 1930 | global $globalTimezone, $globalDBdriver; |
1931 | 1931 | date_default_timezone_set('UTC'); |
1932 | 1932 | $query_values = array(); |
1933 | 1933 | $additional_query = ''; |
1934 | - $filter_query = $this->getFilter($filters,true,true); |
|
1934 | + $filter_query = $this->getFilter($filters, true, true); |
|
1935 | 1935 | if ($q != "") |
1936 | 1936 | { |
1937 | 1937 | if (!is_string($q)) |
@@ -1939,8 +1939,8 @@ discard block |
||
1939 | 1939 | return false; |
1940 | 1940 | } else { |
1941 | 1941 | $q_array = explode(" ", $q); |
1942 | - foreach ($q_array as $q_item){ |
|
1943 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1942 | + foreach ($q_array as $q_item) { |
|
1943 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1944 | 1944 | $additional_query .= " AND ("; |
1945 | 1945 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
1946 | 1946 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1952,42 +1952,42 @@ discard block |
||
1952 | 1952 | } |
1953 | 1953 | if ($callsign != "") |
1954 | 1954 | { |
1955 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1955 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1956 | 1956 | if (!is_string($callsign)) |
1957 | 1957 | { |
1958 | 1958 | return false; |
1959 | 1959 | } else { |
1960 | 1960 | $additional_query .= " AND marine_output.ident = :callsign"; |
1961 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1961 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1962 | 1962 | } |
1963 | 1963 | } |
1964 | 1964 | if ($mmsi != "") |
1965 | 1965 | { |
1966 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1966 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1967 | 1967 | if (!is_numeric($mmsi)) |
1968 | 1968 | { |
1969 | 1969 | return false; |
1970 | 1970 | } else { |
1971 | 1971 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
1972 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
1972 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
1973 | 1973 | } |
1974 | 1974 | } |
1975 | 1975 | if ($imo != "") |
1976 | 1976 | { |
1977 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1977 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1978 | 1978 | if (!is_numeric($imo)) |
1979 | 1979 | { |
1980 | 1980 | return false; |
1981 | 1981 | } else { |
1982 | 1982 | $additional_query .= " AND marine_output.imo = :imo"; |
1983 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
1983 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
1984 | 1984 | } |
1985 | 1985 | } |
1986 | 1986 | if ($date_posted != "") |
1987 | 1987 | { |
1988 | 1988 | $date_array = explode(",", $date_posted); |
1989 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1990 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1989 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1990 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1991 | 1991 | if ($globalTimezone != '') { |
1992 | 1992 | date_default_timezone_set($globalTimezone); |
1993 | 1993 | $datetime = new DateTime(); |
@@ -2014,8 +2014,8 @@ discard block |
||
2014 | 2014 | if ($limit != "") |
2015 | 2015 | { |
2016 | 2016 | $limit_array = explode(",", $limit); |
2017 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
2018 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
2017 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
2018 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
2019 | 2019 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2020 | 2020 | { |
2021 | 2021 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2033,28 +2033,28 @@ discard block |
||
2033 | 2033 | } |
2034 | 2034 | } |
2035 | 2035 | if ($origLat != "" && $origLon != "" && $dist != "") { |
2036 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
2036 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
2037 | 2037 | if ($globalDBdriver == 'mysql') { |
2038 | - $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 |
|
2038 | + $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 |
|
2039 | 2039 | 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)) |
2040 | 2040 | 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; |
2041 | 2041 | } else { |
2042 | - $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 |
|
2042 | + $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 |
|
2043 | 2043 | 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)) |
2044 | 2044 | 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; |
2045 | 2045 | } |
2046 | 2046 | } else { |
2047 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2047 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
2048 | 2048 | ".$additional_query." |
2049 | 2049 | ".$orderby_query; |
2050 | 2050 | } |
2051 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
2051 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
2052 | 2052 | return $marine_array; |
2053 | 2053 | } |
2054 | 2054 | |
2055 | 2055 | public function getOrderBy() |
2056 | 2056 | { |
2057 | - $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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
2057 | + $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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
2058 | 2058 | |
2059 | 2059 | return $orderby; |
2060 | 2060 |
@@ -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,39 +140,75 @@ 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['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['format_source'])) { |
|
191 | + $temp_array['format_source'] = $row['format_source']; |
|
192 | + } |
|
157 | 193 | if (isset($row['heading'])) { |
158 | 194 | $temp_array['heading'] = $row['heading']; |
159 | 195 | $heading_direction = $this->parseDirection($row['heading']); |
160 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
196 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
197 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
198 | + } |
|
199 | + } |
|
200 | + if (isset($row['ground_speed'])) { |
|
201 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
161 | 202 | } |
162 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
163 | 203 | |
164 | 204 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
165 | 205 | { |
166 | 206 | $Image = new Image($this->db); |
167 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
168 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
207 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
208 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
209 | + } else { |
|
210 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
211 | + } |
|
169 | 212 | unset($Image); |
170 | 213 | if (count($image_array) > 0) { |
171 | 214 | $temp_array['image'] = $image_array[0]['image']; |
@@ -217,13 +260,21 @@ discard block |
||
217 | 260 | } |
218 | 261 | |
219 | 262 | $fromsource = NULL; |
220 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
221 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
222 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
263 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
264 | + $temp_array['source_name'] = $row['source_name']; |
|
265 | + } |
|
266 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
267 | + $temp_array['over_country'] = $row['over_country']; |
|
268 | + } |
|
269 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
270 | + $temp_array['distance'] = $row['distance']; |
|
271 | + } |
|
223 | 272 | $temp_array['query_number_rows'] = $num_rows; |
224 | 273 | $spotter_array[] = $temp_array; |
225 | 274 | } |
226 | - if ($num_rows == 0) return array(); |
|
275 | + if ($num_rows == 0) { |
|
276 | + return array(); |
|
277 | + } |
|
227 | 278 | $spotter_array[0]['query_number_rows'] = $num_rows; |
228 | 279 | return $spotter_array; |
229 | 280 | } |
@@ -249,8 +300,12 @@ discard block |
||
249 | 300 | { |
250 | 301 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
251 | 302 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
252 | - } else $limit_query = ""; |
|
253 | - } else $limit_query = ""; |
|
303 | + } else { |
|
304 | + $limit_query = ""; |
|
305 | + } |
|
306 | + } else { |
|
307 | + $limit_query = ""; |
|
308 | + } |
|
254 | 309 | if ($sort != "") |
255 | 310 | { |
256 | 311 | $search_orderby_array = $this->getOrderBy(); |
@@ -274,7 +329,9 @@ discard block |
||
274 | 329 | global $global_query; |
275 | 330 | |
276 | 331 | date_default_timezone_set('UTC'); |
277 | - if ($id == '') return array(); |
|
332 | + if ($id == '') { |
|
333 | + return array(); |
|
334 | + } |
|
278 | 335 | $additional_query = "marine_output.fammarine_id = :id"; |
279 | 336 | $query_values = array(':id' => $id); |
280 | 337 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -470,8 +527,11 @@ discard block |
||
470 | 527 | $query .= " ORDER BY marine_output.source_name ASC"; |
471 | 528 | |
472 | 529 | $sth = $this->db->prepare($query); |
473 | - if (!empty($query_values)) $sth->execute($query_values); |
|
474 | - else $sth->execute(); |
|
530 | + if (!empty($query_values)) { |
|
531 | + $sth->execute($query_values); |
|
532 | + } else { |
|
533 | + $sth->execute(); |
|
534 | + } |
|
475 | 535 | |
476 | 536 | $source_array = array(); |
477 | 537 | $temp_array = array(); |
@@ -526,8 +586,11 @@ discard block |
||
526 | 586 | $sth = $this->db->prepare($query); |
527 | 587 | $sth->execute(array(':mmsi' => $mmsi)); |
528 | 588 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
529 | - if (isset($result[0])) return $result[0]; |
|
530 | - else return array(); |
|
589 | + if (isset($result[0])) { |
|
590 | + return $result[0]; |
|
591 | + } else { |
|
592 | + return array(); |
|
593 | + } |
|
531 | 594 | } |
532 | 595 | |
533 | 596 | /** |
@@ -568,7 +631,9 @@ discard block |
||
568 | 631 | date_default_timezone_set($globalTimezone); |
569 | 632 | $datetime = new DateTime(); |
570 | 633 | $offset = $datetime->format('P'); |
571 | - } else $offset = '+00:00'; |
|
634 | + } else { |
|
635 | + $offset = '+00:00'; |
|
636 | + } |
|
572 | 637 | |
573 | 638 | if ($globalDBdriver == 'mysql') { |
574 | 639 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -818,11 +883,19 @@ discard block |
||
818 | 883 | $latitude = 0; |
819 | 884 | $longitude = 0; |
820 | 885 | } |
821 | - if ($type_id == '') $type_id = NULL; |
|
822 | - if ($status_id == '') $status_id = NULL; |
|
823 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
886 | + if ($type_id == '') { |
|
887 | + $type_id = NULL; |
|
888 | + } |
|
889 | + if ($status_id == '') { |
|
890 | + $status_id = NULL; |
|
891 | + } |
|
892 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
893 | + $heading = 0; |
|
894 | + } |
|
824 | 895 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
825 | - if ($arrival_date == '') $arrival_date = NULL; |
|
896 | + if ($arrival_date == '') { |
|
897 | + $arrival_date = NULL; |
|
898 | + } |
|
826 | 899 | $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) |
827 | 900 | 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)"; |
828 | 901 | |
@@ -929,7 +1002,9 @@ discard block |
||
929 | 1002 | global $globalDBdriver, $globalArchive; |
930 | 1003 | //$filter_query = $this->getFilter($filters,true,true); |
931 | 1004 | $Connection= new Connection($this->db); |
932 | - if (!$Connection->tableExists('countries')) return array(); |
|
1005 | + if (!$Connection->tableExists('countries')) { |
|
1006 | + return array(); |
|
1007 | + } |
|
933 | 1008 | require_once('class.SpotterLive.php'); |
934 | 1009 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
935 | 1010 | $MarineLive = new MarineLive($this->db); |
@@ -973,7 +1048,9 @@ discard block |
||
973 | 1048 | $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 "; |
974 | 1049 | } |
975 | 1050 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
976 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1051 | + if ($limit) { |
|
1052 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1053 | + } |
|
977 | 1054 | |
978 | 1055 | $sth = $this->db->prepare($query); |
979 | 1056 | $sth->execute(); |
@@ -1007,12 +1084,18 @@ discard block |
||
1007 | 1084 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
1008 | 1085 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
1009 | 1086 | if ($olderthanmonths > 0) { |
1010 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1011 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1087 | + if ($globalDBdriver == 'mysql') { |
|
1088 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1089 | + } else { |
|
1090 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1091 | + } |
|
1012 | 1092 | } |
1013 | 1093 | if ($sincedate != '') { |
1014 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1015 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1094 | + if ($globalDBdriver == 'mysql') { |
|
1095 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1096 | + } else { |
|
1097 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1098 | + } |
|
1016 | 1099 | } |
1017 | 1100 | $query_values = array(); |
1018 | 1101 | if ($year != '') { |
@@ -1043,7 +1126,9 @@ discard block |
||
1043 | 1126 | } |
1044 | 1127 | } |
1045 | 1128 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1046 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1129 | + if ($limit) { |
|
1130 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1131 | + } |
|
1047 | 1132 | |
1048 | 1133 | $sth = $this->db->prepare($query); |
1049 | 1134 | $sth->execute($query_values); |
@@ -1078,7 +1163,9 @@ discard block |
||
1078 | 1163 | date_default_timezone_set($globalTimezone); |
1079 | 1164 | $datetime = new DateTime(); |
1080 | 1165 | $offset = $datetime->format('P'); |
1081 | - } else $offset = '+00:00'; |
|
1166 | + } else { |
|
1167 | + $offset = '+00:00'; |
|
1168 | + } |
|
1082 | 1169 | |
1083 | 1170 | if ($globalDBdriver == 'mysql') { |
1084 | 1171 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1128,7 +1215,9 @@ discard block |
||
1128 | 1215 | date_default_timezone_set($globalTimezone); |
1129 | 1216 | $datetime = new DateTime(); |
1130 | 1217 | $offset = $datetime->format('P'); |
1131 | - } else $offset = '+00:00'; |
|
1218 | + } else { |
|
1219 | + $offset = '+00:00'; |
|
1220 | + } |
|
1132 | 1221 | $filter_query = $this->getFilter($filters,true,true); |
1133 | 1222 | if ($globalDBdriver == 'mysql') { |
1134 | 1223 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1174,7 +1263,9 @@ discard block |
||
1174 | 1263 | date_default_timezone_set($globalTimezone); |
1175 | 1264 | $datetime = new DateTime(); |
1176 | 1265 | $offset = $datetime->format('P'); |
1177 | - } else $offset = '+00:00'; |
|
1266 | + } else { |
|
1267 | + $offset = '+00:00'; |
|
1268 | + } |
|
1178 | 1269 | $filter_query = $this->getFilter($filters,true,true); |
1179 | 1270 | if ($globalDBdriver == 'mysql') { |
1180 | 1271 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1222,7 +1313,9 @@ discard block |
||
1222 | 1313 | date_default_timezone_set($globalTimezone); |
1223 | 1314 | $datetime = new DateTime(); |
1224 | 1315 | $offset = $datetime->format('P'); |
1225 | - } else $offset = '+00:00'; |
|
1316 | + } else { |
|
1317 | + $offset = '+00:00'; |
|
1318 | + } |
|
1226 | 1319 | |
1227 | 1320 | if ($globalDBdriver == 'mysql') { |
1228 | 1321 | $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 |
@@ -1271,7 +1364,9 @@ discard block |
||
1271 | 1364 | date_default_timezone_set($globalTimezone); |
1272 | 1365 | $datetime = new DateTime(); |
1273 | 1366 | $offset = $datetime->format('P'); |
1274 | - } else $offset = '+00:00'; |
|
1367 | + } else { |
|
1368 | + $offset = '+00:00'; |
|
1369 | + } |
|
1275 | 1370 | $filter_query = $this->getFilter($filters,true,true); |
1276 | 1371 | if ($globalDBdriver == 'mysql') { |
1277 | 1372 | $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 |
@@ -1320,7 +1415,9 @@ discard block |
||
1320 | 1415 | date_default_timezone_set($globalTimezone); |
1321 | 1416 | $datetime = new DateTime(); |
1322 | 1417 | $offset = $datetime->format('P'); |
1323 | - } else $offset = '+00:00'; |
|
1418 | + } else { |
|
1419 | + $offset = '+00:00'; |
|
1420 | + } |
|
1324 | 1421 | |
1325 | 1422 | $orderby_sql = ''; |
1326 | 1423 | if ($orderby == "hour") |
@@ -1389,7 +1486,9 @@ discard block |
||
1389 | 1486 | date_default_timezone_set($globalTimezone); |
1390 | 1487 | $datetime = new DateTime($date); |
1391 | 1488 | $offset = $datetime->format('P'); |
1392 | - } else $offset = '+00:00'; |
|
1489 | + } else { |
|
1490 | + $offset = '+00:00'; |
|
1491 | + } |
|
1393 | 1492 | |
1394 | 1493 | if ($globalDBdriver == 'mysql') { |
1395 | 1494 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1437,7 +1536,9 @@ discard block |
||
1437 | 1536 | date_default_timezone_set($globalTimezone); |
1438 | 1537 | $datetime = new DateTime(); |
1439 | 1538 | $offset = $datetime->format('P'); |
1440 | - } else $offset = '+00:00'; |
|
1539 | + } else { |
|
1540 | + $offset = '+00:00'; |
|
1541 | + } |
|
1441 | 1542 | |
1442 | 1543 | if ($globalDBdriver == 'mysql') { |
1443 | 1544 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1502,8 +1603,11 @@ discard block |
||
1502 | 1603 | $query_values = array_merge($query_values,array(':month' => $month)); |
1503 | 1604 | } |
1504 | 1605 | } |
1505 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1506 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1606 | + if (empty($query_values)) { |
|
1607 | + $queryi .= $this->getFilter($filters); |
|
1608 | + } else { |
|
1609 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1610 | + } |
|
1507 | 1611 | |
1508 | 1612 | $sth = $this->db->prepare($queryi); |
1509 | 1613 | $sth->execute($query_values); |
@@ -1540,8 +1644,11 @@ discard block |
||
1540 | 1644 | $query_values = array_merge($query_values,array(':month' => $month)); |
1541 | 1645 | } |
1542 | 1646 | } |
1543 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1544 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1647 | + if (empty($query_values)) { |
|
1648 | + $queryi .= $this->getFilter($filters); |
|
1649 | + } else { |
|
1650 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1651 | + } |
|
1545 | 1652 | |
1546 | 1653 | $sth = $this->db->prepare($queryi); |
1547 | 1654 | $sth->execute($query_values); |
@@ -1563,7 +1670,9 @@ discard block |
||
1563 | 1670 | date_default_timezone_set($globalTimezone); |
1564 | 1671 | $datetime = new DateTime(); |
1565 | 1672 | $offset = $datetime->format('P'); |
1566 | - } else $offset = '+00:00'; |
|
1673 | + } else { |
|
1674 | + $offset = '+00:00'; |
|
1675 | + } |
|
1567 | 1676 | |
1568 | 1677 | if ($globalDBdriver == 'mysql') { |
1569 | 1678 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1667,7 +1776,9 @@ discard block |
||
1667 | 1776 | */ |
1668 | 1777 | public function parseDirection($direction = 0) |
1669 | 1778 | { |
1670 | - if ($direction == '') $direction = 0; |
|
1779 | + if ($direction == '') { |
|
1780 | + $direction = 0; |
|
1781 | + } |
|
1671 | 1782 | $direction_array = array(); |
1672 | 1783 | $temp_array = array(); |
1673 | 1784 | |
@@ -1756,7 +1867,9 @@ discard block |
||
1756 | 1867 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1757 | 1868 | |
1758 | 1869 | $Connection = new Connection($this->db); |
1759 | - if (!$Connection->tableExists('countries')) return ''; |
|
1870 | + if (!$Connection->tableExists('countries')) { |
|
1871 | + return ''; |
|
1872 | + } |
|
1760 | 1873 | |
1761 | 1874 | try { |
1762 | 1875 | /* |
@@ -1776,9 +1889,13 @@ discard block |
||
1776 | 1889 | $sth->closeCursor(); |
1777 | 1890 | if (count($row) > 0) { |
1778 | 1891 | return $row; |
1779 | - } else return ''; |
|
1892 | + } else { |
|
1893 | + return ''; |
|
1894 | + } |
|
1780 | 1895 | } catch (PDOException $e) { |
1781 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1896 | + if (isset($globalDebug) && $globalDebug) { |
|
1897 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1898 | + } |
|
1782 | 1899 | return ''; |
1783 | 1900 | } |
1784 | 1901 | |
@@ -1796,7 +1913,9 @@ discard block |
||
1796 | 1913 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1797 | 1914 | |
1798 | 1915 | $Connection = new Connection($this->db); |
1799 | - if (!$Connection->tableExists('countries')) return ''; |
|
1916 | + if (!$Connection->tableExists('countries')) { |
|
1917 | + return ''; |
|
1918 | + } |
|
1800 | 1919 | |
1801 | 1920 | try { |
1802 | 1921 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1808,9 +1927,13 @@ discard block |
||
1808 | 1927 | $sth->closeCursor(); |
1809 | 1928 | if (count($row) > 0) { |
1810 | 1929 | return $row; |
1811 | - } else return ''; |
|
1930 | + } else { |
|
1931 | + return ''; |
|
1932 | + } |
|
1812 | 1933 | } catch (PDOException $e) { |
1813 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1934 | + if (isset($globalDebug) && $globalDebug) { |
|
1935 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1936 | + } |
|
1814 | 1937 | return ''; |
1815 | 1938 | } |
1816 | 1939 | |
@@ -1828,7 +1951,9 @@ discard block |
||
1828 | 1951 | { |
1829 | 1952 | global $globalBitlyAccessToken; |
1830 | 1953 | |
1831 | - if ($globalBitlyAccessToken == '') return $url; |
|
1954 | + if ($globalBitlyAccessToken == '') { |
|
1955 | + return $url; |
|
1956 | + } |
|
1832 | 1957 | |
1833 | 1958 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1834 | 1959 | |
@@ -1904,7 +2029,9 @@ discard block |
||
1904 | 2029 | } |
1905 | 2030 | } |
1906 | 2031 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
1907 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2032 | + if ($limit) { |
|
2033 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2034 | + } |
|
1908 | 2035 | $sth = $this->db->prepare($query); |
1909 | 2036 | $sth->execute($query_values); |
1910 | 2037 | $marine_array = array(); |
@@ -1942,9 +2069,15 @@ discard block |
||
1942 | 2069 | foreach ($q_array as $q_item){ |
1943 | 2070 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1944 | 2071 | $additional_query .= " AND ("; |
1945 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1946 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1947 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2072 | + if (is_int($q_item)) { |
|
2073 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2074 | + } |
|
2075 | + if (is_int($q_item)) { |
|
2076 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2077 | + } |
|
2078 | + if (is_int($q_item)) { |
|
2079 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2080 | + } |
|
1948 | 2081 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1949 | 2082 | $additional_query .= ")"; |
1950 | 2083 | } |
@@ -1992,7 +2125,9 @@ discard block |
||
1992 | 2125 | date_default_timezone_set($globalTimezone); |
1993 | 2126 | $datetime = new DateTime(); |
1994 | 2127 | $offset = $datetime->format('P'); |
1995 | - } else $offset = '+00:00'; |
|
2128 | + } else { |
|
2129 | + $offset = '+00:00'; |
|
2130 | + } |
|
1996 | 2131 | if ($date_array[1] != "") |
1997 | 2132 | { |
1998 | 2133 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2019,8 +2154,12 @@ discard block |
||
2019 | 2154 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2020 | 2155 | { |
2021 | 2156 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2022 | - } else $limit_query = ""; |
|
2023 | - } else $limit_query = ""; |
|
2157 | + } else { |
|
2158 | + $limit_query = ""; |
|
2159 | + } |
|
2160 | + } else { |
|
2161 | + $limit_query = ""; |
|
2162 | + } |
|
2024 | 2163 | if ($sort != "") |
2025 | 2164 | { |
2026 | 2165 | $search_orderby_array = $this->getOrderBy(); |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime); |
|
17 | 17 | |
18 | 18 | if (empty($spotter_array)) { |
19 | 19 | $from_archive = true; |
20 | - $spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident,$currenttime); |
|
20 | + $spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident, $currenttime); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } else { |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | if (isset($_GET['fammarine_id'])) { |
34 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
34 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING); |
|
35 | 35 | if (isset($_GET['currenttime'])) { |
36 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
36 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
37 | 37 | $currenttime = round($currenttime/1000); |
38 | - $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime); |
|
38 | + $spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime); |
|
39 | 39 | |
40 | 40 | if (empty($spotter_array)) { |
41 | 41 | $from_archive = true; |
42 | 42 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
43 | - $spotter_array = $MarineArchive->getDateArchiveMarineDataById($fammarine_id,$currenttime); |
|
43 | + $spotter_array = $MarineArchive->getDateArchiveMarineDataById($fammarine_id, $currenttime); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } else { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
63 | 63 | { |
64 | 64 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
65 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
65 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
66 | 66 | } else $image = $spotter_item['image_thumbnail']; |
67 | 67 | |
68 | 68 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | */ |
91 | 91 | print '<div><span>'._("Speed").'</span>'; |
92 | 92 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
93 | - print round($spotter_item['ground_speed']*0.621371,2).' mph'; |
|
93 | + print round($spotter_item['ground_speed']*0.621371, 2).' mph'; |
|
94 | 94 | } elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) { |
95 | - print round($spotter_item['ground_speed']*0.539957,2).' knots'; |
|
95 | + print round($spotter_item['ground_speed']*0.539957, 2).' knots'; |
|
96 | 96 | } else { |
97 | 97 | print $spotter_item['ground_speed'].' km/h'; |
98 | 98 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -814,17 +814,17 @@ discard block |
||
814 | 814 | try { |
815 | 815 | $sth = $Connection->db->prepare($query); |
816 | 816 | $sth->execute(); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
819 | 819 | } |
820 | 820 | } |
821 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
821 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
822 | 822 | // Add aircraft_manufacturer to stats_aircraft |
823 | 823 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
824 | 824 | try { |
825 | 825 | $sth = $Connection->db->prepare($query); |
826 | 826 | $sth->execute(); |
827 | - } catch(PDOException $e) { |
|
827 | + } catch (PDOException $e) { |
|
828 | 828 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
829 | 829 | } |
830 | 830 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | try { |
834 | 834 | $sth = $Connection->db->prepare($query); |
835 | 835 | $sth->execute(); |
836 | - } catch(PDOException $e) { |
|
836 | + } catch (PDOException $e) { |
|
837 | 837 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
838 | 838 | } |
839 | 839 | return $error; |
@@ -849,23 +849,23 @@ discard block |
||
849 | 849 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 850 | } |
851 | 851 | if ($error != '') return 'Import airlines.sql : '.$error; |
852 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
852 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
853 | 853 | // Add forsource to airlines |
854 | 854 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
855 | 855 | try { |
856 | 856 | $sth = $Connection->db->prepare($query); |
857 | 857 | $sth->execute(); |
858 | - } catch(PDOException $e) { |
|
858 | + } catch (PDOException $e) { |
|
859 | 859 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
860 | 860 | } |
861 | 861 | } |
862 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
862 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
863 | 863 | // Add forsource to airlines |
864 | 864 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
865 | 865 | try { |
866 | 866 | $sth = $Connection->db->prepare($query); |
867 | 867 | $sth->execute(); |
868 | - } catch(PDOException $e) { |
|
868 | + } catch (PDOException $e) { |
|
869 | 869 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
870 | 870 | } |
871 | 871 | // Add unique key |
@@ -877,17 +877,17 @@ discard block |
||
877 | 877 | try { |
878 | 878 | $sth = $Connection->db->prepare($query); |
879 | 879 | $sth->execute(); |
880 | - } catch(PDOException $e) { |
|
880 | + } catch (PDOException $e) { |
|
881 | 881 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
882 | 882 | } |
883 | 883 | } |
884 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
884 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
885 | 885 | // Add forsource to airlines |
886 | 886 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
887 | 887 | try { |
888 | 888 | $sth = $Connection->db->prepare($query); |
889 | 889 | $sth->execute(); |
890 | - } catch(PDOException $e) { |
|
890 | + } catch (PDOException $e) { |
|
891 | 891 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
892 | 892 | } |
893 | 893 | // Add unique key |
@@ -899,17 +899,17 @@ discard block |
||
899 | 899 | try { |
900 | 900 | $sth = $Connection->db->prepare($query); |
901 | 901 | $sth->execute(); |
902 | - } catch(PDOException $e) { |
|
902 | + } catch (PDOException $e) { |
|
903 | 903 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
904 | 904 | } |
905 | 905 | } |
906 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
906 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
907 | 907 | // Add forsource to airlines |
908 | 908 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
909 | 909 | try { |
910 | 910 | $sth = $Connection->db->prepare($query); |
911 | 911 | $sth->execute(); |
912 | - } catch(PDOException $e) { |
|
912 | + } catch (PDOException $e) { |
|
913 | 913 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
914 | 914 | } |
915 | 915 | // Add unique key |
@@ -921,36 +921,36 @@ discard block |
||
921 | 921 | try { |
922 | 922 | $sth = $Connection->db->prepare($query); |
923 | 923 | $sth->execute(); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
926 | 926 | } |
927 | 927 | } |
928 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
928 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
929 | 929 | // Add forsource to airlines |
930 | 930 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
936 | 936 | } |
937 | 937 | } |
938 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
938 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
939 | 939 | // Add forsource to airlines |
940 | 940 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
941 | 941 | try { |
942 | 942 | $sth = $Connection->db->prepare($query); |
943 | 943 | $sth->execute(); |
944 | - } catch(PDOException $e) { |
|
944 | + } catch (PDOException $e) { |
|
945 | 945 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
946 | 946 | } |
947 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
947 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
948 | 948 | // Add unique key |
949 | 949 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
950 | 950 | try { |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
955 | 955 | } |
956 | 956 | } else { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | try { |
964 | 964 | $sth = $Connection->db->prepare($query); |
965 | 965 | $sth->execute(); |
966 | - } catch(PDOException $e) { |
|
966 | + } catch (PDOException $e) { |
|
967 | 967 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
968 | 968 | } |
969 | 969 | } |
970 | 970 | } |
971 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
971 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
972 | 972 | // Add forsource to airlines |
973 | 973 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
974 | 974 | try { |
975 | 975 | $sth = $Connection->db->prepare($query); |
976 | 976 | $sth->execute(); |
977 | - } catch(PDOException $e) { |
|
977 | + } catch (PDOException $e) { |
|
978 | 978 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
979 | 979 | } |
980 | 980 | // Add unique key |
@@ -986,17 +986,17 @@ discard block |
||
986 | 986 | try { |
987 | 987 | $sth = $Connection->db->prepare($query); |
988 | 988 | $sth->execute(); |
989 | - } catch(PDOException $e) { |
|
989 | + } catch (PDOException $e) { |
|
990 | 990 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
991 | 991 | } |
992 | 992 | } |
993 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
993 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
994 | 994 | // Add forsource to airlines |
995 | 995 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
996 | 996 | try { |
997 | 997 | $sth = $Connection->db->prepare($query); |
998 | 998 | $sth->execute(); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1001 | 1001 | } |
1002 | 1002 | // Add unique key |
@@ -1008,17 +1008,17 @@ discard block |
||
1008 | 1008 | try { |
1009 | 1009 | $sth = $Connection->db->prepare($query); |
1010 | 1010 | $sth->execute(); |
1011 | - } catch(PDOException $e) { |
|
1011 | + } catch (PDOException $e) { |
|
1012 | 1012 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1015 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1016 | 1016 | // Add forsource to airlines |
1017 | 1017 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1018 | 1018 | try { |
1019 | 1019 | $sth = $Connection->db->prepare($query); |
1020 | 1020 | $sth->execute(); |
1021 | - } catch(PDOException $e) { |
|
1021 | + } catch (PDOException $e) { |
|
1022 | 1022 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1023 | 1023 | } |
1024 | 1024 | // Add unique key |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | try { |
1031 | 1031 | $sth = $Connection->db->prepare($query); |
1032 | 1032 | $sth->execute(); |
1033 | - } catch(PDOException $e) { |
|
1033 | + } catch (PDOException $e) { |
|
1034 | 1034 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | try { |
1040 | 1040 | $sth = $Connection->db->prepare($query); |
1041 | 1041 | $sth->execute(); |
1042 | - } catch(PDOException $e) { |
|
1042 | + } catch (PDOException $e) { |
|
1043 | 1043 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1044 | 1044 | } |
1045 | 1045 | return $error; |
@@ -1049,13 +1049,13 @@ discard block |
||
1049 | 1049 | global $globalDBdriver; |
1050 | 1050 | $Connection = new Connection(); |
1051 | 1051 | $error = ''; |
1052 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1052 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1053 | 1053 | // Add forsource to airlines |
1054 | 1054 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1055 | 1055 | try { |
1056 | 1056 | $sth = $Connection->db->prepare($query); |
1057 | 1057 | $sth->execute(); |
1058 | - } catch(PDOException $e) { |
|
1058 | + } catch (PDOException $e) { |
|
1059 | 1059 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1060 | 1060 | } |
1061 | 1061 | // Add unique key |
@@ -1067,17 +1067,17 @@ discard block |
||
1067 | 1067 | try { |
1068 | 1068 | $sth = $Connection->db->prepare($query); |
1069 | 1069 | $sth->execute(); |
1070 | - } catch(PDOException $e) { |
|
1070 | + } catch (PDOException $e) { |
|
1071 | 1071 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1074 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1075 | 1075 | // Add forsource to airlines |
1076 | 1076 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1077 | 1077 | try { |
1078 | 1078 | $sth = $Connection->db->prepare($query); |
1079 | 1079 | $sth->execute(); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1082 | 1082 | } |
1083 | 1083 | // Add unique key |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | try { |
1090 | 1090 | $sth = $Connection->db->prepare($query); |
1091 | 1091 | $sth->execute(); |
1092 | - } catch(PDOException $e) { |
|
1092 | + } catch (PDOException $e) { |
|
1093 | 1093 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | try { |
1098 | 1098 | $sth = $Connection->db->prepare($query); |
1099 | 1099 | $sth->execute(); |
1100 | - } catch(PDOException $e) { |
|
1100 | + } catch (PDOException $e) { |
|
1101 | 1101 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1102 | 1102 | } |
1103 | 1103 | return $error; |
@@ -1107,12 +1107,12 @@ discard block |
||
1107 | 1107 | global $globalDBdriver; |
1108 | 1108 | $Connection = new Connection(); |
1109 | 1109 | $error = ''; |
1110 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1110 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1111 | 1111 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1112 | 1112 | try { |
1113 | 1113 | $sth = $Connection->db->prepare($query); |
1114 | 1114 | $sth->execute(); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | try { |
1121 | 1121 | $sth = $Connection->db->prepare($query); |
1122 | 1122 | $sth->execute(); |
1123 | - } catch(PDOException $e) { |
|
1123 | + } catch (PDOException $e) { |
|
1124 | 1124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1125 | 1125 | } |
1126 | 1126 | return $error; |
@@ -1130,13 +1130,13 @@ discard block |
||
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $error = ''; |
1133 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1133 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1134 | 1134 | // Add forsource to airlines |
1135 | 1135 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1136 | 1136 | try { |
1137 | 1137 | $sth = $Connection->db->prepare($query); |
1138 | 1138 | $sth->execute(); |
1139 | - } catch(PDOException $e) { |
|
1139 | + } catch (PDOException $e) { |
|
1140 | 1140 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1141 | 1141 | } |
1142 | 1142 | // Add unique key |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | try { |
1149 | 1149 | $sth = $Connection->db->prepare($query); |
1150 | 1150 | $sth->execute(); |
1151 | - } catch(PDOException $e) { |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | try { |
1157 | 1157 | $sth = $Connection->db->prepare($query); |
1158 | 1158 | $sth->execute(); |
1159 | - } catch(PDOException $e) { |
|
1159 | + } catch (PDOException $e) { |
|
1160 | 1160 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1161 | 1161 | } |
1162 | 1162 | return $error; |
@@ -1166,23 +1166,23 @@ discard block |
||
1166 | 1166 | global $globalDBdriver; |
1167 | 1167 | $Connection = new Connection(); |
1168 | 1168 | $error = ''; |
1169 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1169 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1170 | 1170 | // Add unique key |
1171 | 1171 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1172 | 1172 | try { |
1173 | 1173 | $sth = $Connection->db->prepare($query); |
1174 | 1174 | $sth->execute(); |
1175 | - } catch(PDOException $e) { |
|
1175 | + } catch (PDOException $e) { |
|
1176 | 1176 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1179 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1180 | 1180 | // Add mfr to aircraft |
1181 | 1181 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1182 | 1182 | try { |
1183 | 1183 | $sth = $Connection->db->prepare($query); |
1184 | 1184 | $sth->execute(); |
1185 | - } catch(PDOException $e) { |
|
1185 | + } catch (PDOException $e) { |
|
1186 | 1186 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1187 | 1187 | } |
1188 | 1188 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | try { |
1199 | 1199 | $sth = $Connection->db->prepare($query); |
1200 | 1200 | $sth->execute(); |
1201 | - } catch(PDOException $e) { |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1203 | 1203 | } |
1204 | 1204 | return $error; |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | global $globalDBdriver; |
1209 | 1209 | $Connection = new Connection(); |
1210 | 1210 | $error = ''; |
1211 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1211 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1212 | 1212 | // drop mfr to aircraft |
1213 | 1213 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1214 | 1214 | try { |
1215 | 1215 | $sth = $Connection->db->prepare($query); |
1216 | 1216 | $sth->execute(); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $sth = $Connection->db->prepare($query); |
1232 | 1232 | $sth->execute(); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1235 | 1235 | } |
1236 | 1236 | return $error; |
@@ -1240,33 +1240,33 @@ discard block |
||
1240 | 1240 | global $globalDBdriver; |
1241 | 1241 | $Connection = new Connection(); |
1242 | 1242 | $error = ''; |
1243 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1243 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1244 | 1244 | // Add index key |
1245 | 1245 | $query = "create index ref_idx on notam (ref)"; |
1246 | 1246 | try { |
1247 | 1247 | $sth = $Connection->db->prepare($query); |
1248 | 1248 | $sth->execute(); |
1249 | - } catch(PDOException $e) { |
|
1249 | + } catch (PDOException $e) { |
|
1250 | 1250 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1253 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1254 | 1254 | // Add index key |
1255 | 1255 | $query = "create index registration_idx on accidents (registration)"; |
1256 | 1256 | try { |
1257 | 1257 | $sth = $Connection->db->prepare($query); |
1258 | 1258 | $sth->execute(); |
1259 | - } catch(PDOException $e) { |
|
1259 | + } catch (PDOException $e) { |
|
1260 | 1260 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1263 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1264 | 1264 | // Add index key |
1265 | 1265 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1266 | 1266 | try { |
1267 | 1267 | $sth = $Connection->db->prepare($query); |
1268 | 1268 | $sth->execute(); |
1269 | - } catch(PDOException $e) { |
|
1269 | + } catch (PDOException $e) { |
|
1270 | 1270 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | try { |
1276 | 1276 | $sth = $Connection->db->prepare($query); |
1277 | 1277 | $sth->execute(); |
1278 | - } catch(PDOException $e) { |
|
1278 | + } catch (PDOException $e) { |
|
1279 | 1279 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1280 | 1280 | } |
1281 | 1281 | return $error; |
@@ -1285,23 +1285,23 @@ discard block |
||
1285 | 1285 | global $globalDBdriver; |
1286 | 1286 | $Connection = new Connection(); |
1287 | 1287 | $error = ''; |
1288 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1288 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1289 | 1289 | // Add airline_name to accidents |
1290 | 1290 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1291 | 1291 | try { |
1292 | 1292 | $sth = $Connection->db->prepare($query); |
1293 | 1293 | $sth->execute(); |
1294 | - } catch(PDOException $e) { |
|
1294 | + } catch (PDOException $e) { |
|
1295 | 1295 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1298 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1299 | 1299 | // Add airline_icao to accidents |
1300 | 1300 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1301 | 1301 | try { |
1302 | 1302 | $sth = $Connection->db->prepare($query); |
1303 | 1303 | $sth->execute(); |
1304 | - } catch(PDOException $e) { |
|
1304 | + } catch (PDOException $e) { |
|
1305 | 1305 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1306 | 1306 | } |
1307 | 1307 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | try { |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | 1311 | $sth->execute(); |
1312 | - } catch(PDOException $e) { |
|
1312 | + } catch (PDOException $e) { |
|
1313 | 1313 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1314 | 1314 | } |
1315 | 1315 | return $error; |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1320 | 1320 | $Connection = new Connection(); |
1321 | 1321 | $error = ''; |
1322 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1322 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1323 | 1323 | // Add alliance to airlines |
1324 | 1324 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1325 | 1325 | try { |
1326 | 1326 | $sth = $Connection->db->prepare($query); |
1327 | 1327 | $sth->execute(); |
1328 | - } catch(PDOException $e) { |
|
1328 | + } catch (PDOException $e) { |
|
1329 | 1329 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | try { |
1353 | 1353 | $sth = $Connection->db->prepare($query); |
1354 | 1354 | $sth->execute(); |
1355 | - } catch(PDOException $e) { |
|
1355 | + } catch (PDOException $e) { |
|
1356 | 1356 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1357 | 1357 | } |
1358 | 1358 | return $error; |
@@ -1362,13 +1362,13 @@ discard block |
||
1362 | 1362 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1363 | 1363 | $Connection = new Connection(); |
1364 | 1364 | $error = ''; |
1365 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1365 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1366 | 1366 | // Add ban_eu to airlines |
1367 | 1367 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1368 | 1368 | try { |
1369 | 1369 | $sth = $Connection->db->prepare($query); |
1370 | 1370 | $sth->execute(); |
1371 | - } catch(PDOException $e) { |
|
1371 | + } catch (PDOException $e) { |
|
1372 | 1372 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1373 | 1373 | } |
1374 | 1374 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | try { |
1377 | 1377 | $sth = $Connection->db->prepare($query); |
1378 | 1378 | $sth->execute(); |
1379 | - } catch(PDOException $e) { |
|
1379 | + } catch (PDOException $e) { |
|
1380 | 1380 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1381 | 1381 | } |
1382 | 1382 | return $error; |
@@ -1387,19 +1387,19 @@ discard block |
||
1387 | 1387 | $Connection = new Connection(); |
1388 | 1388 | $error = ''; |
1389 | 1389 | if ($globalDBdriver == 'mysql') { |
1390 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
1390 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
1391 | 1391 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
1392 | 1392 | try { |
1393 | 1393 | $sth = $Connection->db->prepare($query); |
1394 | 1394 | $sth->execute(); |
1395 | - } catch(PDOException $e) { |
|
1395 | + } catch (PDOException $e) { |
|
1396 | 1396 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1397 | 1397 | } |
1398 | 1398 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | try { |
1408 | 1408 | $sth = $Connection->db->prepare($query); |
1409 | 1409 | $sth->execute(); |
1410 | - } catch(PDOException $e) { |
|
1410 | + } catch (PDOException $e) { |
|
1411 | 1411 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1412 | 1412 | } |
1413 | 1413 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | try { |
1459 | 1459 | $sth = $Connection->db->prepare($query); |
1460 | 1460 | $sth->execute(); |
1461 | - } catch(PDOException $e) { |
|
1461 | + } catch (PDOException $e) { |
|
1462 | 1462 | return "error (fix date) : ".$e->getMessage()."\n"; |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1548 | 1548 | } |
1549 | 1549 | return $error; |
@@ -1552,13 +1552,13 @@ discard block |
||
1552 | 1552 | global $globalDBdriver; |
1553 | 1553 | $Connection = new Connection(); |
1554 | 1554 | $error = ''; |
1555 | - if (!$Connection->indexExists('accidents','type')) { |
|
1555 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
1556 | 1556 | // Add index key |
1557 | 1557 | $query = "create index type on accidents (type,date)"; |
1558 | 1558 | try { |
1559 | 1559 | $sth = $Connection->db->prepare($query); |
1560 | 1560 | $sth->execute(); |
1561 | - } catch(PDOException $e) { |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1563 | 1563 | } |
1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | try { |
1567 | 1567 | $sth = $Connection->db->prepare($query); |
1568 | 1568 | $sth->execute(); |
1569 | - } catch(PDOException $e) { |
|
1569 | + } catch (PDOException $e) { |
|
1570 | 1570 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1571 | 1571 | } |
1572 | 1572 | return $error; |
@@ -1576,12 +1576,12 @@ discard block |
||
1576 | 1576 | global $globalDBdriver; |
1577 | 1577 | $Connection = new Connection(); |
1578 | 1578 | $error = ''; |
1579 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
1579 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
1580 | 1580 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
1581 | 1581 | try { |
1582 | 1582 | $sth = $Connection->db->prepare($query); |
1583 | 1583 | $sth->execute(); |
1584 | - } catch(PDOException $e) { |
|
1584 | + } catch (PDOException $e) { |
|
1585 | 1585 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
1586 | 1586 | } |
1587 | 1587 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | try { |
1648 | 1648 | $sth = $Connection->db->prepare($query); |
1649 | 1649 | $sth->execute(); |
1650 | - } catch(PDOException $e) { |
|
1650 | + } catch (PDOException $e) { |
|
1651 | 1651 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1652 | 1652 | } |
1653 | 1653 | return $error; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | try { |
1700 | 1700 | $sth = $Connection->db->prepare($query); |
1701 | 1701 | $sth->execute(); |
1702 | - } catch(PDOException $e) { |
|
1702 | + } catch (PDOException $e) { |
|
1703 | 1703 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
1704 | 1704 | } |
1705 | 1705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1708,18 +1708,18 @@ discard block |
||
1708 | 1708 | try { |
1709 | 1709 | $sth = $Connection->db->prepare($query); |
1710 | 1710 | $sth->execute(); |
1711 | - } catch(PDOException $e) { |
|
1711 | + } catch (PDOException $e) { |
|
1712 | 1712 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; |
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
1716 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
1717 | 1717 | // Add index key |
1718 | 1718 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
1719 | 1719 | try { |
1720 | 1720 | $sth = $Connection->db->prepare($query); |
1721 | 1721 | $sth->execute(); |
1722 | - } catch(PDOException $e) { |
|
1722 | + } catch (PDOException $e) { |
|
1723 | 1723 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1724 | 1724 | } |
1725 | 1725 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | try { |
1728 | 1728 | $sth = $Connection->db->prepare($query); |
1729 | 1729 | $sth->execute(); |
1730 | - } catch(PDOException $e) { |
|
1730 | + } catch (PDOException $e) { |
|
1731 | 1731 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1732 | 1732 | } |
1733 | 1733 | return $error; |
@@ -1738,148 +1738,148 @@ discard block |
||
1738 | 1738 | $Connection = new Connection(); |
1739 | 1739 | $error = ''; |
1740 | 1740 | if ($globalDBdriver == 'mysql') { |
1741 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1741 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1742 | 1742 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1743 | 1743 | try { |
1744 | 1744 | $sth = $Connection->db->prepare($query); |
1745 | 1745 | $sth->execute(); |
1746 | - } catch(PDOException $e) { |
|
1746 | + } catch (PDOException $e) { |
|
1747 | 1747 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1750 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1751 | 1751 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
1752 | 1752 | try { |
1753 | 1753 | $sth = $Connection->db->prepare($query); |
1754 | 1754 | $sth->execute(); |
1755 | - } catch(PDOException $e) { |
|
1755 | + } catch (PDOException $e) { |
|
1756 | 1756 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1757 | 1757 | } |
1758 | 1758 | } |
1759 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1759 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1760 | 1760 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
1761 | 1761 | try { |
1762 | 1762 | $sth = $Connection->db->prepare($query); |
1763 | 1763 | $sth->execute(); |
1764 | - } catch(PDOException $e) { |
|
1764 | + } catch (PDOException $e) { |
|
1765 | 1765 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1768 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1769 | 1769 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1770 | 1770 | try { |
1771 | 1771 | $sth = $Connection->db->prepare($query); |
1772 | 1772 | $sth->execute(); |
1773 | - } catch(PDOException $e) { |
|
1773 | + } catch (PDOException $e) { |
|
1774 | 1774 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1775 | 1775 | } |
1776 | 1776 | } |
1777 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1777 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1778 | 1778 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1779 | 1779 | try { |
1780 | 1780 | $sth = $Connection->db->prepare($query); |
1781 | 1781 | $sth->execute(); |
1782 | - } catch(PDOException $e) { |
|
1782 | + } catch (PDOException $e) { |
|
1783 | 1783 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1786 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1787 | 1787 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
1788 | 1788 | try { |
1789 | 1789 | $sth = $Connection->db->prepare($query); |
1790 | 1790 | $sth->execute(); |
1791 | - } catch(PDOException $e) { |
|
1791 | + } catch (PDOException $e) { |
|
1792 | 1792 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1795 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1796 | 1796 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
1797 | 1797 | try { |
1798 | 1798 | $sth = $Connection->db->prepare($query); |
1799 | 1799 | $sth->execute(); |
1800 | - } catch(PDOException $e) { |
|
1800 | + } catch (PDOException $e) { |
|
1801 | 1801 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1802 | 1802 | } |
1803 | 1803 | } |
1804 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1804 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1805 | 1805 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1806 | 1806 | try { |
1807 | 1807 | $sth = $Connection->db->prepare($query); |
1808 | 1808 | $sth->execute(); |
1809 | - } catch(PDOException $e) { |
|
1809 | + } catch (PDOException $e) { |
|
1810 | 1810 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | } else { |
1814 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1814 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1815 | 1815 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
1816 | 1816 | try { |
1817 | 1817 | $sth = $Connection->db->prepare($query); |
1818 | 1818 | $sth->execute(); |
1819 | - } catch(PDOException $e) { |
|
1819 | + } catch (PDOException $e) { |
|
1820 | 1820 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1821 | 1821 | } |
1822 | 1822 | } |
1823 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1823 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1824 | 1824 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
1825 | 1825 | try { |
1826 | 1826 | $sth = $Connection->db->prepare($query); |
1827 | 1827 | $sth->execute(); |
1828 | - } catch(PDOException $e) { |
|
1828 | + } catch (PDOException $e) { |
|
1829 | 1829 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1830 | 1830 | } |
1831 | 1831 | } |
1832 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1832 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1833 | 1833 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
1834 | 1834 | try { |
1835 | 1835 | $sth = $Connection->db->prepare($query); |
1836 | 1836 | $sth->execute(); |
1837 | - } catch(PDOException $e) { |
|
1837 | + } catch (PDOException $e) { |
|
1838 | 1838 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1839 | 1839 | } |
1840 | 1840 | } |
1841 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1841 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1842 | 1842 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
1843 | 1843 | try { |
1844 | 1844 | $sth = $Connection->db->prepare($query); |
1845 | 1845 | $sth->execute(); |
1846 | - } catch(PDOException $e) { |
|
1846 | + } catch (PDOException $e) { |
|
1847 | 1847 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1848 | 1848 | } |
1849 | 1849 | } |
1850 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1850 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1851 | 1851 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
1852 | 1852 | try { |
1853 | 1853 | $sth = $Connection->db->prepare($query); |
1854 | 1854 | $sth->execute(); |
1855 | - } catch(PDOException $e) { |
|
1855 | + } catch (PDOException $e) { |
|
1856 | 1856 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1857 | 1857 | } |
1858 | 1858 | } |
1859 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1859 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1860 | 1860 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
1861 | 1861 | try { |
1862 | 1862 | $sth = $Connection->db->prepare($query); |
1863 | 1863 | $sth->execute(); |
1864 | - } catch(PDOException $e) { |
|
1864 | + } catch (PDOException $e) { |
|
1865 | 1865 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1866 | 1866 | } |
1867 | 1867 | } |
1868 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1868 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1869 | 1869 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
1870 | 1870 | try { |
1871 | 1871 | $sth = $Connection->db->prepare($query); |
1872 | 1872 | $sth->execute(); |
1873 | - } catch(PDOException $e) { |
|
1873 | + } catch (PDOException $e) { |
|
1874 | 1874 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1875 | 1875 | } |
1876 | 1876 | } |
1877 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1877 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1878 | 1878 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
1879 | 1879 | try { |
1880 | 1880 | $sth = $Connection->db->prepare($query); |
1881 | 1881 | $sth->execute(); |
1882 | - } catch(PDOException $e) { |
|
1882 | + } catch (PDOException $e) { |
|
1883 | 1883 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1884 | 1884 | } |
1885 | 1885 | } |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | try { |
1889 | 1889 | $sth = $Connection->db->prepare($query); |
1890 | 1890 | $sth->execute(); |
1891 | - } catch(PDOException $e) { |
|
1891 | + } catch (PDOException $e) { |
|
1892 | 1892 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1893 | 1893 | } |
1894 | 1894 | return $error; |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | try { |
1904 | 1904 | $sth = $Connection->db->prepare($query); |
1905 | 1905 | $sth->execute(); |
1906 | - } catch(PDOException $e) { |
|
1906 | + } catch (PDOException $e) { |
|
1907 | 1907 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1908 | 1908 | } |
1909 | 1909 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; |
1910 | 1910 | try { |
1911 | 1911 | $sth = $Connection->db->prepare($query); |
1912 | 1912 | $sth->execute(); |
1913 | - } catch(PDOException $e) { |
|
1913 | + } catch (PDOException $e) { |
|
1914 | 1914 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1915 | 1915 | } |
1916 | 1916 | } else { |
@@ -1918,14 +1918,14 @@ discard block |
||
1918 | 1918 | try { |
1919 | 1919 | $sth = $Connection->db->prepare($query); |
1920 | 1920 | $sth->execute(); |
1921 | - } catch(PDOException $e) { |
|
1921 | + } catch (PDOException $e) { |
|
1922 | 1922 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1923 | 1923 | } |
1924 | 1924 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; |
1925 | 1925 | try { |
1926 | 1926 | $sth = $Connection->db->prepare($query); |
1927 | 1927 | $sth->execute(); |
1928 | - } catch(PDOException $e) { |
|
1928 | + } catch (PDOException $e) { |
|
1929 | 1929 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1930 | 1930 | } |
1931 | 1931 | } |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | try { |
1934 | 1934 | $sth = $Connection->db->prepare($query); |
1935 | 1935 | $sth->execute(); |
1936 | - } catch(PDOException $e) { |
|
1936 | + } catch (PDOException $e) { |
|
1937 | 1937 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1938 | 1938 | } |
1939 | 1939 | return $error; |
@@ -1943,32 +1943,32 @@ discard block |
||
1943 | 1943 | global $globalDBdriver; |
1944 | 1944 | $Connection = new Connection(); |
1945 | 1945 | $error = ''; |
1946 | - if (!$Connection->checkColumnName('source_location','last_seen')) { |
|
1946 | + if (!$Connection->checkColumnName('source_location', 'last_seen')) { |
|
1947 | 1947 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; |
1948 | 1948 | try { |
1949 | 1949 | $sth = $Connection->db->prepare($query); |
1950 | 1950 | $sth->execute(); |
1951 | - } catch(PDOException $e) { |
|
1951 | + } catch (PDOException $e) { |
|
1952 | 1952 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; |
1953 | 1953 | } |
1954 | 1954 | } |
1955 | 1955 | if ($globalDBdriver == 'mysql') { |
1956 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1956 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1957 | 1957 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; |
1958 | 1958 | try { |
1959 | 1959 | $sth = $Connection->db->prepare($query); |
1960 | 1960 | $sth->execute(); |
1961 | - } catch(PDOException $e) { |
|
1961 | + } catch (PDOException $e) { |
|
1962 | 1962 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } else { |
1966 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1966 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1967 | 1967 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; |
1968 | 1968 | try { |
1969 | 1969 | $sth = $Connection->db->prepare($query); |
1970 | 1970 | $sth->execute(); |
1971 | - } catch(PDOException $e) { |
|
1971 | + } catch (PDOException $e) { |
|
1972 | 1972 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1973 | 1973 | } |
1974 | 1974 | } |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | try { |
1978 | 1978 | $sth = $Connection->db->prepare($query); |
1979 | 1979 | $sth->execute(); |
1980 | - } catch(PDOException $e) { |
|
1980 | + } catch (PDOException $e) { |
|
1981 | 1981 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1982 | 1982 | } |
1983 | 1983 | return $error; |
@@ -1987,12 +1987,12 @@ discard block |
||
1987 | 1987 | global $globalDBdriver; |
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $error = ''; |
1990 | - if (!$Connection->checkColumnName('source_location','description')) { |
|
1990 | + if (!$Connection->checkColumnName('source_location', 'description')) { |
|
1991 | 1991 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; |
1992 | 1992 | try { |
1993 | 1993 | $sth = $Connection->db->prepare($query); |
1994 | 1994 | $sth->execute(); |
1995 | - } catch(PDOException $e) { |
|
1995 | + } catch (PDOException $e) { |
|
1996 | 1996 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; |
1997 | 1997 | } |
1998 | 1998 | } |
@@ -2000,7 +2000,7 @@ discard block |
||
2000 | 2000 | try { |
2001 | 2001 | $sth = $Connection->db->prepare($query); |
2002 | 2002 | $sth->execute(); |
2003 | - } catch(PDOException $e) { |
|
2003 | + } catch (PDOException $e) { |
|
2004 | 2004 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2005 | 2005 | } |
2006 | 2006 | return $error; |
@@ -2010,39 +2010,39 @@ discard block |
||
2010 | 2010 | global $globalDBdriver; |
2011 | 2011 | $Connection = new Connection(); |
2012 | 2012 | $error = ''; |
2013 | - if (!$Connection->checkColumnName('spotter_live','real_altitude')) { |
|
2013 | + if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) { |
|
2014 | 2014 | $query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL"; |
2015 | 2015 | try { |
2016 | 2016 | $sth = $Connection->db->prepare($query); |
2017 | 2017 | $sth->execute(); |
2018 | - } catch(PDOException $e) { |
|
2018 | + } catch (PDOException $e) { |
|
2019 | 2019 | return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n"; |
2020 | 2020 | } |
2021 | 2021 | } |
2022 | - if (!$Connection->checkColumnName('spotter_output','real_altitude')) { |
|
2022 | + if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) { |
|
2023 | 2023 | $query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2024 | 2024 | try { |
2025 | 2025 | $sth = $Connection->db->prepare($query); |
2026 | 2026 | $sth->execute(); |
2027 | - } catch(PDOException $e) { |
|
2027 | + } catch (PDOException $e) { |
|
2028 | 2028 | return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n"; |
2029 | 2029 | } |
2030 | 2030 | } |
2031 | - if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) { |
|
2031 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) { |
|
2032 | 2032 | $query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2033 | 2033 | try { |
2034 | 2034 | $sth = $Connection->db->prepare($query); |
2035 | 2035 | $sth->execute(); |
2036 | - } catch(PDOException $e) { |
|
2036 | + } catch (PDOException $e) { |
|
2037 | 2037 | return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n"; |
2038 | 2038 | } |
2039 | 2039 | } |
2040 | - if (!$Connection->checkColumnName('spotter_archive','real_altitude')) { |
|
2040 | + if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) { |
|
2041 | 2041 | $query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL"; |
2042 | 2042 | try { |
2043 | 2043 | $sth = $Connection->db->prepare($query); |
2044 | 2044 | $sth->execute(); |
2045 | - } catch(PDOException $e) { |
|
2045 | + } catch (PDOException $e) { |
|
2046 | 2046 | return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n"; |
2047 | 2047 | } |
2048 | 2048 | } |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | try { |
2051 | 2051 | $sth = $Connection->db->prepare($query); |
2052 | 2052 | $sth->execute(); |
2053 | - } catch(PDOException $e) { |
|
2053 | + } catch (PDOException $e) { |
|
2054 | 2054 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2055 | 2055 | } |
2056 | 2056 | return $error; |
@@ -2072,14 +2072,14 @@ discard block |
||
2072 | 2072 | try { |
2073 | 2073 | $sth = $Connection->db->prepare($query); |
2074 | 2074 | $sth->execute(); |
2075 | - } catch(PDOException $e) { |
|
2075 | + } catch (PDOException $e) { |
|
2076 | 2076 | return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n"; |
2077 | 2077 | } |
2078 | 2078 | $query = "UPDATE config SET value = '44' WHERE name = 'schema_version'"; |
2079 | 2079 | try { |
2080 | 2080 | $sth = $Connection->db->prepare($query); |
2081 | 2081 | $sth->execute(); |
2082 | - } catch(PDOException $e) { |
|
2082 | + } catch (PDOException $e) { |
|
2083 | 2083 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2084 | 2084 | } |
2085 | 2085 | return $error; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2125 | 2125 | } |
2126 | 2126 | return $error; |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | try { |
2144 | 2144 | $sth = $Connection->db->prepare($query); |
2145 | 2145 | $sth->execute(); |
2146 | - } catch(PDOException $e) { |
|
2146 | + } catch (PDOException $e) { |
|
2147 | 2147 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2148 | 2148 | } |
2149 | 2149 | return $error; |
@@ -2193,7 +2193,7 @@ discard block |
||
2193 | 2193 | try { |
2194 | 2194 | $sth = $Connection->db->prepare($query); |
2195 | 2195 | $sth->execute(); |
2196 | - } catch(PDOException $e) { |
|
2196 | + } catch (PDOException $e) { |
|
2197 | 2197 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2198 | 2198 | } |
2199 | 2199 | return $error; |
@@ -2216,7 +2216,7 @@ discard block |
||
2216 | 2216 | try { |
2217 | 2217 | $sth = $Connection->db->prepare($query); |
2218 | 2218 | $sth->execute(); |
2219 | - } catch(PDOException $e) { |
|
2219 | + } catch (PDOException $e) { |
|
2220 | 2220 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2221 | 2221 | } |
2222 | 2222 | return $error; |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | try { |
2240 | 2240 | $sth = $Connection->db->prepare($query); |
2241 | 2241 | $sth->execute(); |
2242 | - } catch(PDOException $e) { |
|
2242 | + } catch (PDOException $e) { |
|
2243 | 2243 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2244 | 2244 | } |
2245 | 2245 | return $error; |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | try { |
2261 | 2261 | $sth = $Connection->db->prepare($query); |
2262 | 2262 | $sth->execute(); |
2263 | - } catch(PDOException $e) { |
|
2263 | + } catch (PDOException $e) { |
|
2264 | 2264 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2265 | 2265 | } |
2266 | 2266 | return $error; |
@@ -2285,7 +2285,7 @@ discard block |
||
2285 | 2285 | try { |
2286 | 2286 | $sth = $Connection->db->prepare($query); |
2287 | 2287 | $sth->execute(); |
2288 | - } catch(PDOException $e) { |
|
2288 | + } catch (PDOException $e) { |
|
2289 | 2289 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2290 | 2290 | } |
2291 | 2291 | return $error; |
@@ -2295,39 +2295,39 @@ discard block |
||
2295 | 2295 | global $globalDBdriver; |
2296 | 2296 | $Connection = new Connection(); |
2297 | 2297 | $error = ''; |
2298 | - if (!$Connection->checkColumnName('marine_live','captain_name')) { |
|
2298 | + if (!$Connection->checkColumnName('marine_live', 'captain_name')) { |
|
2299 | 2299 | $query = "ALTER TABLE marine_live ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL"; |
2300 | 2300 | try { |
2301 | 2301 | $sth = $Connection->db->prepare($query); |
2302 | 2302 | $sth->execute(); |
2303 | - } catch(PDOException $e) { |
|
2303 | + } catch (PDOException $e) { |
|
2304 | 2304 | return "error (add columns captain and race in marine_live) : ".$e->getMessage()."\n"; |
2305 | 2305 | } |
2306 | 2306 | } |
2307 | - if (!$Connection->checkColumnName('marine_output','captain_name')) { |
|
2307 | + if (!$Connection->checkColumnName('marine_output', 'captain_name')) { |
|
2308 | 2308 | $query = "ALTER TABLE marine_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL"; |
2309 | 2309 | try { |
2310 | 2310 | $sth = $Connection->db->prepare($query); |
2311 | 2311 | $sth->execute(); |
2312 | - } catch(PDOException $e) { |
|
2312 | + } catch (PDOException $e) { |
|
2313 | 2313 | return "error (add columns captain and race in marine_output) : ".$e->getMessage()."\n"; |
2314 | 2314 | } |
2315 | 2315 | } |
2316 | - if (!$Connection->checkColumnName('marine_archive','captain_name')) { |
|
2316 | + if (!$Connection->checkColumnName('marine_archive', 'captain_name')) { |
|
2317 | 2317 | $query = "ALTER TABLE marine_archive ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL"; |
2318 | 2318 | try { |
2319 | 2319 | $sth = $Connection->db->prepare($query); |
2320 | 2320 | $sth->execute(); |
2321 | - } catch(PDOException $e) { |
|
2321 | + } catch (PDOException $e) { |
|
2322 | 2322 | return "error (add columns captain and race in marine_archive) : ".$e->getMessage()."\n"; |
2323 | 2323 | } |
2324 | 2324 | } |
2325 | - if (!$Connection->checkColumnName('marine_archive_output','captain_name')) { |
|
2325 | + if (!$Connection->checkColumnName('marine_archive_output', 'captain_name')) { |
|
2326 | 2326 | $query = "ALTER TABLE marine_archive_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL"; |
2327 | 2327 | try { |
2328 | 2328 | $sth = $Connection->db->prepare($query); |
2329 | 2329 | $sth->execute(); |
2330 | - } catch(PDOException $e) { |
|
2330 | + } catch (PDOException $e) { |
|
2331 | 2331 | return "error (add columns captain and race in marine_archive_output) : ".$e->getMessage()."\n"; |
2332 | 2332 | } |
2333 | 2333 | } |
@@ -2335,7 +2335,7 @@ discard block |
||
2335 | 2335 | try { |
2336 | 2336 | $sth = $Connection->db->prepare($query); |
2337 | 2337 | $sth->execute(); |
2338 | - } catch(PDOException $e) { |
|
2338 | + } catch (PDOException $e) { |
|
2339 | 2339 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2340 | 2340 | } |
2341 | 2341 | return $error; |
@@ -2353,14 +2353,14 @@ discard block |
||
2353 | 2353 | try { |
2354 | 2354 | $sth = $Connection->db->prepare($query); |
2355 | 2355 | $sth->execute(); |
2356 | - } catch(PDOException $e) { |
|
2356 | + } catch (PDOException $e) { |
|
2357 | 2357 | return "error (modify column ground_speede in marine_*) : ".$e->getMessage()."\n"; |
2358 | 2358 | } |
2359 | 2359 | $query = "UPDATE config SET value = '53' WHERE name = 'schema_version'"; |
2360 | 2360 | try { |
2361 | 2361 | $sth = $Connection->db->prepare($query); |
2362 | 2362 | $sth->execute(); |
2363 | - } catch(PDOException $e) { |
|
2363 | + } catch (PDOException $e) { |
|
2364 | 2364 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2365 | 2365 | } |
2366 | 2366 | return $error; |
@@ -2384,7 +2384,7 @@ discard block |
||
2384 | 2384 | try { |
2385 | 2385 | $sth = $Connection->db->prepare($query); |
2386 | 2386 | $sth->execute(); |
2387 | - } catch(PDOException $e) { |
|
2387 | + } catch (PDOException $e) { |
|
2388 | 2388 | return "error (check_version): ".$e->getMessage()."\n"; |
2389 | 2389 | } |
2390 | 2390 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2156,37 +2284,53 @@ discard block |
||
2156 | 2284 | if (!$Connection->tableExists('stats_marine')) { |
2157 | 2285 | if ($globalDBdriver == 'mysql') { |
2158 | 2286 | $error .= create_db::import_file('../db/stats_marine.sql'); |
2159 | - if ($error != '') return $error; |
|
2287 | + if ($error != '') { |
|
2288 | + return $error; |
|
2289 | + } |
|
2160 | 2290 | } else { |
2161 | 2291 | $error .= create_db::import_file('../db/pgsql/stats_marine.sql'); |
2162 | - if ($error != '') return $error; |
|
2292 | + if ($error != '') { |
|
2293 | + return $error; |
|
2294 | + } |
|
2163 | 2295 | } |
2164 | 2296 | } |
2165 | 2297 | if (!$Connection->tableExists('stats_marine_country')) { |
2166 | 2298 | if ($globalDBdriver == 'mysql') { |
2167 | 2299 | $error .= create_db::import_file('../db/stats_marine_country.sql'); |
2168 | - if ($error != '') return $error; |
|
2300 | + if ($error != '') { |
|
2301 | + return $error; |
|
2302 | + } |
|
2169 | 2303 | } else { |
2170 | 2304 | $error .= create_db::import_file('../db/pgsql/stats_marine_country.sql'); |
2171 | - if ($error != '') return $error; |
|
2305 | + if ($error != '') { |
|
2306 | + return $error; |
|
2307 | + } |
|
2172 | 2308 | } |
2173 | 2309 | } |
2174 | 2310 | if (!$Connection->tableExists('stats_tracker')) { |
2175 | 2311 | if ($globalDBdriver == 'mysql') { |
2176 | 2312 | $error .= create_db::import_file('../db/stats_tracker.sql'); |
2177 | - if ($error != '') return $error; |
|
2313 | + if ($error != '') { |
|
2314 | + return $error; |
|
2315 | + } |
|
2178 | 2316 | } else { |
2179 | 2317 | $error .= create_db::import_file('../db/pgsql/stats_tracker.sql'); |
2180 | - if ($error != '') return $error; |
|
2318 | + if ($error != '') { |
|
2319 | + return $error; |
|
2320 | + } |
|
2181 | 2321 | } |
2182 | 2322 | } |
2183 | 2323 | if (!$Connection->tableExists('stats_tracker_country')) { |
2184 | 2324 | if ($globalDBdriver == 'mysql') { |
2185 | 2325 | $error .= create_db::import_file('../db/stats_tracker_country.sql'); |
2186 | - if ($error != '') return $error; |
|
2326 | + if ($error != '') { |
|
2327 | + return $error; |
|
2328 | + } |
|
2187 | 2329 | } else { |
2188 | 2330 | $error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql'); |
2189 | - if ($error != '') return $error; |
|
2331 | + if ($error != '') { |
|
2332 | + return $error; |
|
2333 | + } |
|
2190 | 2334 | } |
2191 | 2335 | } |
2192 | 2336 | $query = "UPDATE config SET value = '47' WHERE name = 'schema_version'"; |
@@ -2206,10 +2350,14 @@ discard block |
||
2206 | 2350 | if (!$Connection->tableExists('stats_marine_type')) { |
2207 | 2351 | if ($globalDBdriver == 'mysql') { |
2208 | 2352 | $error .= create_db::import_file('../db/stats_marine_type.sql'); |
2209 | - if ($error != '') return $error; |
|
2353 | + if ($error != '') { |
|
2354 | + return $error; |
|
2355 | + } |
|
2210 | 2356 | } else { |
2211 | 2357 | $error .= create_db::import_file('../db/pgsql/stats_marine_type.sql'); |
2212 | - if ($error != '') return $error; |
|
2358 | + if ($error != '') { |
|
2359 | + return $error; |
|
2360 | + } |
|
2213 | 2361 | } |
2214 | 2362 | } |
2215 | 2363 | $query = "UPDATE config SET value = '48' WHERE name = 'schema_version'"; |
@@ -2229,10 +2377,14 @@ discard block |
||
2229 | 2377 | if (!$Connection->tableExists('stats_tracker_type')) { |
2230 | 2378 | if ($globalDBdriver == 'mysql') { |
2231 | 2379 | $error .= create_db::import_file('../db/stats_tracker_type.sql'); |
2232 | - if ($error != '') return $error; |
|
2380 | + if ($error != '') { |
|
2381 | + return $error; |
|
2382 | + } |
|
2233 | 2383 | } else { |
2234 | 2384 | $error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql'); |
2235 | - if ($error != '') return $error; |
|
2385 | + if ($error != '') { |
|
2386 | + return $error; |
|
2387 | + } |
|
2236 | 2388 | } |
2237 | 2389 | } |
2238 | 2390 | $query = "UPDATE config SET value = '49' WHERE name = 'schema_version'"; |
@@ -2251,10 +2403,14 @@ discard block |
||
2251 | 2403 | $error = ''; |
2252 | 2404 | if ($globalDBdriver == 'mysql') { |
2253 | 2405 | $error .= create_db::import_file('../db/airport.sql'); |
2254 | - if ($error != '') return $error; |
|
2406 | + if ($error != '') { |
|
2407 | + return $error; |
|
2408 | + } |
|
2255 | 2409 | } else { |
2256 | 2410 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2257 | - if ($error != '') return $error; |
|
2411 | + if ($error != '') { |
|
2412 | + return $error; |
|
2413 | + } |
|
2258 | 2414 | } |
2259 | 2415 | $query = "UPDATE config SET value = '50' WHERE name = 'schema_version'"; |
2260 | 2416 | try { |
@@ -2272,14 +2428,22 @@ discard block |
||
2272 | 2428 | $error = ''; |
2273 | 2429 | if ($globalDBdriver == 'mysql') { |
2274 | 2430 | $error .= create_db::import_file('../db/aircraft.sql'); |
2275 | - if ($error != '') return $error; |
|
2431 | + if ($error != '') { |
|
2432 | + return $error; |
|
2433 | + } |
|
2276 | 2434 | $error .= create_db::import_file('../db/aircraft_block.sql'); |
2277 | - if ($error != '') return $error; |
|
2435 | + if ($error != '') { |
|
2436 | + return $error; |
|
2437 | + } |
|
2278 | 2438 | } else { |
2279 | 2439 | $error .= create_db::import_file('../db/pgsql/aircraft.sql'); |
2280 | - if ($error != '') return $error; |
|
2440 | + if ($error != '') { |
|
2441 | + return $error; |
|
2442 | + } |
|
2281 | 2443 | $error .= create_db::import_file('../db/pgsql/aircraft_block.sql'); |
2282 | - if ($error != '') return $error; |
|
2444 | + if ($error != '') { |
|
2445 | + return $error; |
|
2446 | + } |
|
2283 | 2447 | } |
2284 | 2448 | $query = "UPDATE config SET value = '51' WHERE name = 'schema_version'"; |
2285 | 2449 | try { |
@@ -2377,8 +2541,11 @@ discard block |
||
2377 | 2541 | if ($Connection->tableExists('aircraft')) { |
2378 | 2542 | if (!$Connection->tableExists('config')) { |
2379 | 2543 | $version = '1'; |
2380 | - if ($update) return self::update_from_1(); |
|
2381 | - else return $version; |
|
2544 | + if ($update) { |
|
2545 | + return self::update_from_1(); |
|
2546 | + } else { |
|
2547 | + return $version; |
|
2548 | + } |
|
2382 | 2549 | } else { |
2383 | 2550 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2384 | 2551 | try { |
@@ -2391,215 +2558,375 @@ discard block |
||
2391 | 2558 | if ($update) { |
2392 | 2559 | if ($result['value'] == '2') { |
2393 | 2560 | $error = self::update_from_2(); |
2394 | - if ($error != '') return $error; |
|
2395 | - else return self::check_version(true); |
|
2561 | + if ($error != '') { |
|
2562 | + return $error; |
|
2563 | + } else { |
|
2564 | + return self::check_version(true); |
|
2565 | + } |
|
2396 | 2566 | } elseif ($result['value'] == '3') { |
2397 | 2567 | $error = self::update_from_3(); |
2398 | - if ($error != '') return $error; |
|
2399 | - else return self::check_version(true); |
|
2568 | + if ($error != '') { |
|
2569 | + return $error; |
|
2570 | + } else { |
|
2571 | + return self::check_version(true); |
|
2572 | + } |
|
2400 | 2573 | } elseif ($result['value'] == '4') { |
2401 | 2574 | $error = self::update_from_4(); |
2402 | - if ($error != '') return $error; |
|
2403 | - else return self::check_version(true); |
|
2575 | + if ($error != '') { |
|
2576 | + return $error; |
|
2577 | + } else { |
|
2578 | + return self::check_version(true); |
|
2579 | + } |
|
2404 | 2580 | } elseif ($result['value'] == '5') { |
2405 | 2581 | $error = self::update_from_5(); |
2406 | - if ($error != '') return $error; |
|
2407 | - else return self::check_version(true); |
|
2582 | + if ($error != '') { |
|
2583 | + return $error; |
|
2584 | + } else { |
|
2585 | + return self::check_version(true); |
|
2586 | + } |
|
2408 | 2587 | } elseif ($result['value'] == '6') { |
2409 | 2588 | $error = self::update_from_6(); |
2410 | - if ($error != '') return $error; |
|
2411 | - else return self::check_version(true); |
|
2589 | + if ($error != '') { |
|
2590 | + return $error; |
|
2591 | + } else { |
|
2592 | + return self::check_version(true); |
|
2593 | + } |
|
2412 | 2594 | } elseif ($result['value'] == '7') { |
2413 | 2595 | $error = self::update_from_7(); |
2414 | - if ($error != '') return $error; |
|
2415 | - else return self::check_version(true); |
|
2596 | + if ($error != '') { |
|
2597 | + return $error; |
|
2598 | + } else { |
|
2599 | + return self::check_version(true); |
|
2600 | + } |
|
2416 | 2601 | } elseif ($result['value'] == '8') { |
2417 | 2602 | $error = self::update_from_8(); |
2418 | - if ($error != '') return $error; |
|
2419 | - else return self::check_version(true); |
|
2603 | + if ($error != '') { |
|
2604 | + return $error; |
|
2605 | + } else { |
|
2606 | + return self::check_version(true); |
|
2607 | + } |
|
2420 | 2608 | } elseif ($result['value'] == '9') { |
2421 | 2609 | $error = self::update_from_9(); |
2422 | - if ($error != '') return $error; |
|
2423 | - else return self::check_version(true); |
|
2610 | + if ($error != '') { |
|
2611 | + return $error; |
|
2612 | + } else { |
|
2613 | + return self::check_version(true); |
|
2614 | + } |
|
2424 | 2615 | } elseif ($result['value'] == '10') { |
2425 | 2616 | $error = self::update_from_10(); |
2426 | - if ($error != '') return $error; |
|
2427 | - else return self::check_version(true); |
|
2617 | + if ($error != '') { |
|
2618 | + return $error; |
|
2619 | + } else { |
|
2620 | + return self::check_version(true); |
|
2621 | + } |
|
2428 | 2622 | } elseif ($result['value'] == '11') { |
2429 | 2623 | $error = self::update_from_11(); |
2430 | - if ($error != '') return $error; |
|
2431 | - else return self::check_version(true); |
|
2624 | + if ($error != '') { |
|
2625 | + return $error; |
|
2626 | + } else { |
|
2627 | + return self::check_version(true); |
|
2628 | + } |
|
2432 | 2629 | } elseif ($result['value'] == '12') { |
2433 | 2630 | $error = self::update_from_12(); |
2434 | - if ($error != '') return $error; |
|
2435 | - else return self::check_version(true); |
|
2631 | + if ($error != '') { |
|
2632 | + return $error; |
|
2633 | + } else { |
|
2634 | + return self::check_version(true); |
|
2635 | + } |
|
2436 | 2636 | } elseif ($result['value'] == '13') { |
2437 | 2637 | $error = self::update_from_13(); |
2438 | - if ($error != '') return $error; |
|
2439 | - else return self::check_version(true); |
|
2638 | + if ($error != '') { |
|
2639 | + return $error; |
|
2640 | + } else { |
|
2641 | + return self::check_version(true); |
|
2642 | + } |
|
2440 | 2643 | } elseif ($result['value'] == '14') { |
2441 | 2644 | $error = self::update_from_14(); |
2442 | - if ($error != '') return $error; |
|
2443 | - else return self::check_version(true); |
|
2645 | + if ($error != '') { |
|
2646 | + return $error; |
|
2647 | + } else { |
|
2648 | + return self::check_version(true); |
|
2649 | + } |
|
2444 | 2650 | } elseif ($result['value'] == '15') { |
2445 | 2651 | $error = self::update_from_15(); |
2446 | - if ($error != '') return $error; |
|
2447 | - else return self::check_version(true); |
|
2652 | + if ($error != '') { |
|
2653 | + return $error; |
|
2654 | + } else { |
|
2655 | + return self::check_version(true); |
|
2656 | + } |
|
2448 | 2657 | } elseif ($result['value'] == '16') { |
2449 | 2658 | $error = self::update_from_16(); |
2450 | - if ($error != '') return $error; |
|
2451 | - else return self::check_version(true); |
|
2659 | + if ($error != '') { |
|
2660 | + return $error; |
|
2661 | + } else { |
|
2662 | + return self::check_version(true); |
|
2663 | + } |
|
2452 | 2664 | } elseif ($result['value'] == '17') { |
2453 | 2665 | $error = self::update_from_17(); |
2454 | - if ($error != '') return $error; |
|
2455 | - else return self::check_version(true); |
|
2666 | + if ($error != '') { |
|
2667 | + return $error; |
|
2668 | + } else { |
|
2669 | + return self::check_version(true); |
|
2670 | + } |
|
2456 | 2671 | } elseif ($result['value'] == '18') { |
2457 | 2672 | $error = self::update_from_18(); |
2458 | - if ($error != '') return $error; |
|
2459 | - else return self::check_version(true); |
|
2673 | + if ($error != '') { |
|
2674 | + return $error; |
|
2675 | + } else { |
|
2676 | + return self::check_version(true); |
|
2677 | + } |
|
2460 | 2678 | } elseif ($result['value'] == '19') { |
2461 | 2679 | $error = self::update_from_19(); |
2462 | - if ($error != '') return $error; |
|
2463 | - else return self::check_version(true); |
|
2680 | + if ($error != '') { |
|
2681 | + return $error; |
|
2682 | + } else { |
|
2683 | + return self::check_version(true); |
|
2684 | + } |
|
2464 | 2685 | } elseif ($result['value'] == '20') { |
2465 | 2686 | $error = self::update_from_20(); |
2466 | - if ($error != '') return $error; |
|
2467 | - else return self::check_version(true); |
|
2687 | + if ($error != '') { |
|
2688 | + return $error; |
|
2689 | + } else { |
|
2690 | + return self::check_version(true); |
|
2691 | + } |
|
2468 | 2692 | } elseif ($result['value'] == '21') { |
2469 | 2693 | $error = self::update_from_21(); |
2470 | - if ($error != '') return $error; |
|
2471 | - else return self::check_version(true); |
|
2694 | + if ($error != '') { |
|
2695 | + return $error; |
|
2696 | + } else { |
|
2697 | + return self::check_version(true); |
|
2698 | + } |
|
2472 | 2699 | } elseif ($result['value'] == '22') { |
2473 | 2700 | $error = self::update_from_22(); |
2474 | - if ($error != '') return $error; |
|
2475 | - else return self::check_version(true); |
|
2701 | + if ($error != '') { |
|
2702 | + return $error; |
|
2703 | + } else { |
|
2704 | + return self::check_version(true); |
|
2705 | + } |
|
2476 | 2706 | } elseif ($result['value'] == '23') { |
2477 | 2707 | $error = self::update_from_23(); |
2478 | - if ($error != '') return $error; |
|
2479 | - else return self::check_version(true); |
|
2708 | + if ($error != '') { |
|
2709 | + return $error; |
|
2710 | + } else { |
|
2711 | + return self::check_version(true); |
|
2712 | + } |
|
2480 | 2713 | } elseif ($result['value'] == '24') { |
2481 | 2714 | $error = self::update_from_24(); |
2482 | - if ($error != '') return $error; |
|
2483 | - else return self::check_version(true); |
|
2715 | + if ($error != '') { |
|
2716 | + return $error; |
|
2717 | + } else { |
|
2718 | + return self::check_version(true); |
|
2719 | + } |
|
2484 | 2720 | } elseif ($result['value'] == '25') { |
2485 | 2721 | $error = self::update_from_25(); |
2486 | - if ($error != '') return $error; |
|
2487 | - else return self::check_version(true); |
|
2722 | + if ($error != '') { |
|
2723 | + return $error; |
|
2724 | + } else { |
|
2725 | + return self::check_version(true); |
|
2726 | + } |
|
2488 | 2727 | } elseif ($result['value'] == '26') { |
2489 | 2728 | $error = self::update_from_26(); |
2490 | - if ($error != '') return $error; |
|
2491 | - else return self::check_version(true); |
|
2729 | + if ($error != '') { |
|
2730 | + return $error; |
|
2731 | + } else { |
|
2732 | + return self::check_version(true); |
|
2733 | + } |
|
2492 | 2734 | } elseif ($result['value'] == '27') { |
2493 | 2735 | $error = self::update_from_27(); |
2494 | - if ($error != '') return $error; |
|
2495 | - else return self::check_version(true); |
|
2736 | + if ($error != '') { |
|
2737 | + return $error; |
|
2738 | + } else { |
|
2739 | + return self::check_version(true); |
|
2740 | + } |
|
2496 | 2741 | } elseif ($result['value'] == '28') { |
2497 | 2742 | $error = self::update_from_28(); |
2498 | - if ($error != '') return $error; |
|
2499 | - else return self::check_version(true); |
|
2743 | + if ($error != '') { |
|
2744 | + return $error; |
|
2745 | + } else { |
|
2746 | + return self::check_version(true); |
|
2747 | + } |
|
2500 | 2748 | } elseif ($result['value'] == '29') { |
2501 | 2749 | $error = self::update_from_29(); |
2502 | - if ($error != '') return $error; |
|
2503 | - else return self::check_version(true); |
|
2750 | + if ($error != '') { |
|
2751 | + return $error; |
|
2752 | + } else { |
|
2753 | + return self::check_version(true); |
|
2754 | + } |
|
2504 | 2755 | } elseif ($result['value'] == '30') { |
2505 | 2756 | $error = self::update_from_30(); |
2506 | - if ($error != '') return $error; |
|
2507 | - else return self::check_version(true); |
|
2757 | + if ($error != '') { |
|
2758 | + return $error; |
|
2759 | + } else { |
|
2760 | + return self::check_version(true); |
|
2761 | + } |
|
2508 | 2762 | } elseif ($result['value'] == '31') { |
2509 | 2763 | $error = self::update_from_31(); |
2510 | - if ($error != '') return $error; |
|
2511 | - else return self::check_version(true); |
|
2764 | + if ($error != '') { |
|
2765 | + return $error; |
|
2766 | + } else { |
|
2767 | + return self::check_version(true); |
|
2768 | + } |
|
2512 | 2769 | } elseif ($result['value'] == '32') { |
2513 | 2770 | $error = self::update_from_32(); |
2514 | - if ($error != '') return $error; |
|
2515 | - else return self::check_version(true); |
|
2771 | + if ($error != '') { |
|
2772 | + return $error; |
|
2773 | + } else { |
|
2774 | + return self::check_version(true); |
|
2775 | + } |
|
2516 | 2776 | } elseif ($result['value'] == '33') { |
2517 | 2777 | $error = self::update_from_33(); |
2518 | - if ($error != '') return $error; |
|
2519 | - else return self::check_version(true); |
|
2778 | + if ($error != '') { |
|
2779 | + return $error; |
|
2780 | + } else { |
|
2781 | + return self::check_version(true); |
|
2782 | + } |
|
2520 | 2783 | } elseif ($result['value'] == '34') { |
2521 | 2784 | $error = self::update_from_34(); |
2522 | - if ($error != '') return $error; |
|
2523 | - else return self::check_version(true); |
|
2785 | + if ($error != '') { |
|
2786 | + return $error; |
|
2787 | + } else { |
|
2788 | + return self::check_version(true); |
|
2789 | + } |
|
2524 | 2790 | } elseif ($result['value'] == '35') { |
2525 | 2791 | $error = self::update_from_35(); |
2526 | - if ($error != '') return $error; |
|
2527 | - else return self::check_version(true); |
|
2792 | + if ($error != '') { |
|
2793 | + return $error; |
|
2794 | + } else { |
|
2795 | + return self::check_version(true); |
|
2796 | + } |
|
2528 | 2797 | } elseif ($result['value'] == '36') { |
2529 | 2798 | $error = self::update_from_36(); |
2530 | - if ($error != '') return $error; |
|
2531 | - else return self::check_version(true); |
|
2799 | + if ($error != '') { |
|
2800 | + return $error; |
|
2801 | + } else { |
|
2802 | + return self::check_version(true); |
|
2803 | + } |
|
2532 | 2804 | } elseif ($result['value'] == '37') { |
2533 | 2805 | $error = self::update_from_37(); |
2534 | - if ($error != '') return $error; |
|
2535 | - else return self::check_version(true); |
|
2806 | + if ($error != '') { |
|
2807 | + return $error; |
|
2808 | + } else { |
|
2809 | + return self::check_version(true); |
|
2810 | + } |
|
2536 | 2811 | } elseif ($result['value'] == '38') { |
2537 | 2812 | $error = self::update_from_38(); |
2538 | - if ($error != '') return $error; |
|
2539 | - else return self::check_version(true); |
|
2813 | + if ($error != '') { |
|
2814 | + return $error; |
|
2815 | + } else { |
|
2816 | + return self::check_version(true); |
|
2817 | + } |
|
2540 | 2818 | } elseif ($result['value'] == '39') { |
2541 | 2819 | $error = self::update_from_39(); |
2542 | - if ($error != '') return $error; |
|
2543 | - else return self::check_version(true); |
|
2820 | + if ($error != '') { |
|
2821 | + return $error; |
|
2822 | + } else { |
|
2823 | + return self::check_version(true); |
|
2824 | + } |
|
2544 | 2825 | } elseif ($result['value'] == '40') { |
2545 | 2826 | $error = self::update_from_40(); |
2546 | - if ($error != '') return $error; |
|
2547 | - else return self::check_version(true); |
|
2827 | + if ($error != '') { |
|
2828 | + return $error; |
|
2829 | + } else { |
|
2830 | + return self::check_version(true); |
|
2831 | + } |
|
2548 | 2832 | } elseif ($result['value'] == '41') { |
2549 | 2833 | $error = self::update_from_41(); |
2550 | - if ($error != '') return $error; |
|
2551 | - else return self::check_version(true); |
|
2834 | + if ($error != '') { |
|
2835 | + return $error; |
|
2836 | + } else { |
|
2837 | + return self::check_version(true); |
|
2838 | + } |
|
2552 | 2839 | } elseif ($result['value'] == '42') { |
2553 | 2840 | $error = self::update_from_42(); |
2554 | - if ($error != '') return $error; |
|
2555 | - else return self::check_version(true); |
|
2841 | + if ($error != '') { |
|
2842 | + return $error; |
|
2843 | + } else { |
|
2844 | + return self::check_version(true); |
|
2845 | + } |
|
2556 | 2846 | } elseif ($result['value'] == '43') { |
2557 | 2847 | $error = self::update_from_43(); |
2558 | - if ($error != '') return $error; |
|
2559 | - else return self::check_version(true); |
|
2848 | + if ($error != '') { |
|
2849 | + return $error; |
|
2850 | + } else { |
|
2851 | + return self::check_version(true); |
|
2852 | + } |
|
2560 | 2853 | } elseif ($result['value'] == '44') { |
2561 | 2854 | $error = self::update_from_44(); |
2562 | - if ($error != '') return $error; |
|
2563 | - else return self::check_version(true); |
|
2855 | + if ($error != '') { |
|
2856 | + return $error; |
|
2857 | + } else { |
|
2858 | + return self::check_version(true); |
|
2859 | + } |
|
2564 | 2860 | } elseif ($result['value'] == '45') { |
2565 | 2861 | $error = self::update_from_45(); |
2566 | - if ($error != '') return $error; |
|
2567 | - else return self::check_version(true); |
|
2862 | + if ($error != '') { |
|
2863 | + return $error; |
|
2864 | + } else { |
|
2865 | + return self::check_version(true); |
|
2866 | + } |
|
2568 | 2867 | } elseif ($result['value'] == '46') { |
2569 | 2868 | $error = self::update_from_46(); |
2570 | - if ($error != '') return $error; |
|
2571 | - else return self::check_version(true); |
|
2869 | + if ($error != '') { |
|
2870 | + return $error; |
|
2871 | + } else { |
|
2872 | + return self::check_version(true); |
|
2873 | + } |
|
2572 | 2874 | } elseif ($result['value'] == '47') { |
2573 | 2875 | $error = self::update_from_47(); |
2574 | - if ($error != '') return $error; |
|
2575 | - else return self::check_version(true); |
|
2876 | + if ($error != '') { |
|
2877 | + return $error; |
|
2878 | + } else { |
|
2879 | + return self::check_version(true); |
|
2880 | + } |
|
2576 | 2881 | } elseif ($result['value'] == '48') { |
2577 | 2882 | $error = self::update_from_48(); |
2578 | - if ($error != '') return $error; |
|
2579 | - else return self::check_version(true); |
|
2883 | + if ($error != '') { |
|
2884 | + return $error; |
|
2885 | + } else { |
|
2886 | + return self::check_version(true); |
|
2887 | + } |
|
2580 | 2888 | } elseif ($result['value'] == '49') { |
2581 | 2889 | $error = self::update_from_49(); |
2582 | - if ($error != '') return $error; |
|
2583 | - else return self::check_version(true); |
|
2890 | + if ($error != '') { |
|
2891 | + return $error; |
|
2892 | + } else { |
|
2893 | + return self::check_version(true); |
|
2894 | + } |
|
2584 | 2895 | } elseif ($result['value'] == '50') { |
2585 | 2896 | $error = self::update_from_50(); |
2586 | - if ($error != '') return $error; |
|
2587 | - else return self::check_version(true); |
|
2897 | + if ($error != '') { |
|
2898 | + return $error; |
|
2899 | + } else { |
|
2900 | + return self::check_version(true); |
|
2901 | + } |
|
2588 | 2902 | } elseif ($result['value'] == '51') { |
2589 | 2903 | $error = self::update_from_51(); |
2590 | - if ($error != '') return $error; |
|
2591 | - else return self::check_version(true); |
|
2904 | + if ($error != '') { |
|
2905 | + return $error; |
|
2906 | + } else { |
|
2907 | + return self::check_version(true); |
|
2908 | + } |
|
2592 | 2909 | } elseif ($result['value'] == '52') { |
2593 | 2910 | $error = self::update_from_52(); |
2594 | - if ($error != '') return $error; |
|
2595 | - else return self::check_version(true); |
|
2596 | - } else return ''; |
|
2911 | + if ($error != '') { |
|
2912 | + return $error; |
|
2913 | + } else { |
|
2914 | + return self::check_version(true); |
|
2915 | + } |
|
2916 | + } else { |
|
2917 | + return ''; |
|
2918 | + } |
|
2597 | 2919 | } else { |
2598 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2599 | - else return 0; |
|
2920 | + if (isset($result['value']) && $result['value'] != '') { |
|
2921 | + return $result['value']; |
|
2922 | + } else { |
|
2923 | + return 0; |
|
2924 | + } |
|
2600 | 2925 | } |
2601 | 2926 | } |
2602 | - } else return $version; |
|
2927 | + } else { |
|
2928 | + return $version; |
|
2929 | + } |
|
2603 | 2930 | } |
2604 | 2931 | } |
2605 | 2932 | } |