@@ -15,8 +15,12 @@ discard block |
||
15 | 15 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
16 | 16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
17 | 17 | $sql_date = $end_date; |
18 | - } else $sql_date = ''; |
|
19 | -} else $sql_date = ''; |
|
18 | + } else { |
|
19 | + $sql_date = ''; |
|
20 | + } |
|
21 | + } else { |
|
22 | + $sql_date = ''; |
|
23 | +} |
|
20 | 24 | |
21 | 25 | if (isset($_GET['highest_altitude'])) { |
22 | 26 | //for altitude manipulation |
@@ -30,8 +34,12 @@ discard block |
||
30 | 34 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
31 | 35 | $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000"; |
32 | 36 | $sql_altitude = $start_altitude; |
33 | - } else $sql_altitude = ''; |
|
34 | -} else $sql_altitude = ''; |
|
37 | + } else { |
|
38 | + $sql_altitude = ''; |
|
39 | + } |
|
40 | + } else { |
|
41 | + $sql_altitude = ''; |
|
42 | +} |
|
35 | 43 | |
36 | 44 | //calculuation for the pagination |
37 | 45 | if(!isset($_GET['limit'])) |
@@ -48,7 +56,7 @@ discard block |
||
48 | 56 | $limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
49 | 57 | $absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
50 | 58 | } |
51 | -} else { |
|
59 | +} else { |
|
52 | 60 | $limit_explode = explode(",", $_GET['limit']); |
53 | 61 | $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
54 | 62 | $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
@@ -66,8 +74,11 @@ discard block |
||
66 | 74 | |
67 | 75 | header('Content-Type: text/xml'); |
68 | 76 | |
69 | -if (isset($_GET['sort'])) $sort = $_GET['sort']; |
|
70 | -else $sort = ''; |
|
77 | +if (isset($_GET['sort'])) { |
|
78 | + $sort = $_GET['sort']; |
|
79 | +} else { |
|
80 | + $sort = ''; |
|
81 | +} |
|
71 | 82 | $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
72 | 83 | $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
73 | 84 | $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |
@@ -123,7 +134,9 @@ discard block |
||
123 | 134 | $waypoint_pieces = explode(' ', $spotter_item['waypoints']); |
124 | 135 | $waypoint_pieces = array_chunk($waypoint_pieces, 2); |
125 | 136 | foreach ($waypoint_pieces as $waypoint_coordinate) { |
126 | - if (isset($waypoint_coordinate[1])) $output .= $waypoint_coordinate[1].','.$waypoint_coordinate[0].','.$altitude.' '; |
|
137 | + if (isset($waypoint_coordinate[1])) { |
|
138 | + $output .= $waypoint_coordinate[1].','.$waypoint_coordinate[0].','.$altitude.' '; |
|
139 | + } |
|
127 | 140 | } |
128 | 141 | $output .= '</coordinates>'; |
129 | 142 | $output .= '<altitudeMode>absolute</altitudeMode>'; |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | } |
44 | 44 | $Stats = new Stats($Spotter->db); |
45 | 45 | $airline_names = $Stats->getAllAirlineNames(); |
46 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
46 | + if (empty($airline_names)) { |
|
47 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
48 | + } |
|
47 | 49 | foreach($airline_names as $airline_name) |
48 | 50 | { |
49 | 51 | if($airline == $airline_name['airline_icao']) |
@@ -66,8 +68,7 @@ discard block |
||
66 | 68 | if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif')) |
67 | 69 | { |
68 | 70 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
69 | - } |
|
70 | - elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
71 | + } elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
71 | 72 | { |
72 | 73 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
73 | 74 | } |
@@ -131,7 +132,9 @@ discard block |
||
131 | 132 | $images = $Image->getSpotterImage($aircraft_item['registration']); |
132 | 133 | if (isset($images['image_thumbnail'])) { |
133 | 134 | $aircraft_item['image_thumbnail'] = $images['image_thumbnail']; |
134 | - } else $aircraft_item['image_thumbnail'] = ''; |
|
135 | + } else { |
|
136 | + $aircraft_item['image_thumbnail'] = ''; |
|
137 | + } |
|
135 | 138 | } |
136 | 139 | if ($aircraft_item['image_thumbnail'] != "") |
137 | 140 | { |
@@ -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) { |
@@ -80,8 +84,11 @@ discard block |
||
80 | 84 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
81 | 85 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
82 | 86 | } |
83 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
84 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
87 | + if ($filter_query_where == '' && $where) { |
|
88 | + $filter_query_where = ' WHERE'; |
|
89 | + } elseif ($filter_query_where != '' && $and) { |
|
90 | + $filter_query_where .= ' AND'; |
|
91 | + } |
|
85 | 92 | if ($filter_query_where != '') { |
86 | 93 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
87 | 94 | } |
@@ -122,9 +129,13 @@ discard block |
||
122 | 129 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
123 | 130 | } |
124 | 131 | } |
125 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
132 | + if ($orderby_query == '') { |
|
133 | + $orderby_query= ' ORDER BY date DESC'; |
|
134 | + } |
|
126 | 135 | |
127 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
136 | + if (!isset($globalLiveInterval)) { |
|
137 | + $globalLiveInterval = '200'; |
|
138 | + } |
|
128 | 139 | if ($globalDBdriver == 'mysql') { |
129 | 140 | //$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"; |
130 | 141 | $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; |
@@ -149,7 +160,9 @@ discard block |
||
149 | 160 | |
150 | 161 | $filter_query = $this->getFilter($filter,true,true); |
151 | 162 | |
152 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
163 | + if (!isset($globalLiveInterval)) { |
|
164 | + $globalLiveInterval = '200'; |
|
165 | + } |
|
153 | 166 | if ($globalDBdriver == 'mysql') { |
154 | 167 | $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 |
155 | 168 | 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"; |
@@ -190,48 +203,72 @@ discard block |
||
190 | 203 | } |
191 | 204 | $filter_query = $this->getFilter($filter,true,true); |
192 | 205 | |
193 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
194 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
206 | + if (!isset($globalLiveInterval)) { |
|
207 | + $globalLiveInterval = '200'; |
|
208 | + } |
|
209 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
210 | + $globalMap3DMarinesLimit = '300'; |
|
211 | + } |
|
195 | 212 | if ($globalDBdriver == 'mysql') { |
196 | 213 | if (isset($globalArchive) && $globalArchive === TRUE) { |
197 | 214 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
198 | 215 | 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 "; |
199 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
216 | + if ($usecoord) { |
|
217 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
218 | + } |
|
200 | 219 | $query .= "UNION |
201 | 220 | 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 |
202 | 221 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
203 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
222 | + if ($usecoord) { |
|
223 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
224 | + } |
|
204 | 225 | $query .= ") AS marine |
205 | 226 | WHERE latitude <> '0' AND longitude <> '0' |
206 | 227 | ORDER BY fammarine_id, date"; |
207 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
228 | + if ($limit) { |
|
229 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
230 | + } |
|
208 | 231 | } else { |
209 | 232 | $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 |
210 | 233 | 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." "; |
|
234 | + if ($usecoord) { |
|
235 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
236 | + } |
|
212 | 237 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
213 | 238 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
214 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
239 | + if ($limit) { |
|
240 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
241 | + } |
|
215 | 242 | } |
216 | 243 | } else { |
217 | 244 | if (isset($globalArchive) && $globalArchive === TRUE) { |
218 | 245 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
219 | 246 | 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 "; |
220 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
247 | + if ($usecoord) { |
|
248 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
249 | + } |
|
221 | 250 | $query .= "UNION |
222 | 251 | 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 |
223 | 252 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
224 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
253 | + if ($usecoord) { |
|
254 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
255 | + } |
|
225 | 256 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
226 | 257 | $query .= "ORDER BY fammarine_id, date"; |
227 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
258 | + if ($limit) { |
|
259 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
260 | + } |
|
228 | 261 | } else { |
229 | 262 | $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 |
230 | 263 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
231 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
264 | + if ($usecoord) { |
|
265 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
266 | + } |
|
232 | 267 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
233 | 268 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
234 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
269 | + if ($limit) { |
|
270 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
271 | + } |
|
235 | 272 | } |
236 | 273 | } |
237 | 274 | try { |
@@ -256,7 +293,9 @@ discard block |
||
256 | 293 | global $globalDBdriver, $globalLiveInterval; |
257 | 294 | $filter_query = $this->getFilter($filter,true,true); |
258 | 295 | |
259 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
296 | + if (!isset($globalLiveInterval)) { |
|
297 | + $globalLiveInterval = '200'; |
|
298 | + } |
|
260 | 299 | if ($globalDBdriver == 'mysql') { |
261 | 300 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
262 | 301 | } else { |
@@ -284,7 +323,9 @@ discard block |
||
284 | 323 | { |
285 | 324 | global $globalDBdriver, $globalLiveInterval; |
286 | 325 | $Marine = new Marine($this->db); |
287 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
326 | + if (!isset($globalLiveInterval)) { |
|
327 | + $globalLiveInterval = '200'; |
|
328 | + } |
|
288 | 329 | $filter_query = $this->getFilter($filter); |
289 | 330 | |
290 | 331 | if (is_array($coord)) { |
@@ -292,7 +333,9 @@ discard block |
||
292 | 333 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
293 | 334 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
294 | 335 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
295 | - } else return array(); |
|
336 | + } else { |
|
337 | + return array(); |
|
338 | + } |
|
296 | 339 | if ($globalDBdriver == 'mysql') { |
297 | 340 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
298 | 341 | } else { |
@@ -312,7 +355,9 @@ discard block |
||
312 | 355 | { |
313 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
314 | 357 | $Marine = new Marine($this->db); |
315 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
358 | + if (!isset($globalLiveInterval)) { |
|
359 | + $globalLiveInterval = '200'; |
|
360 | + } |
|
316 | 361 | $filter_query = $this->getFilter($filter,true,true); |
317 | 362 | |
318 | 363 | if (is_array($coord)) { |
@@ -320,7 +365,9 @@ discard block |
||
320 | 365 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
321 | 366 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
322 | 367 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
323 | - } else return array(); |
|
368 | + } else { |
|
369 | + return array(); |
|
370 | + } |
|
324 | 371 | /* |
325 | 372 | if ($globalDBdriver == 'mysql') { |
326 | 373 | $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 |
@@ -543,11 +590,15 @@ discard block |
||
543 | 590 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
544 | 591 | if ($globalDBdriver == 'mysql') { |
545 | 592 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
546 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
593 | + if ($liveinterval) { |
|
594 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
595 | + } |
|
547 | 596 | $query .= ' ORDER BY date'; |
548 | 597 | } else { |
549 | 598 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
550 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
599 | + if ($liveinterval) { |
|
600 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
601 | + } |
|
551 | 602 | $query .= ' ORDER BY date'; |
552 | 603 | } |
553 | 604 | |
@@ -642,7 +693,9 @@ discard block |
||
642 | 693 | $i++; |
643 | 694 | $j++; |
644 | 695 | if ($j == 30) { |
645 | - if ($globalDebug) echo "."; |
|
696 | + if ($globalDebug) { |
|
697 | + echo "."; |
|
698 | + } |
|
646 | 699 | try { |
647 | 700 | |
648 | 701 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -922,7 +975,9 @@ discard block |
||
922 | 975 | { |
923 | 976 | return false; |
924 | 977 | } |
925 | - } else return ''; |
|
978 | + } else { |
|
979 | + return ''; |
|
980 | + } |
|
926 | 981 | |
927 | 982 | if ($longitude != '') |
928 | 983 | { |
@@ -930,7 +985,9 @@ discard block |
||
930 | 985 | { |
931 | 986 | return false; |
932 | 987 | } |
933 | - } else return ''; |
|
988 | + } else { |
|
989 | + return ''; |
|
990 | + } |
|
934 | 991 | |
935 | 992 | |
936 | 993 | if ($heading != '') |
@@ -939,7 +996,9 @@ discard block |
||
939 | 996 | { |
940 | 997 | return false; |
941 | 998 | } |
942 | - } else $heading = 0; |
|
999 | + } else { |
|
1000 | + $heading = 0; |
|
1001 | + } |
|
943 | 1002 | |
944 | 1003 | if ($groundspeed != '') |
945 | 1004 | { |
@@ -947,9 +1006,13 @@ discard block |
||
947 | 1006 | { |
948 | 1007 | return false; |
949 | 1008 | } |
950 | - } else $groundspeed = 0; |
|
1009 | + } else { |
|
1010 | + $groundspeed = 0; |
|
1011 | + } |
|
951 | 1012 | date_default_timezone_set('UTC'); |
952 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1013 | + if ($date == '') { |
|
1014 | + $date = date("Y-m-d H:i:s", time()); |
|
1015 | + } |
|
953 | 1016 | |
954 | 1017 | |
955 | 1018 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -970,15 +1033,27 @@ discard block |
||
970 | 1033 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
971 | 1034 | $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
972 | 1035 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
973 | - if ($typeid == '') $typeid = NULL; |
|
974 | - if ($statusid == '') $statusid = NULL; |
|
1036 | + if ($typeid == '') { |
|
1037 | + $typeid = NULL; |
|
1038 | + } |
|
1039 | + if ($statusid == '') { |
|
1040 | + $statusid = NULL; |
|
1041 | + } |
|
975 | 1042 | |
976 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
977 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
978 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1043 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1044 | + $groundspeed = 0; |
|
1045 | + } |
|
1046 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1047 | + $heading = 0; |
|
1048 | + } |
|
1049 | + if ($arrival_date == '') { |
|
1050 | + $arrival_date = NULL; |
|
1051 | + } |
|
979 | 1052 | $query = ''; |
980 | 1053 | if ($globalArchive) { |
981 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1054 | + if ($globalDebug) { |
|
1055 | + echo '-- Delete previous data -- '; |
|
1056 | + } |
|
982 | 1057 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
983 | 1058 | } |
984 | 1059 | $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) |
@@ -993,10 +1068,14 @@ discard block |
||
993 | 1068 | } |
994 | 1069 | |
995 | 1070 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
996 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1071 | + if ($globalDebug) { |
|
1072 | + echo '(Add to Marine archive : '; |
|
1073 | + } |
|
997 | 1074 | $MarineArchive = new MarineArchive($this->db); |
998 | 1075 | $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); |
999 | - if ($globalDebug) echo $result.')'; |
|
1076 | + if ($globalDebug) { |
|
1077 | + echo $result.')'; |
|
1078 | + } |
|
1000 | 1079 | } |
1001 | 1080 | return "success"; |
1002 | 1081 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $limit_start = 0; |
15 | 15 | $limit_end = 25; |
16 | 16 | $absolute_difference = 25; |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
19 | 19 | $limit_start = $limit_explode[0]; |
20 | 20 | $limit_end = $limit_explode[1]; |
@@ -6,7 +6,9 @@ |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Vessel Type"); |
7 | 7 | |
8 | 8 | $type = 'marine'; |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
11 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
12 | 14 |
@@ -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) { |
@@ -72,8 +76,11 @@ discard block |
||
72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 77 | } |
74 | 78 | } |
75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
79 | + if ($filter_query_where == '' && $where) { |
|
80 | + $filter_query_where = ' WHERE'; |
|
81 | + } elseif ($filter_query_where != '' && $and) { |
|
82 | + $filter_query_where .= ' AND'; |
|
83 | + } |
|
77 | 84 | if ($filter_query_where != '') { |
78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
79 | 86 | } |
@@ -127,35 +134,63 @@ discard block |
||
127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
130 | - */} |
|
131 | - elseif (isset($row['marineid'])) { |
|
137 | + */} elseif (isset($row['marineid'])) { |
|
132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
133 | 139 | } else { |
134 | 140 | $temp_array['marine_id'] = ''; |
135 | 141 | } |
136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
140 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
141 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
142 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
143 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
144 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
145 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
146 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | + if (isset($row['fammarine_id'])) { |
|
143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
144 | + } |
|
145 | + if (isset($row['mmsi'])) { |
|
146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
147 | + } |
|
148 | + if (isset($row['type'])) { |
|
149 | + $temp_array['type'] = $row['type']; |
|
150 | + } |
|
151 | + if (isset($row['type_id'])) { |
|
152 | + $temp_array['type_id'] = $row['type_id']; |
|
153 | + } |
|
154 | + if (isset($row['status'])) { |
|
155 | + $temp_array['status'] = $row['status']; |
|
156 | + } |
|
157 | + if (isset($row['status_id'])) { |
|
158 | + $temp_array['status_id'] = $row['status_id']; |
|
159 | + } |
|
160 | + if (isset($row['ident'])) { |
|
161 | + $temp_array['ident'] = $row['ident']; |
|
162 | + } |
|
163 | + if (isset($row['arrival_port_name'])) { |
|
164 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
165 | + } |
|
166 | + if (isset($row['latitude'])) { |
|
167 | + $temp_array['latitude'] = $row['latitude']; |
|
168 | + } |
|
169 | + if (isset($row['longitude'])) { |
|
170 | + $temp_array['longitude'] = $row['longitude']; |
|
171 | + } |
|
172 | + if (isset($row['format_source'])) { |
|
173 | + $temp_array['format_source'] = $row['format_source']; |
|
174 | + } |
|
147 | 175 | if (isset($row['heading'])) { |
148 | 176 | $temp_array['heading'] = $row['heading']; |
149 | 177 | $heading_direction = $this->parseDirection($row['heading']); |
150 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
178 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
179 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
180 | + } |
|
181 | + } |
|
182 | + if (isset($row['ground_speed'])) { |
|
183 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
151 | 184 | } |
152 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
153 | 185 | |
154 | 186 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
155 | 187 | { |
156 | 188 | $Image = new Image($this->db); |
157 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
158 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
189 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
190 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
191 | + } else { |
|
192 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
193 | + } |
|
159 | 194 | unset($Image); |
160 | 195 | if (count($image_array) > 0) { |
161 | 196 | $temp_array['image'] = $image_array[0]['image']; |
@@ -207,13 +242,21 @@ discard block |
||
207 | 242 | } |
208 | 243 | |
209 | 244 | $fromsource = NULL; |
210 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
211 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
212 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
245 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
246 | + $temp_array['source_name'] = $row['source_name']; |
|
247 | + } |
|
248 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
249 | + $temp_array['over_country'] = $row['over_country']; |
|
250 | + } |
|
251 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
252 | + $temp_array['distance'] = $row['distance']; |
|
253 | + } |
|
213 | 254 | $temp_array['query_number_rows'] = $num_rows; |
214 | 255 | $spotter_array[] = $temp_array; |
215 | 256 | } |
216 | - if ($num_rows == 0) return array(); |
|
257 | + if ($num_rows == 0) { |
|
258 | + return array(); |
|
259 | + } |
|
217 | 260 | $spotter_array[0]['query_number_rows'] = $num_rows; |
218 | 261 | return $spotter_array; |
219 | 262 | } |
@@ -239,8 +282,12 @@ discard block |
||
239 | 282 | { |
240 | 283 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
241 | 284 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
242 | - } else $limit_query = ""; |
|
243 | - } else $limit_query = ""; |
|
285 | + } else { |
|
286 | + $limit_query = ""; |
|
287 | + } |
|
288 | + } else { |
|
289 | + $limit_query = ""; |
|
290 | + } |
|
244 | 291 | if ($sort != "") |
245 | 292 | { |
246 | 293 | $search_orderby_array = $this->getOrderBy(); |
@@ -264,7 +311,9 @@ discard block |
||
264 | 311 | global $global_query; |
265 | 312 | |
266 | 313 | date_default_timezone_set('UTC'); |
267 | - if ($id == '') return array(); |
|
314 | + if ($id == '') { |
|
315 | + return array(); |
|
316 | + } |
|
268 | 317 | $additional_query = "marine_output.fammarine_id = :id"; |
269 | 318 | $query_values = array(':id' => $id); |
270 | 319 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -460,8 +509,11 @@ discard block |
||
460 | 509 | $query .= " ORDER BY marine_output.source_name ASC"; |
461 | 510 | |
462 | 511 | $sth = $this->db->prepare($query); |
463 | - if (!empty($query_values)) $sth->execute($query_values); |
|
464 | - else $sth->execute(); |
|
512 | + if (!empty($query_values)) { |
|
513 | + $sth->execute($query_values); |
|
514 | + } else { |
|
515 | + $sth->execute(); |
|
516 | + } |
|
465 | 517 | |
466 | 518 | $source_array = array(); |
467 | 519 | $temp_array = array(); |
@@ -516,8 +568,11 @@ discard block |
||
516 | 568 | $sth = $this->db->prepare($query); |
517 | 569 | $sth->execute(array(':mmsi' => $mmsi)); |
518 | 570 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
519 | - if (isset($result[0])) return $result[0]; |
|
520 | - else return array(); |
|
571 | + if (isset($result[0])) { |
|
572 | + return $result[0]; |
|
573 | + } else { |
|
574 | + return array(); |
|
575 | + } |
|
521 | 576 | } |
522 | 577 | |
523 | 578 | /** |
@@ -558,7 +613,9 @@ discard block |
||
558 | 613 | date_default_timezone_set($globalTimezone); |
559 | 614 | $datetime = new DateTime(); |
560 | 615 | $offset = $datetime->format('P'); |
561 | - } else $offset = '+00:00'; |
|
616 | + } else { |
|
617 | + $offset = '+00:00'; |
|
618 | + } |
|
562 | 619 | |
563 | 620 | if ($globalDBdriver == 'mysql') { |
564 | 621 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -804,11 +861,21 @@ discard block |
||
804 | 861 | $latitude = 0; |
805 | 862 | $longitude = 0; |
806 | 863 | } |
807 | - if ($type_id == '') $type_id = NULL; |
|
808 | - if ($status_id == '') $status_id = NULL; |
|
809 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
810 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
811 | - if ($arrival_date == '') $arrival_date = NULL; |
|
864 | + if ($type_id == '') { |
|
865 | + $type_id = NULL; |
|
866 | + } |
|
867 | + if ($status_id == '') { |
|
868 | + $status_id = NULL; |
|
869 | + } |
|
870 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
871 | + $heading = 0; |
|
872 | + } |
|
873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
874 | + $groundspeed = 0; |
|
875 | + } |
|
876 | + if ($arrival_date == '') { |
|
877 | + $arrival_date = NULL; |
|
878 | + } |
|
812 | 879 | $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) |
813 | 880 | 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)"; |
814 | 881 | |
@@ -915,7 +982,9 @@ discard block |
||
915 | 982 | global $globalDBdriver, $globalArchive; |
916 | 983 | //$filter_query = $this->getFilter($filters,true,true); |
917 | 984 | $Connection= new Connection($this->db); |
918 | - if (!$Connection->tableExists('countries')) return array(); |
|
985 | + if (!$Connection->tableExists('countries')) { |
|
986 | + return array(); |
|
987 | + } |
|
919 | 988 | require_once('class.SpotterLive.php'); |
920 | 989 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
921 | 990 | $MarineLive = new MarineLive($this->db); |
@@ -959,7 +1028,9 @@ discard block |
||
959 | 1028 | $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 "; |
960 | 1029 | } |
961 | 1030 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
962 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1031 | + if ($limit) { |
|
1032 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1033 | + } |
|
963 | 1034 | |
964 | 1035 | $sth = $this->db->prepare($query); |
965 | 1036 | $sth->execute(); |
@@ -993,12 +1064,18 @@ discard block |
||
993 | 1064 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
994 | 1065 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
995 | 1066 | if ($olderthanmonths > 0) { |
996 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
997 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1067 | + if ($globalDBdriver == 'mysql') { |
|
1068 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
1069 | + } else { |
|
1070 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
1071 | + } |
|
998 | 1072 | } |
999 | 1073 | if ($sincedate != '') { |
1000 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1001 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1074 | + if ($globalDBdriver == 'mysql') { |
|
1075 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
1076 | + } else { |
|
1077 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
1078 | + } |
|
1002 | 1079 | } |
1003 | 1080 | $query_values = array(); |
1004 | 1081 | if ($year != '') { |
@@ -1029,7 +1106,9 @@ discard block |
||
1029 | 1106 | } |
1030 | 1107 | } |
1031 | 1108 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
1032 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1109 | + if ($limit) { |
|
1110 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1111 | + } |
|
1033 | 1112 | |
1034 | 1113 | $sth = $this->db->prepare($query); |
1035 | 1114 | $sth->execute($query_values); |
@@ -1064,7 +1143,9 @@ discard block |
||
1064 | 1143 | date_default_timezone_set($globalTimezone); |
1065 | 1144 | $datetime = new DateTime(); |
1066 | 1145 | $offset = $datetime->format('P'); |
1067 | - } else $offset = '+00:00'; |
|
1146 | + } else { |
|
1147 | + $offset = '+00:00'; |
|
1148 | + } |
|
1068 | 1149 | |
1069 | 1150 | if ($globalDBdriver == 'mysql') { |
1070 | 1151 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1114,7 +1195,9 @@ discard block |
||
1114 | 1195 | date_default_timezone_set($globalTimezone); |
1115 | 1196 | $datetime = new DateTime(); |
1116 | 1197 | $offset = $datetime->format('P'); |
1117 | - } else $offset = '+00:00'; |
|
1198 | + } else { |
|
1199 | + $offset = '+00:00'; |
|
1200 | + } |
|
1118 | 1201 | $filter_query = $this->getFilter($filters,true,true); |
1119 | 1202 | if ($globalDBdriver == 'mysql') { |
1120 | 1203 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1160,7 +1243,9 @@ discard block |
||
1160 | 1243 | date_default_timezone_set($globalTimezone); |
1161 | 1244 | $datetime = new DateTime(); |
1162 | 1245 | $offset = $datetime->format('P'); |
1163 | - } else $offset = '+00:00'; |
|
1246 | + } else { |
|
1247 | + $offset = '+00:00'; |
|
1248 | + } |
|
1164 | 1249 | $filter_query = $this->getFilter($filters,true,true); |
1165 | 1250 | if ($globalDBdriver == 'mysql') { |
1166 | 1251 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1208,7 +1293,9 @@ discard block |
||
1208 | 1293 | date_default_timezone_set($globalTimezone); |
1209 | 1294 | $datetime = new DateTime(); |
1210 | 1295 | $offset = $datetime->format('P'); |
1211 | - } else $offset = '+00:00'; |
|
1296 | + } else { |
|
1297 | + $offset = '+00:00'; |
|
1298 | + } |
|
1212 | 1299 | |
1213 | 1300 | if ($globalDBdriver == 'mysql') { |
1214 | 1301 | $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 |
@@ -1257,7 +1344,9 @@ discard block |
||
1257 | 1344 | date_default_timezone_set($globalTimezone); |
1258 | 1345 | $datetime = new DateTime(); |
1259 | 1346 | $offset = $datetime->format('P'); |
1260 | - } else $offset = '+00:00'; |
|
1347 | + } else { |
|
1348 | + $offset = '+00:00'; |
|
1349 | + } |
|
1261 | 1350 | $filter_query = $this->getFilter($filters,true,true); |
1262 | 1351 | if ($globalDBdriver == 'mysql') { |
1263 | 1352 | $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 |
@@ -1306,7 +1395,9 @@ discard block |
||
1306 | 1395 | date_default_timezone_set($globalTimezone); |
1307 | 1396 | $datetime = new DateTime(); |
1308 | 1397 | $offset = $datetime->format('P'); |
1309 | - } else $offset = '+00:00'; |
|
1398 | + } else { |
|
1399 | + $offset = '+00:00'; |
|
1400 | + } |
|
1310 | 1401 | |
1311 | 1402 | $orderby_sql = ''; |
1312 | 1403 | if ($orderby == "hour") |
@@ -1375,7 +1466,9 @@ discard block |
||
1375 | 1466 | date_default_timezone_set($globalTimezone); |
1376 | 1467 | $datetime = new DateTime($date); |
1377 | 1468 | $offset = $datetime->format('P'); |
1378 | - } else $offset = '+00:00'; |
|
1469 | + } else { |
|
1470 | + $offset = '+00:00'; |
|
1471 | + } |
|
1379 | 1472 | |
1380 | 1473 | if ($globalDBdriver == 'mysql') { |
1381 | 1474 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1423,7 +1516,9 @@ discard block |
||
1423 | 1516 | date_default_timezone_set($globalTimezone); |
1424 | 1517 | $datetime = new DateTime(); |
1425 | 1518 | $offset = $datetime->format('P'); |
1426 | - } else $offset = '+00:00'; |
|
1519 | + } else { |
|
1520 | + $offset = '+00:00'; |
|
1521 | + } |
|
1427 | 1522 | |
1428 | 1523 | if ($globalDBdriver == 'mysql') { |
1429 | 1524 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1488,8 +1583,11 @@ discard block |
||
1488 | 1583 | $query_values = array_merge($query_values,array(':month' => $month)); |
1489 | 1584 | } |
1490 | 1585 | } |
1491 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1492 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1586 | + if (empty($query_values)) { |
|
1587 | + $queryi .= $this->getFilter($filters); |
|
1588 | + } else { |
|
1589 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1590 | + } |
|
1493 | 1591 | |
1494 | 1592 | $sth = $this->db->prepare($queryi); |
1495 | 1593 | $sth->execute($query_values); |
@@ -1526,8 +1624,11 @@ discard block |
||
1526 | 1624 | $query_values = array_merge($query_values,array(':month' => $month)); |
1527 | 1625 | } |
1528 | 1626 | } |
1529 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1530 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1627 | + if (empty($query_values)) { |
|
1628 | + $queryi .= $this->getFilter($filters); |
|
1629 | + } else { |
|
1630 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1631 | + } |
|
1531 | 1632 | |
1532 | 1633 | $sth = $this->db->prepare($queryi); |
1533 | 1634 | $sth->execute($query_values); |
@@ -1549,7 +1650,9 @@ discard block |
||
1549 | 1650 | date_default_timezone_set($globalTimezone); |
1550 | 1651 | $datetime = new DateTime(); |
1551 | 1652 | $offset = $datetime->format('P'); |
1552 | - } else $offset = '+00:00'; |
|
1653 | + } else { |
|
1654 | + $offset = '+00:00'; |
|
1655 | + } |
|
1553 | 1656 | |
1554 | 1657 | if ($globalDBdriver == 'mysql') { |
1555 | 1658 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1653,7 +1756,9 @@ discard block |
||
1653 | 1756 | */ |
1654 | 1757 | public function parseDirection($direction = 0) |
1655 | 1758 | { |
1656 | - if ($direction == '') $direction = 0; |
|
1759 | + if ($direction == '') { |
|
1760 | + $direction = 0; |
|
1761 | + } |
|
1657 | 1762 | $direction_array = array(); |
1658 | 1763 | $temp_array = array(); |
1659 | 1764 | |
@@ -1742,7 +1847,9 @@ discard block |
||
1742 | 1847 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1743 | 1848 | |
1744 | 1849 | $Connection = new Connection($this->db); |
1745 | - if (!$Connection->tableExists('countries')) return ''; |
|
1850 | + if (!$Connection->tableExists('countries')) { |
|
1851 | + return ''; |
|
1852 | + } |
|
1746 | 1853 | |
1747 | 1854 | try { |
1748 | 1855 | /* |
@@ -1762,9 +1869,13 @@ discard block |
||
1762 | 1869 | $sth->closeCursor(); |
1763 | 1870 | if (count($row) > 0) { |
1764 | 1871 | return $row; |
1765 | - } else return ''; |
|
1872 | + } else { |
|
1873 | + return ''; |
|
1874 | + } |
|
1766 | 1875 | } catch (PDOException $e) { |
1767 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1876 | + if (isset($globalDebug) && $globalDebug) { |
|
1877 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1878 | + } |
|
1768 | 1879 | return ''; |
1769 | 1880 | } |
1770 | 1881 | |
@@ -1782,7 +1893,9 @@ discard block |
||
1782 | 1893 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1783 | 1894 | |
1784 | 1895 | $Connection = new Connection($this->db); |
1785 | - if (!$Connection->tableExists('countries')) return ''; |
|
1896 | + if (!$Connection->tableExists('countries')) { |
|
1897 | + return ''; |
|
1898 | + } |
|
1786 | 1899 | |
1787 | 1900 | try { |
1788 | 1901 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1794,9 +1907,13 @@ discard block |
||
1794 | 1907 | $sth->closeCursor(); |
1795 | 1908 | if (count($row) > 0) { |
1796 | 1909 | return $row; |
1797 | - } else return ''; |
|
1910 | + } else { |
|
1911 | + return ''; |
|
1912 | + } |
|
1798 | 1913 | } catch (PDOException $e) { |
1799 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1914 | + if (isset($globalDebug) && $globalDebug) { |
|
1915 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1916 | + } |
|
1800 | 1917 | return ''; |
1801 | 1918 | } |
1802 | 1919 | |
@@ -1814,7 +1931,9 @@ discard block |
||
1814 | 1931 | { |
1815 | 1932 | global $globalBitlyAccessToken; |
1816 | 1933 | |
1817 | - if ($globalBitlyAccessToken == '') return $url; |
|
1934 | + if ($globalBitlyAccessToken == '') { |
|
1935 | + return $url; |
|
1936 | + } |
|
1818 | 1937 | |
1819 | 1938 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1820 | 1939 | |
@@ -1890,7 +2009,9 @@ discard block |
||
1890 | 2009 | } |
1891 | 2010 | } |
1892 | 2011 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
1893 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
2012 | + if ($limit) { |
|
2013 | + $query .= " LIMIT 10 OFFSET 0"; |
|
2014 | + } |
|
1894 | 2015 | $sth = $this->db->prepare($query); |
1895 | 2016 | $sth->execute($query_values); |
1896 | 2017 | $marine_array = array(); |
@@ -1928,9 +2049,15 @@ discard block |
||
1928 | 2049 | foreach ($q_array as $q_item){ |
1929 | 2050 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1930 | 2051 | $additional_query .= " AND ("; |
1931 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1932 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1933 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2052 | + if (is_int($q_item)) { |
|
2053 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
2054 | + } |
|
2055 | + if (is_int($q_item)) { |
|
2056 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
2057 | + } |
|
2058 | + if (is_int($q_item)) { |
|
2059 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
2060 | + } |
|
1934 | 2061 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1935 | 2062 | $additional_query .= ")"; |
1936 | 2063 | } |
@@ -1978,7 +2105,9 @@ discard block |
||
1978 | 2105 | date_default_timezone_set($globalTimezone); |
1979 | 2106 | $datetime = new DateTime(); |
1980 | 2107 | $offset = $datetime->format('P'); |
1981 | - } else $offset = '+00:00'; |
|
2108 | + } else { |
|
2109 | + $offset = '+00:00'; |
|
2110 | + } |
|
1982 | 2111 | if ($date_array[1] != "") |
1983 | 2112 | { |
1984 | 2113 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2005,8 +2134,12 @@ discard block |
||
2005 | 2134 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
2006 | 2135 | { |
2007 | 2136 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
2008 | - } else $limit_query = ""; |
|
2009 | - } else $limit_query = ""; |
|
2137 | + } else { |
|
2138 | + $limit_query = ""; |
|
2139 | + } |
|
2140 | + } else { |
|
2141 | + $limit_query = ""; |
|
2142 | + } |
|
2010 | 2143 | if ($sort != "") |
2011 | 2144 | { |
2012 | 2145 | $search_orderby_array = $this->getOrderBy(); |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -191,7 +217,9 @@ discard block |
||
191 | 217 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
192 | 218 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
193 | 219 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
194 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
222 | + } |
|
195 | 223 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
196 | 224 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
197 | 225 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -204,7 +232,9 @@ discard block |
||
204 | 232 | } |
205 | 233 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
206 | 234 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
207 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
237 | + } |
|
208 | 238 | if (!isset($line['id'])) { |
209 | 239 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
210 | 240 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -213,7 +243,9 @@ discard block |
||
213 | 243 | } |
214 | 244 | } |
215 | 245 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
216 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
246 | + if (strtotime($line['arrival_date']) > time()) { |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
248 | + } |
|
217 | 249 | } |
218 | 250 | |
219 | 251 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
@@ -234,34 +266,49 @@ discard block |
||
234 | 266 | $Marine = new Marine($this->db); |
235 | 267 | $fromsource = NULL; |
236 | 268 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
237 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
269 | + if ($globalDebug && $result != 'success') { |
|
270 | + echo '!!! ERROR : '.$result."\n"; |
|
271 | + } |
|
238 | 272 | $Marine->db = null; |
239 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
273 | + if ($globalDebugTimeElapsed) { |
|
274 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
275 | + } |
|
240 | 276 | } |
241 | 277 | } |
242 | 278 | } |
243 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
279 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
281 | + } |
|
244 | 282 | } |
245 | 283 | |
246 | 284 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
247 | 285 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
248 | 286 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
249 | 287 | } else { |
250 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
251 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
288 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
289 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
290 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
291 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
292 | + } |
|
252 | 293 | return ''; |
253 | 294 | } |
254 | 295 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
255 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
296 | + if ($globalDebug) { |
|
297 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
298 | + } |
|
256 | 299 | return ''; |
257 | 300 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
258 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
301 | + if ($globalDebug) { |
|
302 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
303 | + } |
|
259 | 304 | return ''; |
260 | 305 | } elseif (!isset($line['datetime'])) { |
261 | 306 | date_default_timezone_set('UTC'); |
262 | 307 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
263 | 308 | } else { |
264 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
311 | + } |
|
265 | 312 | return ''; |
266 | 313 | } |
267 | 314 | |
@@ -274,14 +321,21 @@ discard block |
||
274 | 321 | if ($distance > 1000 && $distance < 10000) { |
275 | 322 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
276 | 323 | $speed = $speed*3.6; |
277 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
278 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
324 | + if ($speed < 1000) { |
|
325 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
326 | + } |
|
327 | + if ($globalDebug) { |
|
328 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
329 | + } |
|
279 | 330 | } |
280 | 331 | } |
281 | 332 | |
282 | 333 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
283 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
284 | - else unset($timediff); |
|
334 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
335 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
336 | + } else { |
|
337 | + unset($timediff); |
|
338 | + } |
|
285 | 339 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
286 | 340 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
287 | 341 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -289,22 +343,32 @@ discard block |
||
289 | 343 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
290 | 344 | $this->all_tracked[$id]['putinarchive'] = true; |
291 | 345 | |
292 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
346 | + if ($globalDebug) { |
|
347 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
348 | + } |
|
293 | 349 | $timeelapsed = microtime(true); |
294 | 350 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
295 | 351 | $Marine = new Marine($this->db); |
296 | 352 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
297 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
353 | + if (!empty($all_country)) { |
|
354 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
355 | + } |
|
298 | 356 | $Marine->db = null; |
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
357 | + if ($globalDebugTimeElapsed) { |
|
358 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + } |
|
300 | 360 | } |
301 | 361 | $this->tmd = 0; |
302 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
362 | + if ($globalDebug) { |
|
363 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
364 | + } |
|
303 | 365 | } |
304 | 366 | } |
305 | 367 | |
306 | 368 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
307 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
369 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
370 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
371 | + } |
|
308 | 372 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
309 | 373 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
310 | 374 | $dataFound = true; |
@@ -313,8 +377,12 @@ discard block |
||
313 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
314 | 378 | } |
315 | 379 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
316 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
317 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
380 | + if ($line['longitude'] > 180) { |
|
381 | + $line['longitude'] = $line['longitude'] - 360; |
|
382 | + } |
|
383 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
384 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
385 | + } |
|
318 | 386 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
319 | 387 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
320 | 388 | $dataFound = true; |
@@ -332,7 +400,9 @@ discard block |
||
332 | 400 | } |
333 | 401 | } |
334 | 402 | if (isset($line['last_update']) && $line['last_update'] != '') { |
335 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
403 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
404 | + $dataFound = true; |
|
405 | + } |
|
336 | 406 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
337 | 407 | } |
338 | 408 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -346,15 +416,21 @@ discard block |
||
346 | 416 | } |
347 | 417 | |
348 | 418 | if (isset($line['heading']) && $line['heading'] != '') { |
349 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
419 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
420 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
421 | + } |
|
350 | 422 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
351 | 423 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
352 | 424 | //$dataFound = true; |
353 | 425 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
354 | 426 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
355 | 427 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
356 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
357 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
428 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
429 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
430 | + } |
|
431 | + if ($globalDebug) { |
|
432 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
433 | + } |
|
358 | 434 | } |
359 | 435 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
360 | 436 | |
@@ -366,23 +442,38 @@ discard block |
||
366 | 442 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
367 | 443 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
368 | 444 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
369 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
445 | + if ($globalDebug) { |
|
446 | + echo "Check if vessel is already in DB..."; |
|
447 | + } |
|
370 | 448 | $timeelapsed = microtime(true); |
371 | 449 | $MarineLive = new MarineLive($this->db); |
372 | 450 | if (isset($line['id'])) { |
373 | 451 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
374 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
452 | + if ($globalDebugTimeElapsed) { |
|
453 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
454 | + } |
|
375 | 455 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
376 | 456 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
377 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
457 | + if ($globalDebugTimeElapsed) { |
|
458 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | + } |
|
378 | 460 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
379 | 461 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
381 | - } else $recent_ident = ''; |
|
462 | + if ($globalDebugTimeElapsed) { |
|
463 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
464 | + } |
|
465 | + } else { |
|
466 | + $recent_ident = ''; |
|
467 | + } |
|
382 | 468 | $MarineLive->db=null; |
383 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
384 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
385 | - } else $recent_ident = ''; |
|
469 | + if ($globalDebug && $recent_ident == '') { |
|
470 | + echo " Not in DB.\n"; |
|
471 | + } elseif ($globalDebug && $recent_ident != '') { |
|
472 | + echo " Already in DB.\n"; |
|
473 | + } |
|
474 | + } else { |
|
475 | + $recent_ident = ''; |
|
476 | + } |
|
386 | 477 | } else { |
387 | 478 | $recent_ident = ''; |
388 | 479 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -390,30 +481,44 @@ discard block |
||
390 | 481 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
391 | 482 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
392 | 483 | { |
393 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
484 | + if ($globalDebug) { |
|
485 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
486 | + } |
|
394 | 487 | //adds the spotter data for the archive |
395 | 488 | $highlight = ''; |
396 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
489 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
490 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
491 | + } |
|
397 | 492 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
398 | 493 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
399 | 494 | $timeelapsed = microtime(true); |
400 | 495 | $Marine = new Marine($this->db); |
401 | 496 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
402 | 497 | $Marine->db = null; |
403 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
404 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
498 | + if ($globalDebug && isset($result)) { |
|
499 | + echo $result."\n"; |
|
500 | + } |
|
501 | + if ($globalDebugTimeElapsed) { |
|
502 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
503 | + } |
|
405 | 504 | } |
406 | 505 | } |
407 | 506 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
408 | 507 | // Add source stat in DB |
409 | 508 | $Stats = new Stats($this->db); |
410 | 509 | if (!empty($this->stats)) { |
411 | - if ($globalDebug) echo 'Add source stats : '; |
|
510 | + if ($globalDebug) { |
|
511 | + echo 'Add source stats : '; |
|
512 | + } |
|
412 | 513 | foreach($this->stats as $date => $data) { |
413 | 514 | foreach($data as $source => $sourced) { |
414 | 515 | //print_r($sourced); |
415 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
416 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
516 | + if (isset($sourced['polar'])) { |
|
517 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
518 | + } |
|
519 | + if (isset($sourced['hist'])) { |
|
520 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
521 | + } |
|
417 | 522 | if (isset($sourced['msg'])) { |
418 | 523 | if (time() - $sourced['msg']['date'] > 10) { |
419 | 524 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -426,7 +531,9 @@ discard block |
||
426 | 531 | unset($this->stats[$date]); |
427 | 532 | } |
428 | 533 | } |
429 | - if ($globalDebug) echo 'Done'."\n"; |
|
534 | + if ($globalDebug) { |
|
535 | + echo 'Done'."\n"; |
|
536 | + } |
|
430 | 537 | } |
431 | 538 | $Stats->db = null; |
432 | 539 | } |
@@ -436,13 +543,17 @@ discard block |
||
436 | 543 | $this->all_tracked[$id]['addedMarine'] = 1; |
437 | 544 | //print_r($this->all_tracked[$id]); |
438 | 545 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
439 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
546 | + if ($globalDebug) { |
|
547 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
548 | + } |
|
440 | 549 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
441 | 550 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 551 | $MarineLive = new MarineLive($this->db); |
443 | 552 | $MarineLive->deleteLiveMarineData(); |
444 | 553 | $MarineLive->db=null; |
445 | - if ($globalDebug) echo " Done\n"; |
|
554 | + if ($globalDebug) { |
|
555 | + echo " Done\n"; |
|
556 | + } |
|
446 | 557 | } |
447 | 558 | $this->last_delete = time(); |
448 | 559 | } |
@@ -468,15 +579,21 @@ discard block |
||
468 | 579 | |
469 | 580 | if (!$ignoreImport) { |
470 | 581 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
471 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
582 | + if ($globalDebug) { |
|
583 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
584 | + } |
|
472 | 585 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
473 | 586 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
474 | 587 | $timeelapsed = microtime(true); |
475 | 588 | $MarineLive = new MarineLive($this->db); |
476 | 589 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
477 | 590 | $MarineLive->db = null; |
478 | - if ($globalDebug) echo $result."\n"; |
|
479 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
591 | + if ($globalDebug) { |
|
592 | + echo $result."\n"; |
|
593 | + } |
|
594 | + if ($globalDebugTimeElapsed) { |
|
595 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | + } |
|
480 | 597 | } |
481 | 598 | } |
482 | 599 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -488,7 +605,9 @@ discard block |
||
488 | 605 | |
489 | 606 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
490 | 607 | $source = $this->all_tracked[$id]['source_name']; |
491 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
608 | + if ($source == '') { |
|
609 | + $source = $this->all_tracked[$id]['format_source']; |
|
610 | + } |
|
492 | 611 | if (!isset($this->source_location[$source])) { |
493 | 612 | $Location = new Source($this->db); |
494 | 613 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -509,7 +628,9 @@ discard block |
||
509 | 628 | $stats_heading = round($stats_heading/22.5); |
510 | 629 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
511 | 630 | $current_date = date('Y-m-d'); |
512 | - if ($stats_heading == 16) $stats_heading = 0; |
|
631 | + if ($stats_heading == 16) { |
|
632 | + $stats_heading = 0; |
|
633 | + } |
|
513 | 634 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
514 | 635 | for ($i=0;$i<=15;$i++) { |
515 | 636 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -527,7 +648,9 @@ discard block |
||
527 | 648 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
528 | 649 | end($this->stats[$current_date][$source]['hist']); |
529 | 650 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
530 | - } else $mini = 0; |
|
651 | + } else { |
|
652 | + $mini = 0; |
|
653 | + } |
|
531 | 654 | for ($i=$mini;$i<=$distance;$i+=10) { |
532 | 655 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
533 | 656 | } |
@@ -539,19 +662,27 @@ discard block |
||
539 | 662 | |
540 | 663 | |
541 | 664 | $this->all_tracked[$id]['lastupdate'] = time(); |
542 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
543 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
665 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
666 | + $send = true; |
|
667 | + } |
|
668 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
669 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
670 | + } |
|
544 | 671 | //$this->del(); |
545 | 672 | |
546 | 673 | |
547 | 674 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
548 | 675 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
549 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
676 | + if ($globalDebug) { |
|
677 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
678 | + } |
|
550 | 679 | $MarineLive = new MarineLive($this->db); |
551 | 680 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
552 | 681 | $MarineLive->db = null; |
553 | 682 | //MarineLive->deleteLiveMarineData(); |
554 | - if ($globalDebug) echo " Done\n"; |
|
683 | + if ($globalDebug) { |
|
684 | + echo " Done\n"; |
|
685 | + } |
|
555 | 686 | } |
556 | 687 | $this->last_delete_hourly = time(); |
557 | 688 | } |
@@ -560,7 +691,9 @@ discard block |
||
560 | 691 | //$ignoreImport = false; |
561 | 692 | } |
562 | 693 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
563 | - if ($send) return $this->all_tracked[$id]; |
|
694 | + if ($send) { |
|
695 | + return $this->all_tracked[$id]; |
|
696 | + } |
|
564 | 697 | } |
565 | 698 | } |
566 | 699 | } |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | $temp += 1; |
124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
125 | 125 | $flat *= -1.0; |
126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
126 | + } else { |
|
127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
128 | + } |
|
127 | 129 | return $flat; // float |
128 | 130 | } |
129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
135 | 137 | $temp += 1; |
136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
137 | 139 | $flon *= -1.0; |
138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
140 | + } else { |
|
141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
142 | + } |
|
139 | 143 | return $flon; |
140 | 144 | } |
141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
158 | 162 | */ |
159 | 163 | private function asciidec_2_8bit($ascii) { |
160 | 164 | //only process in the following range: 48-87, 96-119 |
161 | - if ($ascii < 48) { } |
|
162 | - else { |
|
163 | - if($ascii>119) { } |
|
164 | - else { |
|
165 | + if ($ascii < 48) { } else { |
|
166 | + if($ascii>119) { } else { |
|
165 | 167 | if ($ascii>87 && $ascii<96) ; |
166 | 168 | else { |
167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
268 | + if ($ro->heading == 511) { |
|
269 | + $ro->heading = ''; |
|
270 | + } |
|
267 | 271 | $ro->cls = 2; // class B |
268 | 272 | } else if ($ro->id == 19) { |
269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
274 | 278 | $ro->cls = 2; // class B |
275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
280 | + if ($ro->heading == 511) { |
|
281 | + $ro->heading = ''; |
|
282 | + } |
|
277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
304 | 310 | $ro->cls = 2; // class B |
305 | 311 | } else if ($ro->id == 27) { |
306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
313 | + if ($ro->cog == 511) { |
|
314 | + $ro->cog = 0.0; |
|
315 | + } |
|
308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
317 | + if ($ro->sog == 63) { |
|
318 | + $ro->sog = 0.0; |
|
319 | + } |
|
310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
312 | 322 | $ro->cls = 1; // class A |
@@ -354,14 +364,20 @@ discard block |
||
354 | 364 | } |
355 | 365 | |
356 | 366 | public function getShipType($code) { |
357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
358 | - else return ''; |
|
367 | + if (isset($this->shiptype[$code])) { |
|
368 | + return $this->shiptype[$code]; |
|
369 | + } else { |
|
370 | + return ''; |
|
371 | + } |
|
359 | 372 | } |
360 | 373 | |
361 | 374 | public function getShipTypeID($type) { |
362 | 375 | $typeid = array_search($type,$this->shiptype); |
363 | - if ($typeid !== FALSE) return $typeid; |
|
364 | - else return ''; |
|
376 | + if ($typeid !== FALSE) { |
|
377 | + return $typeid; |
|
378 | + } else { |
|
379 | + return ''; |
|
380 | + } |
|
365 | 381 | } |
366 | 382 | |
367 | 383 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -398,11 +414,20 @@ discard block |
||
398 | 414 | // assume 1st ! is valid |
399 | 415 | // find * ensure that it is at correct position |
400 | 416 | $end = strrpos ( $rawdata , '*' ); |
401 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
417 | + if ($end === FALSE) { |
|
418 | + return -1; |
|
419 | + } |
|
420 | + // check for NULLS!!! |
|
402 | 421 | $cs = substr( $rawdata, $end + 1 ); |
403 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
422 | + if ( strlen($cs) != 2 ) { |
|
423 | + return -1; |
|
424 | + } |
|
425 | + // correct cs length |
|
404 | 426 | $dcs = (int)hexdec( $cs ); |
405 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
427 | + for ( $alias=1; $alias<$end; $alias++) { |
|
428 | + $chksum ^= ord( $rawdata[$alias] ); |
|
429 | + } |
|
430 | + // perform XOR for NMEA checksum |
|
406 | 431 | if ( $chksum == $dcs ) { // NMEA checksum pass |
407 | 432 | $pcs = explode(',', $rawdata); |
408 | 433 | // !AI??? identifier |
@@ -413,8 +438,14 @@ discard block |
||
413 | 438 | $num_seq = (int)$pcs[1]; // number of sequences |
414 | 439 | $seq = (int)$pcs[2]; // get sequence |
415 | 440 | // get msg sequence id |
416 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
417 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
441 | + if ($pcs[3] == '') { |
|
442 | + $msg_sid = -1; |
|
443 | + } |
|
444 | + // non-multipart message, set to -1 |
|
445 | + else { |
|
446 | + $msg_sid = (int)$pcs[3]; |
|
447 | + } |
|
448 | + // multipart message |
|
418 | 449 | $ais_ch = $pcs[4]; // get AIS channel |
419 | 450 | // message sequence checking |
420 | 451 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -477,10 +508,18 @@ discard block |
||
477 | 508 | //DEBUG echo "[$start $end $tst]\n"; |
478 | 509 | $result = $this->process_ais_raw( $tst, "" ); |
479 | 510 | $last_pos = $end + 1; |
480 | - } else break; |
|
511 | + } else { |
|
512 | + break; |
|
513 | + } |
|
514 | + } |
|
515 | + if ($last_pos > 0) { |
|
516 | + $cbuf = substr($cbuf, $last_pos); |
|
481 | 517 | } |
482 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
483 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
518 | + // move... |
|
519 | + if (strlen($cbuf) > 1024) { |
|
520 | + $cbuf = ""; |
|
521 | + } |
|
522 | + // prevent overflow simple mode... |
|
484 | 523 | return $result; |
485 | 524 | } |
486 | 525 | |
@@ -500,7 +539,9 @@ discard block |
||
500 | 539 | if ($lat<0.0) { |
501 | 540 | $lat = -$lat; |
502 | 541 | $neg=true; |
503 | - } else $neg=false; |
|
542 | + } else { |
|
543 | + $neg=false; |
|
544 | + } |
|
504 | 545 | $latd = 0x00000000; |
505 | 546 | $latd = intval ($lat * 600000.0); |
506 | 547 | if ($neg==true) { |
@@ -516,7 +557,9 @@ discard block |
||
516 | 557 | if ($lon<0.0) { |
517 | 558 | $lon = -$lon; |
518 | 559 | $neg=true; |
519 | - } else $neg=false; |
|
560 | + } else { |
|
561 | + $neg=false; |
|
562 | + } |
|
520 | 563 | $lond = 0x00000000; |
521 | 564 | $lond = intval ($lon * 600000.0); |
522 | 565 | if ($neg==true) { |
@@ -529,9 +572,14 @@ discard block |
||
529 | 572 | |
530 | 573 | private function char2bin($name, $max_len) { |
531 | 574 | $len = strlen($name); |
532 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
533 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
534 | - else $pad = ''; |
|
575 | + if ($len > $max_len) { |
|
576 | + $name = substr($name,0,$max_len); |
|
577 | + } |
|
578 | + if ($len < $max_len) { |
|
579 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
580 | + } else { |
|
581 | + $pad = ''; |
|
582 | + } |
|
535 | 583 | $rv = ''; |
536 | 584 | $ais_chars = array( |
537 | 585 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -544,9 +592,12 @@ discard block |
||
544 | 592 | ); |
545 | 593 | // " |
546 | 594 | $_a = str_split($name); |
547 | - if ($_a) foreach ($_a as $_1) { |
|
595 | + if ($_a) { |
|
596 | + foreach ($_a as $_1) { |
|
548 | 597 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
549 | - else $dec = 0; |
|
598 | + } else { |
|
599 | + $dec = 0; |
|
600 | + } |
|
550 | 601 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
551 | 602 | $rv .= $bin; |
552 | 603 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -558,7 +609,9 @@ discard block |
||
558 | 609 | $len_bit = strlen($_enc); |
559 | 610 | $rem6 = $len_bit % 6; |
560 | 611 | $pad6_len = 0; |
561 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
612 | + if ($rem6) { |
|
613 | + $pad6_len = 6 - $rem6; |
|
614 | + } |
|
562 | 615 | //echo $pad6_len.'<br>'; |
563 | 616 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
564 | 617 | $len_enc = strlen($_enc) / 6; |
@@ -567,8 +620,11 @@ discard block |
||
567 | 620 | for ($i=0; $i<$len_enc; $i++) { |
568 | 621 | $offset = $i * 6; |
569 | 622 | $dec = bindec(substr($_enc,$offset,6)); |
570 | - if ($dec < 40) $dec += 48; |
|
571 | - else $dec += 56; |
|
623 | + if ($dec < 40) { |
|
624 | + $dec += 48; |
|
625 | + } else { |
|
626 | + $dec += 56; |
|
627 | + } |
|
572 | 628 | //echo chr($dec)." $dec<br/>"; |
573 | 629 | $itu .= chr($dec); |
574 | 630 | } |
@@ -581,26 +637,42 @@ discard block |
||
581 | 637 | } |
582 | 638 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
583 | 639 | $lsb = $chksum & 0x0F; |
584 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
585 | - else $lsbc = '0'; |
|
640 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
641 | + $lsbc = $hex_arr[$lsb]; |
|
642 | + } else { |
|
643 | + $lsbc = '0'; |
|
644 | + } |
|
586 | 645 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
587 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
588 | - else $msbc = '0'; |
|
646 | + if ($msb >=0 && $msb <= 15 ) { |
|
647 | + $msbc = $hex_arr[$msb]; |
|
648 | + } else { |
|
649 | + $msbc = '0'; |
|
650 | + } |
|
589 | 651 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
590 | 652 | return $itu; |
591 | 653 | } |
592 | 654 | |
593 | 655 | public function parse($buffer) { |
594 | 656 | $data = $this->process_ais_buf($buffer); |
595 | - if (!is_object($data)) return array(); |
|
657 | + if (!is_object($data)) { |
|
658 | + return array(); |
|
659 | + } |
|
596 | 660 | $result = array(); |
597 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
598 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
661 | + if ($data->lon != 0) { |
|
662 | + $result['longitude'] = $data->lon; |
|
663 | + } |
|
664 | + if ($data->lat != 0) { |
|
665 | + $result['latitude'] = $data->lat; |
|
666 | + } |
|
599 | 667 | $result['ident'] = trim($data->name); |
600 | 668 | $result['timestamp'] = $data->ts; |
601 | 669 | $result['mmsi'] = $data->mmsi; |
602 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
603 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
670 | + if ($data->sog != -1.0) { |
|
671 | + $result['speed'] = $data->sog; |
|
672 | + } |
|
673 | + if ($data->cog != 0) { |
|
674 | + $result['heading'] = $data->cog; |
|
675 | + } |
|
604 | 676 | /* |
605 | 677 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
606 | 678 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -610,15 +682,25 @@ discard block |
||
610 | 682 | |
611 | 683 | public function mmsitype($mmsi) { |
612 | 684 | if (strlen($mmsi) == 9) { |
613 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
614 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
615 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
616 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
617 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
618 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
619 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
620 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
621 | - else return 'Ship'; |
|
685 | + if (substr($mmsi,0,3) == '974') { |
|
686 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
687 | + } elseif (substr($mmsi,0,3) == '972') { |
|
688 | + return 'MOB (Man Overboard) device'; |
|
689 | + } elseif (substr($mmsi,0,3) == '970') { |
|
690 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
691 | + } elseif (substr($mmsi,0,3) == '111') { |
|
692 | + return 'SAR (Search and Rescue) aircraft'; |
|
693 | + } elseif (substr($mmsi,0,2) == '98') { |
|
694 | + return 'Auxiliary craft associated with a parent ship'; |
|
695 | + } elseif (substr($mmsi,0,2) == '99') { |
|
696 | + return 'Aids to Navigation'; |
|
697 | + } elseif (substr($mmsi,0,2) == '00') { |
|
698 | + return 'Coastal stations'; |
|
699 | + } elseif (substr($mmsi,0,1) == '0') { |
|
700 | + return 'Group of ships'; |
|
701 | + } else { |
|
702 | + return 'Ship'; |
|
703 | + } |
|
622 | 704 | } |
623 | 705 | |
624 | 706 | |
@@ -634,32 +716,61 @@ discard block |
||
634 | 716 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
635 | 717 | return array(); |
636 | 718 | } |
637 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
638 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
639 | 725 | $result['ident'] = trim(str_replace('@','',$data->name)); |
640 | 726 | $result['timestamp'] = $data->ts; |
641 | 727 | $result['mmsi'] = $data->mmsi; |
642 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
728 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
729 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
730 | + } |
|
643 | 731 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
644 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
645 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
646 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
647 | - if ($data->status != '') $result['status'] = $data->status; |
|
648 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
649 | - if ($data->type !== '') $result['type'] = $data->type; |
|
650 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
651 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
652 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
732 | + if ($data->sog != -1.0) { |
|
733 | + $result['speed'] = $data->sog; |
|
734 | + } |
|
735 | + if ($data->heading !== '') { |
|
736 | + $result['heading'] = $data->heading; |
|
737 | + } elseif ($data->cog != 0) { |
|
738 | + $result['heading'] = $data->cog; |
|
739 | + } |
|
740 | + if ($data->status != '') { |
|
741 | + $result['status'] = $data->status; |
|
742 | + } |
|
743 | + if ($data->statusid !== '') { |
|
744 | + $result['statusid'] = $data->statusid; |
|
745 | + } |
|
746 | + if ($data->type !== '') { |
|
747 | + $result['type'] = $data->type; |
|
748 | + } |
|
749 | + if ($data->typeid !== '') { |
|
750 | + $result['typeid'] = $data->typeid; |
|
751 | + } |
|
752 | + if ($data->imo !== '') { |
|
753 | + $result['imo'] = $data->imo; |
|
754 | + } |
|
755 | + if ($data->callsign !== '') { |
|
756 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
757 | + } |
|
653 | 758 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
654 | 759 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
655 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
760 | + if ($eta_ts != '') { |
|
761 | + $result['eta_ts'] = $eta_ts; |
|
762 | + } |
|
656 | 763 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
657 | 764 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
658 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
765 | + if ($eta_ts != '') { |
|
766 | + $result['eta_ts'] = $eta_ts; |
|
767 | + } |
|
659 | 768 | } |
660 | 769 | if ($data->destination != '') { |
661 | 770 | $dest = trim(str_replace('@','',$data->destination)); |
662 | - if ($dest != '') $result['destination'] = $dest; |
|
771 | + if ($dest != '') { |
|
772 | + $result['destination'] = $dest; |
|
773 | + } |
|
663 | 774 | } |
664 | 775 | $result['all'] = (array) $data; |
665 | 776 | /* |
@@ -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'"; |
@@ -2255,8 +2407,11 @@ discard block |
||
2255 | 2407 | if ($Connection->tableExists('aircraft')) { |
2256 | 2408 | if (!$Connection->tableExists('config')) { |
2257 | 2409 | $version = '1'; |
2258 | - if ($update) return self::update_from_1(); |
|
2259 | - else return $version; |
|
2410 | + if ($update) { |
|
2411 | + return self::update_from_1(); |
|
2412 | + } else { |
|
2413 | + return $version; |
|
2414 | + } |
|
2260 | 2415 | } else { |
2261 | 2416 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2262 | 2417 | try { |
@@ -2269,199 +2424,347 @@ discard block |
||
2269 | 2424 | if ($update) { |
2270 | 2425 | if ($result['value'] == '2') { |
2271 | 2426 | $error = self::update_from_2(); |
2272 | - if ($error != '') return $error; |
|
2273 | - else return self::check_version(true); |
|
2427 | + if ($error != '') { |
|
2428 | + return $error; |
|
2429 | + } else { |
|
2430 | + return self::check_version(true); |
|
2431 | + } |
|
2274 | 2432 | } elseif ($result['value'] == '3') { |
2275 | 2433 | $error = self::update_from_3(); |
2276 | - if ($error != '') return $error; |
|
2277 | - else return self::check_version(true); |
|
2434 | + if ($error != '') { |
|
2435 | + return $error; |
|
2436 | + } else { |
|
2437 | + return self::check_version(true); |
|
2438 | + } |
|
2278 | 2439 | } elseif ($result['value'] == '4') { |
2279 | 2440 | $error = self::update_from_4(); |
2280 | - if ($error != '') return $error; |
|
2281 | - else return self::check_version(true); |
|
2441 | + if ($error != '') { |
|
2442 | + return $error; |
|
2443 | + } else { |
|
2444 | + return self::check_version(true); |
|
2445 | + } |
|
2282 | 2446 | } elseif ($result['value'] == '5') { |
2283 | 2447 | $error = self::update_from_5(); |
2284 | - if ($error != '') return $error; |
|
2285 | - else return self::check_version(true); |
|
2448 | + if ($error != '') { |
|
2449 | + return $error; |
|
2450 | + } else { |
|
2451 | + return self::check_version(true); |
|
2452 | + } |
|
2286 | 2453 | } elseif ($result['value'] == '6') { |
2287 | 2454 | $error = self::update_from_6(); |
2288 | - if ($error != '') return $error; |
|
2289 | - else return self::check_version(true); |
|
2455 | + if ($error != '') { |
|
2456 | + return $error; |
|
2457 | + } else { |
|
2458 | + return self::check_version(true); |
|
2459 | + } |
|
2290 | 2460 | } elseif ($result['value'] == '7') { |
2291 | 2461 | $error = self::update_from_7(); |
2292 | - if ($error != '') return $error; |
|
2293 | - else return self::check_version(true); |
|
2462 | + if ($error != '') { |
|
2463 | + return $error; |
|
2464 | + } else { |
|
2465 | + return self::check_version(true); |
|
2466 | + } |
|
2294 | 2467 | } elseif ($result['value'] == '8') { |
2295 | 2468 | $error = self::update_from_8(); |
2296 | - if ($error != '') return $error; |
|
2297 | - else return self::check_version(true); |
|
2469 | + if ($error != '') { |
|
2470 | + return $error; |
|
2471 | + } else { |
|
2472 | + return self::check_version(true); |
|
2473 | + } |
|
2298 | 2474 | } elseif ($result['value'] == '9') { |
2299 | 2475 | $error = self::update_from_9(); |
2300 | - if ($error != '') return $error; |
|
2301 | - else return self::check_version(true); |
|
2476 | + if ($error != '') { |
|
2477 | + return $error; |
|
2478 | + } else { |
|
2479 | + return self::check_version(true); |
|
2480 | + } |
|
2302 | 2481 | } elseif ($result['value'] == '10') { |
2303 | 2482 | $error = self::update_from_10(); |
2304 | - if ($error != '') return $error; |
|
2305 | - else return self::check_version(true); |
|
2483 | + if ($error != '') { |
|
2484 | + return $error; |
|
2485 | + } else { |
|
2486 | + return self::check_version(true); |
|
2487 | + } |
|
2306 | 2488 | } elseif ($result['value'] == '11') { |
2307 | 2489 | $error = self::update_from_11(); |
2308 | - if ($error != '') return $error; |
|
2309 | - else return self::check_version(true); |
|
2490 | + if ($error != '') { |
|
2491 | + return $error; |
|
2492 | + } else { |
|
2493 | + return self::check_version(true); |
|
2494 | + } |
|
2310 | 2495 | } elseif ($result['value'] == '12') { |
2311 | 2496 | $error = self::update_from_12(); |
2312 | - if ($error != '') return $error; |
|
2313 | - else return self::check_version(true); |
|
2497 | + if ($error != '') { |
|
2498 | + return $error; |
|
2499 | + } else { |
|
2500 | + return self::check_version(true); |
|
2501 | + } |
|
2314 | 2502 | } elseif ($result['value'] == '13') { |
2315 | 2503 | $error = self::update_from_13(); |
2316 | - if ($error != '') return $error; |
|
2317 | - else return self::check_version(true); |
|
2504 | + if ($error != '') { |
|
2505 | + return $error; |
|
2506 | + } else { |
|
2507 | + return self::check_version(true); |
|
2508 | + } |
|
2318 | 2509 | } elseif ($result['value'] == '14') { |
2319 | 2510 | $error = self::update_from_14(); |
2320 | - if ($error != '') return $error; |
|
2321 | - else return self::check_version(true); |
|
2511 | + if ($error != '') { |
|
2512 | + return $error; |
|
2513 | + } else { |
|
2514 | + return self::check_version(true); |
|
2515 | + } |
|
2322 | 2516 | } elseif ($result['value'] == '15') { |
2323 | 2517 | $error = self::update_from_15(); |
2324 | - if ($error != '') return $error; |
|
2325 | - else return self::check_version(true); |
|
2518 | + if ($error != '') { |
|
2519 | + return $error; |
|
2520 | + } else { |
|
2521 | + return self::check_version(true); |
|
2522 | + } |
|
2326 | 2523 | } elseif ($result['value'] == '16') { |
2327 | 2524 | $error = self::update_from_16(); |
2328 | - if ($error != '') return $error; |
|
2329 | - else return self::check_version(true); |
|
2525 | + if ($error != '') { |
|
2526 | + return $error; |
|
2527 | + } else { |
|
2528 | + return self::check_version(true); |
|
2529 | + } |
|
2330 | 2530 | } elseif ($result['value'] == '17') { |
2331 | 2531 | $error = self::update_from_17(); |
2332 | - if ($error != '') return $error; |
|
2333 | - else return self::check_version(true); |
|
2532 | + if ($error != '') { |
|
2533 | + return $error; |
|
2534 | + } else { |
|
2535 | + return self::check_version(true); |
|
2536 | + } |
|
2334 | 2537 | } elseif ($result['value'] == '18') { |
2335 | 2538 | $error = self::update_from_18(); |
2336 | - if ($error != '') return $error; |
|
2337 | - else return self::check_version(true); |
|
2539 | + if ($error != '') { |
|
2540 | + return $error; |
|
2541 | + } else { |
|
2542 | + return self::check_version(true); |
|
2543 | + } |
|
2338 | 2544 | } elseif ($result['value'] == '19') { |
2339 | 2545 | $error = self::update_from_19(); |
2340 | - if ($error != '') return $error; |
|
2341 | - else return self::check_version(true); |
|
2546 | + if ($error != '') { |
|
2547 | + return $error; |
|
2548 | + } else { |
|
2549 | + return self::check_version(true); |
|
2550 | + } |
|
2342 | 2551 | } elseif ($result['value'] == '20') { |
2343 | 2552 | $error = self::update_from_20(); |
2344 | - if ($error != '') return $error; |
|
2345 | - else return self::check_version(true); |
|
2553 | + if ($error != '') { |
|
2554 | + return $error; |
|
2555 | + } else { |
|
2556 | + return self::check_version(true); |
|
2557 | + } |
|
2346 | 2558 | } elseif ($result['value'] == '21') { |
2347 | 2559 | $error = self::update_from_21(); |
2348 | - if ($error != '') return $error; |
|
2349 | - else return self::check_version(true); |
|
2560 | + if ($error != '') { |
|
2561 | + return $error; |
|
2562 | + } else { |
|
2563 | + return self::check_version(true); |
|
2564 | + } |
|
2350 | 2565 | } elseif ($result['value'] == '22') { |
2351 | 2566 | $error = self::update_from_22(); |
2352 | - if ($error != '') return $error; |
|
2353 | - else return self::check_version(true); |
|
2567 | + if ($error != '') { |
|
2568 | + return $error; |
|
2569 | + } else { |
|
2570 | + return self::check_version(true); |
|
2571 | + } |
|
2354 | 2572 | } elseif ($result['value'] == '23') { |
2355 | 2573 | $error = self::update_from_23(); |
2356 | - if ($error != '') return $error; |
|
2357 | - else return self::check_version(true); |
|
2574 | + if ($error != '') { |
|
2575 | + return $error; |
|
2576 | + } else { |
|
2577 | + return self::check_version(true); |
|
2578 | + } |
|
2358 | 2579 | } elseif ($result['value'] == '24') { |
2359 | 2580 | $error = self::update_from_24(); |
2360 | - if ($error != '') return $error; |
|
2361 | - else return self::check_version(true); |
|
2581 | + if ($error != '') { |
|
2582 | + return $error; |
|
2583 | + } else { |
|
2584 | + return self::check_version(true); |
|
2585 | + } |
|
2362 | 2586 | } elseif ($result['value'] == '25') { |
2363 | 2587 | $error = self::update_from_25(); |
2364 | - if ($error != '') return $error; |
|
2365 | - else return self::check_version(true); |
|
2588 | + if ($error != '') { |
|
2589 | + return $error; |
|
2590 | + } else { |
|
2591 | + return self::check_version(true); |
|
2592 | + } |
|
2366 | 2593 | } elseif ($result['value'] == '26') { |
2367 | 2594 | $error = self::update_from_26(); |
2368 | - if ($error != '') return $error; |
|
2369 | - else return self::check_version(true); |
|
2595 | + if ($error != '') { |
|
2596 | + return $error; |
|
2597 | + } else { |
|
2598 | + return self::check_version(true); |
|
2599 | + } |
|
2370 | 2600 | } elseif ($result['value'] == '27') { |
2371 | 2601 | $error = self::update_from_27(); |
2372 | - if ($error != '') return $error; |
|
2373 | - else return self::check_version(true); |
|
2602 | + if ($error != '') { |
|
2603 | + return $error; |
|
2604 | + } else { |
|
2605 | + return self::check_version(true); |
|
2606 | + } |
|
2374 | 2607 | } elseif ($result['value'] == '28') { |
2375 | 2608 | $error = self::update_from_28(); |
2376 | - if ($error != '') return $error; |
|
2377 | - else return self::check_version(true); |
|
2609 | + if ($error != '') { |
|
2610 | + return $error; |
|
2611 | + } else { |
|
2612 | + return self::check_version(true); |
|
2613 | + } |
|
2378 | 2614 | } elseif ($result['value'] == '29') { |
2379 | 2615 | $error = self::update_from_29(); |
2380 | - if ($error != '') return $error; |
|
2381 | - else return self::check_version(true); |
|
2616 | + if ($error != '') { |
|
2617 | + return $error; |
|
2618 | + } else { |
|
2619 | + return self::check_version(true); |
|
2620 | + } |
|
2382 | 2621 | } elseif ($result['value'] == '30') { |
2383 | 2622 | $error = self::update_from_30(); |
2384 | - if ($error != '') return $error; |
|
2385 | - else return self::check_version(true); |
|
2623 | + if ($error != '') { |
|
2624 | + return $error; |
|
2625 | + } else { |
|
2626 | + return self::check_version(true); |
|
2627 | + } |
|
2386 | 2628 | } elseif ($result['value'] == '31') { |
2387 | 2629 | $error = self::update_from_31(); |
2388 | - if ($error != '') return $error; |
|
2389 | - else return self::check_version(true); |
|
2630 | + if ($error != '') { |
|
2631 | + return $error; |
|
2632 | + } else { |
|
2633 | + return self::check_version(true); |
|
2634 | + } |
|
2390 | 2635 | } elseif ($result['value'] == '32') { |
2391 | 2636 | $error = self::update_from_32(); |
2392 | - if ($error != '') return $error; |
|
2393 | - else return self::check_version(true); |
|
2637 | + if ($error != '') { |
|
2638 | + return $error; |
|
2639 | + } else { |
|
2640 | + return self::check_version(true); |
|
2641 | + } |
|
2394 | 2642 | } elseif ($result['value'] == '33') { |
2395 | 2643 | $error = self::update_from_33(); |
2396 | - if ($error != '') return $error; |
|
2397 | - else return self::check_version(true); |
|
2644 | + if ($error != '') { |
|
2645 | + return $error; |
|
2646 | + } else { |
|
2647 | + return self::check_version(true); |
|
2648 | + } |
|
2398 | 2649 | } elseif ($result['value'] == '34') { |
2399 | 2650 | $error = self::update_from_34(); |
2400 | - if ($error != '') return $error; |
|
2401 | - else return self::check_version(true); |
|
2651 | + if ($error != '') { |
|
2652 | + return $error; |
|
2653 | + } else { |
|
2654 | + return self::check_version(true); |
|
2655 | + } |
|
2402 | 2656 | } elseif ($result['value'] == '35') { |
2403 | 2657 | $error = self::update_from_35(); |
2404 | - if ($error != '') return $error; |
|
2405 | - else return self::check_version(true); |
|
2658 | + if ($error != '') { |
|
2659 | + return $error; |
|
2660 | + } else { |
|
2661 | + return self::check_version(true); |
|
2662 | + } |
|
2406 | 2663 | } elseif ($result['value'] == '36') { |
2407 | 2664 | $error = self::update_from_36(); |
2408 | - if ($error != '') return $error; |
|
2409 | - else return self::check_version(true); |
|
2665 | + if ($error != '') { |
|
2666 | + return $error; |
|
2667 | + } else { |
|
2668 | + return self::check_version(true); |
|
2669 | + } |
|
2410 | 2670 | } elseif ($result['value'] == '37') { |
2411 | 2671 | $error = self::update_from_37(); |
2412 | - if ($error != '') return $error; |
|
2413 | - else return self::check_version(true); |
|
2672 | + if ($error != '') { |
|
2673 | + return $error; |
|
2674 | + } else { |
|
2675 | + return self::check_version(true); |
|
2676 | + } |
|
2414 | 2677 | } elseif ($result['value'] == '38') { |
2415 | 2678 | $error = self::update_from_38(); |
2416 | - if ($error != '') return $error; |
|
2417 | - else return self::check_version(true); |
|
2679 | + if ($error != '') { |
|
2680 | + return $error; |
|
2681 | + } else { |
|
2682 | + return self::check_version(true); |
|
2683 | + } |
|
2418 | 2684 | } elseif ($result['value'] == '39') { |
2419 | 2685 | $error = self::update_from_39(); |
2420 | - if ($error != '') return $error; |
|
2421 | - else return self::check_version(true); |
|
2686 | + if ($error != '') { |
|
2687 | + return $error; |
|
2688 | + } else { |
|
2689 | + return self::check_version(true); |
|
2690 | + } |
|
2422 | 2691 | } elseif ($result['value'] == '40') { |
2423 | 2692 | $error = self::update_from_40(); |
2424 | - if ($error != '') return $error; |
|
2425 | - else return self::check_version(true); |
|
2693 | + if ($error != '') { |
|
2694 | + return $error; |
|
2695 | + } else { |
|
2696 | + return self::check_version(true); |
|
2697 | + } |
|
2426 | 2698 | } elseif ($result['value'] == '41') { |
2427 | 2699 | $error = self::update_from_41(); |
2428 | - if ($error != '') return $error; |
|
2429 | - else return self::check_version(true); |
|
2700 | + if ($error != '') { |
|
2701 | + return $error; |
|
2702 | + } else { |
|
2703 | + return self::check_version(true); |
|
2704 | + } |
|
2430 | 2705 | } elseif ($result['value'] == '42') { |
2431 | 2706 | $error = self::update_from_42(); |
2432 | - if ($error != '') return $error; |
|
2433 | - else return self::check_version(true); |
|
2707 | + if ($error != '') { |
|
2708 | + return $error; |
|
2709 | + } else { |
|
2710 | + return self::check_version(true); |
|
2711 | + } |
|
2434 | 2712 | } elseif ($result['value'] == '43') { |
2435 | 2713 | $error = self::update_from_43(); |
2436 | - if ($error != '') return $error; |
|
2437 | - else return self::check_version(true); |
|
2714 | + if ($error != '') { |
|
2715 | + return $error; |
|
2716 | + } else { |
|
2717 | + return self::check_version(true); |
|
2718 | + } |
|
2438 | 2719 | } elseif ($result['value'] == '44') { |
2439 | 2720 | $error = self::update_from_44(); |
2440 | - if ($error != '') return $error; |
|
2441 | - else return self::check_version(true); |
|
2721 | + if ($error != '') { |
|
2722 | + return $error; |
|
2723 | + } else { |
|
2724 | + return self::check_version(true); |
|
2725 | + } |
|
2442 | 2726 | } elseif ($result['value'] == '45') { |
2443 | 2727 | $error = self::update_from_45(); |
2444 | - if ($error != '') return $error; |
|
2445 | - else return self::check_version(true); |
|
2728 | + if ($error != '') { |
|
2729 | + return $error; |
|
2730 | + } else { |
|
2731 | + return self::check_version(true); |
|
2732 | + } |
|
2446 | 2733 | } elseif ($result['value'] == '46') { |
2447 | 2734 | $error = self::update_from_46(); |
2448 | - if ($error != '') return $error; |
|
2449 | - else return self::check_version(true); |
|
2735 | + if ($error != '') { |
|
2736 | + return $error; |
|
2737 | + } else { |
|
2738 | + return self::check_version(true); |
|
2739 | + } |
|
2450 | 2740 | } elseif ($result['value'] == '47') { |
2451 | 2741 | $error = self::update_from_47(); |
2452 | - if ($error != '') return $error; |
|
2453 | - else return self::check_version(true); |
|
2742 | + if ($error != '') { |
|
2743 | + return $error; |
|
2744 | + } else { |
|
2745 | + return self::check_version(true); |
|
2746 | + } |
|
2454 | 2747 | } elseif ($result['value'] == '48') { |
2455 | 2748 | $error = self::update_from_48(); |
2456 | - if ($error != '') return $error; |
|
2457 | - else return self::check_version(true); |
|
2458 | - } else return ''; |
|
2749 | + if ($error != '') { |
|
2750 | + return $error; |
|
2751 | + } else { |
|
2752 | + return self::check_version(true); |
|
2753 | + } |
|
2754 | + } else { |
|
2755 | + return ''; |
|
2756 | + } |
|
2459 | 2757 | } else { |
2460 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2461 | - else return 0; |
|
2758 | + if (isset($result['value']) && $result['value'] != '') { |
|
2759 | + return $result['value']; |
|
2760 | + } else { |
|
2761 | + return 0; |
|
2762 | + } |
|
2462 | 2763 | } |
2463 | 2764 | } |
2464 | - } else return $version; |
|
2765 | + } else { |
|
2766 | + return $version; |
|
2767 | + } |
|
2465 | 2768 | } |
2466 | 2769 | } |
2467 | 2770 | } |