@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
86 | 89 | //global $cookies; |
87 | 90 | $cookies = array(); |
88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
89 | - $cookies[] = $cookie; |
|
91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
92 | + $cookies[] = $cookie; |
|
93 | + } |
|
90 | 94 | return strlen($headerLine); // Needed by curl |
91 | 95 | } |
92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
104 | + if ($referer != '') { |
|
105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
106 | + } |
|
101 | 107 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
103 | 109 | curl_exec($ch); |
104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
110 | + if (curl_errno($ch) && $globalDebug) { |
|
111 | + echo 'Download error: '.curl_error($ch); |
|
112 | + } |
|
105 | 113 | curl_close($ch); |
106 | 114 | fclose($fp); |
107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 119 | $buffer_size = 4096; // read 4kb at a time |
112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
120 | + if ($out_file_name == '') { |
|
121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
122 | + } |
|
113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
117 | - else { |
|
125 | + if (function_exists('gzopen')) { |
|
126 | + $file = gzopen($in_file,'rb'); |
|
127 | + } elseif (function_exists('gzopen64')) { |
|
128 | + $file = gzopen64($in_file,'rb'); |
|
129 | + } else { |
|
118 | 130 | echo 'gzopen not available'; |
119 | 131 | die; |
120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 144 | $buffer_size = 4096; // read 4kb at a time |
133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
145 | + if ($out_file_name == '') { |
|
146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
147 | + } |
|
134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
137 | - else { |
|
150 | + if (function_exists('bzopen')) { |
|
151 | + $file = bzopen($in_file,'rb'); |
|
152 | + } else { |
|
138 | 153 | echo 'bzopen not available'; |
139 | 154 | die; |
140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
153 | 168 | * @return Array array of the tables in HTML page |
154 | 169 | */ |
155 | 170 | public function table2array($data) { |
156 | - if (!is_string($data)) return array(); |
|
157 | - if ($data == '') return array(); |
|
171 | + if (!is_string($data)) { |
|
172 | + return array(); |
|
173 | + } |
|
174 | + if ($data == '') { |
|
175 | + return array(); |
|
176 | + } |
|
158 | 177 | $html = str_get_html($data); |
159 | - if ($html === false) return array(); |
|
178 | + if ($html === false) { |
|
179 | + return array(); |
|
180 | + } |
|
160 | 181 | $tabledata=array(); |
161 | 182 | foreach($html->find('tr') as $element) |
162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
191 | 212 | */ |
192 | 213 | public function text2array($data) { |
193 | 214 | $html = str_get_html($data); |
194 | - if ($html === false) return array(); |
|
215 | + if ($html === false) { |
|
216 | + return array(); |
|
217 | + } |
|
195 | 218 | $tabledata=array(); |
196 | 219 | foreach($html->find('p') as $element) |
197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
212 | 235 | * @return Float Distance in $unit |
213 | 236 | */ |
214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
238 | + if ($lat == $latc && $lon == $lonc) { |
|
239 | + return 0; |
|
240 | + } |
|
216 | 241 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
217 | 242 | if ($unit == "km") { |
218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
237 | 262 | $x = abs($timeDifference); |
238 | 263 | $d = abs($distance); |
239 | - if ($x == 0 || $d == 0) return true; |
|
264 | + if ($x == 0 || $d == 0) { |
|
265 | + return true; |
|
266 | + } |
|
240 | 267 | // may be due to Internet jitter; distance is realistic |
241 | - if ($x < 0.7 && $d < 2000) return true; |
|
242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
268 | + if ($x < 0.7 && $d < 2000) { |
|
269 | + return true; |
|
270 | + } else { |
|
271 | + return $d/$x < 1500*0.27778; |
|
272 | + } |
|
273 | + // 1500 km/h max |
|
243 | 274 | } |
244 | 275 | |
245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
267 | 298 | |
268 | 299 | public function convertDM($coord,$latlong) { |
269 | 300 | if ($latlong == 'latitude') { |
270 | - if ($coord < 0) $NSEW = 'S'; |
|
271 | - else $NSEW = 'N'; |
|
301 | + if ($coord < 0) { |
|
302 | + $NSEW = 'S'; |
|
303 | + } else { |
|
304 | + $NSEW = 'N'; |
|
305 | + } |
|
272 | 306 | } else { |
273 | - if ($coord < 0) $NSEW = 'W'; |
|
274 | - else $NSEW = 'E'; |
|
307 | + if ($coord < 0) { |
|
308 | + $NSEW = 'W'; |
|
309 | + } else { |
|
310 | + $NSEW = 'E'; |
|
311 | + } |
|
275 | 312 | } |
276 | 313 | $coord = abs($coord); |
277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
314 | 351 | public function hex2str($hex) { |
315 | 352 | $str = ''; |
316 | 353 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
354 | + for($i=0;$i<$hexln;$i+=2) { |
|
355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
356 | + } |
|
318 | 357 | return $str; |
319 | 358 | } |
320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
351 | 390 | $b = $lat2 - $lat1; |
352 | 391 | $c = -($a*$lat1+$b*$lon1); |
353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
354 | - if ($d > -$approx && $d < $approx) return true; |
|
355 | - else return false; |
|
393 | + if ($d > -$approx && $d < $approx) { |
|
394 | + return true; |
|
395 | + } else { |
|
396 | + return false; |
|
397 | + } |
|
356 | 398 | } |
357 | 399 | |
358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
411 | 453 | return $result; |
412 | 454 | } |
413 | 455 | $handle = @opendir('./locale'); |
414 | - if ($handle === false) return $result; |
|
456 | + if ($handle === false) { |
|
457 | + return $result; |
|
458 | + } |
|
415 | 459 | while (false !== ($file = readdir($handle))) { |
416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
478 | 522 | $error = false; |
479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
480 | 524 | if ($fp_in = fopen($source,'rb')) { |
481 | - while (!feof($fp_in)) |
|
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
525 | + while (!feof($fp_in)) { |
|
526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
527 | + } |
|
483 | 528 | fclose($fp_in); |
484 | 529 | } else { |
485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
488 | 533 | } else { |
489 | 534 | $error = true; |
490 | 535 | } |
491 | - if ($error) |
|
492 | - return false; |
|
493 | - else |
|
494 | - return $dest; |
|
536 | + if ($error) { |
|
537 | + return false; |
|
538 | + } else { |
|
539 | + return $dest; |
|
540 | + } |
|
495 | 541 | } |
496 | 542 | |
497 | 543 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
545 | + return $string; |
|
546 | + } |
|
499 | 547 | $chars = array( |
500 | 548 | // Decompositions for Latin-1 Supplement |
501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
619 | 667 | $ip = gethostbyname($host); |
620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
621 | 669 | $r = @socket_connect($s, $ip, $port); |
622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
670 | + if (!socket_set_nonblock($s)) { |
|
671 | + echo "Unable to set nonblock on socket\n"; |
|
672 | + } |
|
623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
624 | 674 | return $s; |
625 | 675 | } |
@@ -664,18 +714,22 @@ discard block |
||
664 | 714 | //NOTE: use a trailing slash for folders!!! |
665 | 715 | //see http://bugs.php.net/bug.php?id=27609 |
666 | 716 | //see http://bugs.php.net/bug.php?id=30931 |
667 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
717 | + if ($path{strlen($path)-1}=='/') { |
|
718 | + // recursively return a temporary file path |
|
668 | 719 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
669 | - else if (is_dir($path)) |
|
670 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
720 | + } else if (is_dir($path)) { |
|
721 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
722 | + } |
|
671 | 723 | // check tmp file for read/write capabilities |
672 | 724 | $rm = file_exists($path); |
673 | 725 | $f = @fopen($path, 'a'); |
674 | - if ($f===false) |
|
675 | - return false; |
|
726 | + if ($f===false) { |
|
727 | + return false; |
|
728 | + } |
|
676 | 729 | fclose($f); |
677 | - if (!$rm) |
|
678 | - unlink($path); |
|
730 | + if (!$rm) { |
|
731 | + unlink($path); |
|
732 | + } |
|
679 | 733 | return true; |
680 | 734 | } |
681 | 735 | } |
@@ -4,11 +4,19 @@ discard block |
||
4 | 4 | if (isset($_SESSION['error'])) { |
5 | 5 | header('Content-Encoding: none;'); |
6 | 6 | echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.'; |
7 | - if (isset($_SESSION['error'])) unset($_SESSION['error']); |
|
8 | - if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']); |
|
9 | - if (isset($_SESSION['next'])) unset($_SESSION['next']); |
|
10 | - if (isset($_SESSION['install'])) unset($_SESSION['install']); |
|
11 | -} |
|
7 | + if (isset($_SESSION['error'])) { |
|
8 | + unset($_SESSION['error']); |
|
9 | + } |
|
10 | + if (isset($_SESSION['errorlst'])) { |
|
11 | + unset($_SESSION['errorlst']); |
|
12 | + } |
|
13 | + if (isset($_SESSION['next'])) { |
|
14 | + unset($_SESSION['next']); |
|
15 | + } |
|
16 | + if (isset($_SESSION['install'])) { |
|
17 | + unset($_SESSION['install']); |
|
18 | + } |
|
19 | + } |
|
12 | 20 | /* |
13 | 21 | if (isset($_SESSION['errorlst'])) { |
14 | 22 | header('Content-Encoding: none;'); |
@@ -156,45 +164,72 @@ discard block |
||
156 | 164 | </div> |
157 | 165 | <p> |
158 | 166 | <label for="dbhost">Database hostname</label> |
159 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
167 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
168 | + print $globalDBhost; |
|
169 | +} |
|
170 | +?>" /> |
|
160 | 171 | </p> |
161 | 172 | <p> |
162 | 173 | <label for="dbport">Database port</label> |
163 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
174 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
175 | + print $globalDBport; |
|
176 | +} |
|
177 | +?>" /> |
|
164 | 178 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
165 | 179 | </p> |
166 | 180 | <p> |
167 | 181 | <label for="dbname">Database name</label> |
168 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
182 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
183 | + print $globalDBname; |
|
184 | +} |
|
185 | +?>" /> |
|
169 | 186 | </p> |
170 | 187 | <p> |
171 | 188 | <label for="dbuser">Database user</label> |
172 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
189 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
190 | + print $globalDBuser; |
|
191 | +} |
|
192 | +?>" /> |
|
173 | 193 | </p> |
174 | 194 | <p> |
175 | 195 | <label for="dbuserpass">Database user password</label> |
176 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
196 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
197 | + print $globalDBpass; |
|
198 | +} |
|
199 | +?>" /> |
|
177 | 200 | </p> |
178 | 201 | </fieldset> |
179 | 202 | <fieldset id="site"> |
180 | 203 | <legend>Site configuration</legend> |
181 | 204 | <p> |
182 | 205 | <label for="sitename">Site name</label> |
183 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
206 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
207 | + print $globalName; |
|
208 | +} |
|
209 | +?>" /> |
|
184 | 210 | </p> |
185 | 211 | <p> |
186 | 212 | <label for="siteurl">Site directory</label> |
187 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
213 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
214 | + print $globalURL; |
|
215 | +} |
|
216 | +?>" /> |
|
188 | 217 | <p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
189 | 218 | </p> |
190 | 219 | <p> |
191 | 220 | <label for="timezone">Timezone</label> |
192 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
221 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
222 | + print $globalTimezone; |
|
223 | +} |
|
224 | +?>" /> |
|
193 | 225 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
194 | 226 | </p> |
195 | 227 | <p> |
196 | 228 | <label for="language">Language</label> |
197 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
229 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
230 | + print $globalLanguage; |
|
231 | +} |
|
232 | +?>" /> |
|
198 | 233 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
199 | 234 | </p> |
200 | 235 | </fieldset> |
@@ -215,11 +250,17 @@ discard block |
||
215 | 250 | <div id="mapbox_data"> |
216 | 251 | <p> |
217 | 252 | <label for="mapboxid">Mapbox id</label> |
218 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
253 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
254 | + print $globalMapboxId; |
|
255 | +} |
|
256 | +?>" /> |
|
219 | 257 | </p> |
220 | 258 | <p> |
221 | 259 | <label for="mapboxtoken">Mapbox token</label> |
222 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
260 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
261 | + print $globalMapboxToken; |
|
262 | +} |
|
263 | +?>" /> |
|
223 | 264 | </p> |
224 | 265 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
225 | 266 | </div> |
@@ -227,7 +268,10 @@ discard block |
||
227 | 268 | <div id="google_data"> |
228 | 269 | <p> |
229 | 270 | <label for="googlekey">Google API key</label> |
230 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
271 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
272 | + print $globalGoogleAPIKey; |
|
273 | +} |
|
274 | +?>" /> |
|
231 | 275 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
232 | 276 | </p> |
233 | 277 | </div> |
@@ -235,7 +279,10 @@ discard block |
||
235 | 279 | <div id="bing_data"> |
236 | 280 | <p> |
237 | 281 | <label for="bingkey">Bing Map key</label> |
238 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
282 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
283 | + print $globalBingMapKey; |
|
284 | +} |
|
285 | +?>" /> |
|
239 | 286 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
240 | 287 | </p> |
241 | 288 | </div> |
@@ -243,7 +290,10 @@ discard block |
||
243 | 290 | <div id="mapquest_data"> |
244 | 291 | <p> |
245 | 292 | <label for="mapquestkey">MapQuest key</label> |
246 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
293 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
294 | + print $globalMapQuestKey; |
|
295 | +} |
|
296 | +?>" /> |
|
247 | 297 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
248 | 298 | </p> |
249 | 299 | </div> |
@@ -251,11 +301,17 @@ discard block |
||
251 | 301 | <div id="here_data"> |
252 | 302 | <p> |
253 | 303 | <label for="hereappid">Here App_Id</label> |
254 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
304 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
305 | + print $globalHereappId; |
|
306 | +} |
|
307 | +?>" /> |
|
255 | 308 | </p> |
256 | 309 | <p> |
257 | 310 | <label for="hereappcode">Here App_Code</label> |
258 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
311 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
312 | + print $globalHereappCode; |
|
313 | +} |
|
314 | +?>" /> |
|
259 | 315 | </p> |
260 | 316 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
261 | 317 | </div> |
@@ -263,7 +319,10 @@ discard block |
||
263 | 319 | <div id="openweathermap_data"> |
264 | 320 | <p> |
265 | 321 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
266 | - <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
322 | + <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
323 | + print $globalOpenWeatherMapKey; |
|
324 | +} |
|
325 | +?>" /> |
|
267 | 326 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
268 | 327 | </p> |
269 | 328 | </div> |
@@ -273,42 +332,86 @@ discard block |
||
273 | 332 | <legend>Coverage area</legend> |
274 | 333 | <p> |
275 | 334 | <label for="latitudemax">The maximum latitude (north)</label> |
276 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
335 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
336 | + print $globalLatitudeMax; |
|
337 | +} |
|
338 | +?>" /> |
|
277 | 339 | </p> |
278 | 340 | <p> |
279 | 341 | <label for="latitudemin">The minimum latitude (south)</label> |
280 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
342 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
343 | + print $globalLatitudeMin; |
|
344 | +} |
|
345 | +?>" /> |
|
281 | 346 | </p> |
282 | 347 | <p> |
283 | 348 | <label for="longitudemax">The maximum longitude (west)</label> |
284 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
349 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
350 | + print $globalLongitudeMax; |
|
351 | +} |
|
352 | +?>" /> |
|
285 | 353 | </p> |
286 | 354 | <p> |
287 | 355 | <label for="longitudemin">The minimum longitude (east)</label> |
288 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
356 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
357 | + print $globalLongitudeMin; |
|
358 | +} |
|
359 | +?>" /> |
|
289 | 360 | </p> |
290 | 361 | <p> |
291 | 362 | <label for="latitudecenter">The latitude center</label> |
292 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
363 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
364 | + print $globalCenterLatitude; |
|
365 | +} |
|
366 | +?>" /> |
|
293 | 367 | </p> |
294 | 368 | <p> |
295 | 369 | <label for="longitudecenter">The longitude center</label> |
296 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
370 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
371 | + print $globalCenterLongitude; |
|
372 | +} |
|
373 | +?>" /> |
|
297 | 374 | </p> |
298 | 375 | <p> |
299 | 376 | <label for="livezoom">Default Zoom on live map</label> |
300 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
377 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
378 | + print $globalLiveZoom; |
|
379 | +} else { |
|
380 | + print '9'; |
|
381 | +} |
|
382 | +?>" /> |
|
301 | 383 | </p> |
302 | 384 | <p> |
303 | 385 | <label for="squawk_country">Country for squawk usage</label> |
304 | 386 | <select name="squawk_country" id="squawk_country"> |
305 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
306 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
307 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
308 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
309 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
310 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
311 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
387 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
388 | + print ' selected '; |
|
389 | +} |
|
390 | +?>>UK</option> |
|
391 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
392 | + print ' selected '; |
|
393 | +} |
|
394 | +?>>NZ</option> |
|
395 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
396 | + print ' selected '; |
|
397 | +} |
|
398 | +?>>US</option> |
|
399 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
400 | + print ' selected '; |
|
401 | +} |
|
402 | +?>>AU</option> |
|
403 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
404 | + print ' selected '; |
|
405 | +} |
|
406 | +?>>NL</option> |
|
407 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
408 | + print ' selected '; |
|
409 | +} |
|
410 | +?>>FR</option> |
|
411 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
412 | + print ' selected '; |
|
413 | +} |
|
414 | +?>>TR</option> |
|
312 | 415 | </select> |
313 | 416 | </p> |
314 | 417 | </fieldset> |
@@ -317,15 +420,24 @@ discard block |
||
317 | 420 | <p><i>Only put in DB flights that are inside a circle</i></p> |
318 | 421 | <p> |
319 | 422 | <label for="latitude">Center latitude</label> |
320 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
423 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
424 | + echo $globalDistanceIgnore['latitude']; |
|
425 | +} |
|
426 | +?>" /> |
|
321 | 427 | </p> |
322 | 428 | <p> |
323 | 429 | <label for="longitude">Center longitude</label> |
324 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
430 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
431 | + echo $globalDistanceIgnore['longitude']; |
|
432 | +} |
|
433 | +?>" /> |
|
325 | 434 | </p> |
326 | 435 | <p> |
327 | 436 | <label for="Distance">Distance (in km)</label> |
328 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
437 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
438 | + echo $globalDistanceIgnore['distance']; |
|
439 | +} |
|
440 | +?>" /> |
|
329 | 441 | </p> |
330 | 442 | </fieldset> |
331 | 443 | <fieldset id="sourceloc"> |
@@ -438,11 +550,17 @@ discard block |
||
438 | 550 | <div id="flightaware_data"> |
439 | 551 | <p> |
440 | 552 | <label for="flightawareusername">FlightAware username</label> |
441 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
553 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
554 | + print $globalFlightAwareUsername; |
|
555 | +} |
|
556 | +?>" /> |
|
442 | 557 | </p> |
443 | 558 | <p> |
444 | 559 | <label for="flightawarepassword">FlightAware password/API key</label> |
445 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
560 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
561 | + print $globalFlightAwarePassword; |
|
562 | +} |
|
563 | +?>" /> |
|
446 | 564 | </p> |
447 | 565 | </div> |
448 | 566 | --> |
@@ -484,7 +602,10 @@ discard block |
||
484 | 602 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
485 | 603 | ?> |
486 | 604 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
487 | - <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
605 | + <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) { |
|
606 | + print $source['port']; |
|
607 | +} |
|
608 | +?>" /></td> |
|
488 | 609 | <?php |
489 | 610 | } else { |
490 | 611 | $hostport = explode(':',$source['host']); |
@@ -503,33 +624,102 @@ discard block |
||
503 | 624 | ?> |
504 | 625 | <td> |
505 | 626 | <select name="format[]" id="format"> |
506 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
507 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
508 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
509 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
510 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
511 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
512 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
513 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
514 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
515 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
516 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
517 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
518 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
519 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
520 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
521 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
522 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
523 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
524 | - <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option> |
|
525 | - <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option> |
|
627 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
628 | + print 'selected'; |
|
629 | +} |
|
630 | +?>>Auto</option> |
|
631 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
632 | + print 'selected'; |
|
633 | +} |
|
634 | +?>>SBS</option> |
|
635 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
636 | + print 'selected'; |
|
637 | +} |
|
638 | +?>>TSV</option> |
|
639 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
640 | + print 'selected'; |
|
641 | +} |
|
642 | +?>>Raw</option> |
|
643 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
644 | + print 'selected'; |
|
645 | +} |
|
646 | +?>>APRS</option> |
|
647 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
648 | + print 'selected'; |
|
649 | +} |
|
650 | +?>>Radarcape deltadb.txt</option> |
|
651 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
652 | + print 'selected'; |
|
653 | +} |
|
654 | +?>>Vatsim</option> |
|
655 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
656 | + print 'selected'; |
|
657 | +} |
|
658 | +?>>Virtual Radar Server AircraftList.json</option> |
|
659 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
660 | + print 'selected'; |
|
661 | +} |
|
662 | +?>>Virtual Radar Server TCP</option> |
|
663 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
664 | + print 'selected'; |
|
665 | +} |
|
666 | +?>>phpVMS</option> |
|
667 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
668 | + print 'selected'; |
|
669 | +} |
|
670 | +?>>Virtual Airlines Manager</option> |
|
671 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
672 | + print 'selected'; |
|
673 | +} |
|
674 | +?>>IVAO</option> |
|
675 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
676 | + print 'selected'; |
|
677 | +} |
|
678 | +?>>FlightGear Multiplayer</option> |
|
679 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
680 | + print 'selected'; |
|
681 | +} |
|
682 | +?>>FlightGear Singleplayer</option> |
|
683 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
684 | + print 'selected'; |
|
685 | +} |
|
686 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
687 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
688 | + print 'selected'; |
|
689 | +} |
|
690 | +?>>ACARS SBS-3 over TCP</option> |
|
691 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
692 | + print 'selected'; |
|
693 | +} |
|
694 | +?>>NMEA AIS over TCP</option> |
|
695 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
696 | + print 'selected'; |
|
697 | +} |
|
698 | +?>>AirWhere website</option> |
|
699 | + <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') { |
|
700 | + print 'selected'; |
|
701 | +} |
|
702 | +?>>HidnSeek Callback</option> |
|
703 | + <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') { |
|
704 | + print 'selected'; |
|
705 | +} |
|
706 | +?>>Blitzortung</option> |
|
526 | 707 | </select> |
527 | 708 | </td> |
528 | 709 | <td> |
529 | - <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
710 | + <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) { |
|
711 | + print $source['name']; |
|
712 | +} |
|
713 | +?>" /> |
|
530 | 714 | </td> |
531 | - <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
532 | - <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
715 | + <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
716 | + print 'checked'; |
|
717 | +} |
|
718 | +?> /></td> |
|
719 | + <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
720 | + print 'checked'; |
|
721 | +} |
|
722 | +?> /></td> |
|
533 | 723 | <td> |
534 | 724 | <select name="timezones[]" id="timezones"> |
535 | 725 | <?php |
@@ -539,7 +729,9 @@ discard block |
||
539 | 729 | print '<option selected>'.$timezones.'</option>'; |
540 | 730 | } elseif (!isset($source['timezone']) && $timezones == 'UTC') { |
541 | 731 | print '<option selected>'.$timezones.'</option>'; |
542 | - } else print '<option>'.$timezones.'</option>'; |
|
732 | + } else { |
|
733 | + print '<option>'.$timezones.'</option>'; |
|
734 | + } |
|
543 | 735 | } |
544 | 736 | ?> |
545 | 737 | </select> |
@@ -589,7 +781,9 @@ discard block |
||
589 | 781 | foreach($timezonelist as $timezones){ |
590 | 782 | if ($timezones == 'UTC') { |
591 | 783 | print '<option selected>'.$timezones.'</option>'; |
592 | - } else print '<option>'.$timezones.'</option>'; |
|
784 | + } else { |
|
785 | + print '<option>'.$timezones.'</option>'; |
|
786 | + } |
|
593 | 787 | } |
594 | 788 | ?> |
595 | 789 | </select> |
@@ -612,11 +806,17 @@ discard block |
||
612 | 806 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
613 | 807 | <p> |
614 | 808 | <label for="acarshost">ACARS UDP host</label> |
615 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
809 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
810 | + print $globalACARSHost; |
|
811 | +} |
|
812 | +?>" /> |
|
616 | 813 | </p> |
617 | 814 | <p> |
618 | 815 | <label for="acarsport">ACARS UDP port</label> |
619 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
816 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
817 | + print $globalACARSPort; |
|
818 | +} |
|
819 | +?>" /> |
|
620 | 820 | </p> |
621 | 821 | </fieldset> |
622 | 822 | </div> |
@@ -703,13 +903,19 @@ discard block |
||
703 | 903 | <div id="schedules_options"> |
704 | 904 | <p> |
705 | 905 | <label for="britishairways">British Airways API Key</label> |
706 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
906 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) { |
|
907 | + print $globalBritishAirwaysKey; |
|
908 | +} |
|
909 | +?>" /> |
|
707 | 910 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
708 | 911 | </p> |
709 | 912 | <!-- |
710 | 913 | <p> |
711 | 914 | <label for="transavia">Transavia Test API Consumer Key</label> |
712 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
915 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
916 | + print $globalTransaviaKey; |
|
917 | +} |
|
918 | +?>" /> |
|
713 | 919 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
714 | 920 | </p> |
715 | 921 | --> |
@@ -718,10 +924,16 @@ discard block |
||
718 | 924 | <b>Lufthansa API Key</b> |
719 | 925 | <p> |
720 | 926 | <label for="lufthansakey">Key</label> |
721 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
927 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
928 | + print $globalLufthansaKey['key']; |
|
929 | +} |
|
930 | +?>" /> |
|
722 | 931 | </p><p> |
723 | 932 | <label for="lufthansasecret">Secret</label> |
724 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
933 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
934 | + print $globalLufthansaKey['secret']; |
|
935 | +} |
|
936 | +?>" /> |
|
725 | 937 | </p> |
726 | 938 | </div> |
727 | 939 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -741,7 +953,10 @@ discard block |
||
741 | 953 | </p> |
742 | 954 | <p> |
743 | 955 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
744 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
956 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
957 | + print $globalNOTAMSource; |
|
958 | +} |
|
959 | +?>" /> |
|
745 | 960 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
746 | 961 | </p> |
747 | 962 | <br /> |
@@ -757,14 +972,20 @@ discard block |
||
757 | 972 | <div id="metarsrc"> |
758 | 973 | <p> |
759 | 974 | <label for="metarsource">URL of your METAR source</label> |
760 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
975 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
976 | + print $globalMETARurl; |
|
977 | +} |
|
978 | +?>" /> |
|
761 | 979 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
762 | 980 | </p> |
763 | 981 | </div> |
764 | 982 | <br /> |
765 | 983 | <p> |
766 | 984 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
767 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
985 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
986 | + print $globalBitlyAccessToken; |
|
987 | +} |
|
988 | +?>" /> |
|
768 | 989 | </p> |
769 | 990 | <br /> |
770 | 991 | <p> |
@@ -780,11 +1001,26 @@ discard block |
||
780 | 1001 | <p> |
781 | 1002 | <label for="geoid_source">Geoid Source</label> |
782 | 1003 | <select name="geoid_source" id="geoid_source"> |
783 | - <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option> |
|
784 | - <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option> |
|
785 | - <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option> |
|
786 | - <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option> |
|
787 | - <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option> |
|
1004 | + <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') { |
|
1005 | + print ' selected="selected"'; |
|
1006 | +} |
|
1007 | +?>>EGM96 15' (2.1MB)</option> |
|
1008 | + <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') { |
|
1009 | + print ' selected="selected"'; |
|
1010 | +} |
|
1011 | +?>>EGM96 5' (19MB)</option> |
|
1012 | + <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') { |
|
1013 | + print ' selected="selected"'; |
|
1014 | +} |
|
1015 | +?>>EGM2008 5' (19MB)</option> |
|
1016 | + <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') { |
|
1017 | + print ' selected="selected"'; |
|
1018 | +} |
|
1019 | +?>>EGM2008 2.5' (75MB)</option> |
|
1020 | + <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') { |
|
1021 | + print ' selected="selected"'; |
|
1022 | +} |
|
1023 | +?>>EGM2008 1' (470MB)</option> |
|
788 | 1024 | </select> |
789 | 1025 | <p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p> |
790 | 1026 | </p> |
@@ -802,7 +1038,12 @@ discard block |
||
802 | 1038 | </p> |
803 | 1039 | <p> |
804 | 1040 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
805 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" /> |
|
1041 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
1042 | + print $globalArchiveMonths; |
|
1043 | +} else { |
|
1044 | + echo '1'; |
|
1045 | +} |
|
1046 | +?>" /> |
|
806 | 1047 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
807 | 1048 | </p> |
808 | 1049 | <p> |
@@ -812,12 +1053,22 @@ discard block |
||
812 | 1053 | </p> |
813 | 1054 | <p> |
814 | 1055 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
815 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" /> |
|
1056 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
1057 | + print $globalArchiveKeepMonths; |
|
1058 | +} else { |
|
1059 | + echo '1'; |
|
1060 | +} |
|
1061 | +?>" /> |
|
816 | 1062 | <p class="help-block">0 to disable</p> |
817 | 1063 | </p> |
818 | 1064 | <p> |
819 | 1065 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
820 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" /> |
|
1066 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
1067 | + print $globalArchiveKeepTrackMonths; |
|
1068 | +} else { |
|
1069 | + echo '1'; |
|
1070 | +} |
|
1071 | +?>" /> |
|
821 | 1072 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
822 | 1073 | </p> |
823 | 1074 | <br /> |
@@ -827,7 +1078,12 @@ discard block |
||
827 | 1078 | <p class="help-block">Uncheck if the script is running as cron job</p> |
828 | 1079 | <div id="cronends"> |
829 | 1080 | <label for="cronend">Run script for xx seconds</label> |
830 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
1081 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
1082 | + print $globalCronEnd; |
|
1083 | +} else { |
|
1084 | + print '0'; |
|
1085 | +} |
|
1086 | +?>" /> |
|
831 | 1087 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
832 | 1088 | </div> |
833 | 1089 | </p> |
@@ -880,15 +1136,30 @@ discard block |
||
880 | 1136 | <br /> |
881 | 1137 | <p> |
882 | 1138 | <label for="refresh">Show flights detected since xxx seconds</label> |
883 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
1139 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
1140 | + echo $globalLiveInterval; |
|
1141 | +} else { |
|
1142 | + echo '200'; |
|
1143 | +} |
|
1144 | +?>" /> |
|
884 | 1145 | </p> |
885 | 1146 | <p> |
886 | 1147 | <label for="maprefresh">Live map refresh (in seconds)</label> |
887 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
1148 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
1149 | + echo $globalMapRefresh; |
|
1150 | +} else { |
|
1151 | + echo '30'; |
|
1152 | +} |
|
1153 | +?>" /> |
|
888 | 1154 | </p> |
889 | 1155 | <p> |
890 | 1156 | <label for="mapidle">Map idle timeout (in minutes)</label> |
891 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
1157 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
1158 | + echo $globalMapIdleTimeout; |
|
1159 | +} else { |
|
1160 | + echo '30'; |
|
1161 | +} |
|
1162 | +?>" /> |
|
892 | 1163 | <p class="help-block">0 to disable</p> |
893 | 1164 | </p> |
894 | 1165 | <p> |
@@ -903,12 +1174,20 @@ discard block |
||
903 | 1174 | <br /> |
904 | 1175 | <p> |
905 | 1176 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
906 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
1177 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
1178 | + echo $globalClosestMinDist; |
|
1179 | +} else { |
|
1180 | + echo '50'; |
|
1181 | +} |
|
1182 | +?>" /> |
|
907 | 1183 | </p> |
908 | 1184 | <br /> |
909 | 1185 | <p> |
910 | 1186 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
911 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
1187 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
1188 | + echo $globalAircraftSize; |
|
1189 | +} |
|
1190 | +?>" /> |
|
912 | 1191 | </p> |
913 | 1192 | <br /> |
914 | 1193 | <p> |
@@ -921,7 +1200,12 @@ discard block |
||
921 | 1200 | if (extension_loaded('gd') && function_exists('gd_info')) { |
922 | 1201 | ?> |
923 | 1202 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
924 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
1203 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
1204 | + echo $globalAircraftIconColor; |
|
1205 | +} else { |
|
1206 | + echo '1a3151'; |
|
1207 | +} |
|
1208 | +?>" /> |
|
925 | 1209 | <?php |
926 | 1210 | if (!is_writable('../cache')) { |
927 | 1211 | ?> |
@@ -939,14 +1223,27 @@ discard block |
||
939 | 1223 | <p> |
940 | 1224 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
941 | 1225 | <div class="range"> |
942 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
943 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
1226 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
1227 | + echo $globalAirportZoom; |
|
1228 | +} else { |
|
1229 | + echo '7'; |
|
1230 | +} |
|
1231 | +?>" /> |
|
1232 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
1233 | + echo $globalAirportZoom; |
|
1234 | +} else { |
|
1235 | + echo '7'; |
|
1236 | +} |
|
1237 | +?></output> |
|
944 | 1238 | </div> |
945 | 1239 | </p> |
946 | 1240 | <br /> |
947 | 1241 | <p> |
948 | 1242 | <label for="customcss">Custom CSS web path</label> |
949 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
1243 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
1244 | + echo $globalCustomCSS; |
|
1245 | +} |
|
1246 | +?>" /> |
|
950 | 1247 | </p> |
951 | 1248 | </fieldset> |
952 | 1249 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -973,8 +1270,12 @@ discard block |
||
973 | 1270 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
974 | 1271 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
975 | 1272 | |
976 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
977 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1273 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
1274 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
1275 | + } |
|
1276 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
1277 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1278 | + } |
|
978 | 1279 | |
979 | 1280 | $_SESSION['database_root'] = $dbroot; |
980 | 1281 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -1042,15 +1343,23 @@ discard block |
||
1042 | 1343 | $source_city = $_POST['source_city']; |
1043 | 1344 | $source_country = $_POST['source_country']; |
1044 | 1345 | $source_ref = $_POST['source_ref']; |
1045 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
1046 | - else $source_id = array(); |
|
1346 | + if (isset($source_id)) { |
|
1347 | + $source_id = $_POST['source_id']; |
|
1348 | + } else { |
|
1349 | + $source_id = array(); |
|
1350 | + } |
|
1047 | 1351 | |
1048 | 1352 | $sources = array(); |
1049 | 1353 | foreach ($source_name as $keys => $name) { |
1050 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1051 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1354 | + if (isset($source_id[$keys])) { |
|
1355 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1356 | + } else { |
|
1357 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1358 | + } |
|
1359 | + } |
|
1360 | + if (count($sources) > 0) { |
|
1361 | + $_SESSION['sources'] = $sources; |
|
1052 | 1362 | } |
1053 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
1054 | 1363 | |
1055 | 1364 | //$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING); |
1056 | 1365 | //$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT); |
@@ -1071,17 +1380,29 @@ discard block |
||
1071 | 1380 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
1072 | 1381 | |
1073 | 1382 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
1074 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1075 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1383 | + if ($globalaircraft == 'aircraft') { |
|
1384 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1385 | + } else { |
|
1386 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1387 | + } |
|
1076 | 1388 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
1077 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1078 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1389 | + if ($globaltracker == 'tracker') { |
|
1390 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1391 | + } else { |
|
1392 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1393 | + } |
|
1079 | 1394 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
1080 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1081 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1395 | + if ($globalmarine == 'marine') { |
|
1396 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1397 | + } else { |
|
1398 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1399 | + } |
|
1082 | 1400 | $globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING); |
1083 | - if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
1084 | - else $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
1401 | + if ($globalsatellite == 'satellite') { |
|
1402 | + $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
1403 | + } else { |
|
1404 | + $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
1405 | + } |
|
1085 | 1406 | |
1086 | 1407 | /* |
1087 | 1408 | $globalSBS1Hosts = array(); |
@@ -1103,23 +1424,37 @@ discard block |
||
1103 | 1424 | $name = $_POST['name']; |
1104 | 1425 | $format = $_POST['format']; |
1105 | 1426 | $timezones = $_POST['timezones']; |
1106 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
1107 | - else $sourcestats = array(); |
|
1108 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
1109 | - else $noarchive = array(); |
|
1427 | + if (isset($_POST['sourcestats'])) { |
|
1428 | + $sourcestats = $_POST['sourcestats']; |
|
1429 | + } else { |
|
1430 | + $sourcestats = array(); |
|
1431 | + } |
|
1432 | + if (isset($_POST['noarchive'])) { |
|
1433 | + $noarchive = $_POST['noarchive']; |
|
1434 | + } else { |
|
1435 | + $noarchive = array(); |
|
1436 | + } |
|
1110 | 1437 | $gSources = array(); |
1111 | 1438 | $forcepilots = false; |
1112 | 1439 | foreach ($host as $key => $h) { |
1113 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
1114 | - else $cov = 'FALSE'; |
|
1115 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
1116 | - else $arch = 'FALSE'; |
|
1440 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
1441 | + $cov = 'TRUE'; |
|
1442 | + } else { |
|
1443 | + $cov = 'FALSE'; |
|
1444 | + } |
|
1445 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
1446 | + $arch = 'TRUE'; |
|
1447 | + } else { |
|
1448 | + $arch = 'FALSE'; |
|
1449 | + } |
|
1117 | 1450 | if (strpos($format[$key],'_callback')) { |
1118 | 1451 | $gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE'); |
1119 | 1452 | } elseif ($h != '' || $name[$key] != '') { |
1120 | 1453 | $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE'); |
1121 | 1454 | } |
1122 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
1455 | + if ($format[$key] == 'airwhere') { |
|
1456 | + $forcepilots = true; |
|
1457 | + } |
|
1123 | 1458 | } |
1124 | 1459 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
1125 | 1460 | |
@@ -1150,7 +1485,9 @@ discard block |
||
1150 | 1485 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
1151 | 1486 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1152 | 1487 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
1153 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1488 | + } else { |
|
1489 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1490 | + } |
|
1154 | 1491 | |
1155 | 1492 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
1156 | 1493 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1189,7 +1526,9 @@ discard block |
||
1189 | 1526 | |
1190 | 1527 | // Create in settings.php keys not yet configurable if not already here |
1191 | 1528 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1192 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1529 | + if (!isset($globalDebug)) { |
|
1530 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1531 | + } |
|
1193 | 1532 | |
1194 | 1533 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
1195 | 1534 | if ($resetyearstats == 'resetyearstats') { |
@@ -1226,37 +1565,56 @@ discard block |
||
1226 | 1565 | } |
1227 | 1566 | */ |
1228 | 1567 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
1229 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1230 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1231 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1232 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1568 | + if ($globalsbs == 'sbs') { |
|
1569 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1570 | + } else { |
|
1571 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1572 | + } |
|
1573 | + if ($globalaprs == 'aprs') { |
|
1574 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1575 | + } else { |
|
1576 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1577 | + } |
|
1233 | 1578 | $va = false; |
1234 | 1579 | if ($globalivao == 'ivao') { |
1235 | 1580 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
1236 | 1581 | $va = true; |
1237 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1582 | + } else { |
|
1583 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1584 | + } |
|
1238 | 1585 | if ($globalvatsim == 'vatsim') { |
1239 | 1586 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
1240 | 1587 | $va = true; |
1241 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1588 | + } else { |
|
1589 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1590 | + } |
|
1242 | 1591 | if ($globalphpvms == 'phpvms') { |
1243 | 1592 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
1244 | 1593 | $va = true; |
1245 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1594 | + } else { |
|
1595 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1596 | + } |
|
1246 | 1597 | if ($globalvam == 'vam') { |
1247 | 1598 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
1248 | 1599 | $va = true; |
1249 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1600 | + } else { |
|
1601 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1602 | + } |
|
1250 | 1603 | if ($va) { |
1251 | 1604 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
1252 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1605 | + } else { |
|
1606 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1607 | + } |
|
1253 | 1608 | if ($globalva == 'va' || $va) { |
1254 | 1609 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
1255 | 1610 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
1256 | 1611 | } else { |
1257 | 1612 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
1258 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1259 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1613 | + if ($forcepilots) { |
|
1614 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1615 | + } else { |
|
1616 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1617 | + } |
|
1260 | 1618 | } |
1261 | 1619 | |
1262 | 1620 | |
@@ -1432,7 +1790,9 @@ discard block |
||
1432 | 1790 | $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
1433 | 1791 | } |
1434 | 1792 | |
1435 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1793 | + if (!isset($globalTransaction)) { |
|
1794 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1795 | + } |
|
1436 | 1796 | |
1437 | 1797 | // Set some defaults values... |
1438 | 1798 | if (!isset($globalAircraftImageSources)) { |
@@ -1447,15 +1807,23 @@ discard block |
||
1447 | 1807 | |
1448 | 1808 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1449 | 1809 | |
1450 | - if ($error == '') settings::modify_settings($settings); |
|
1451 | - if ($error == '') settings::comment_settings($settings_comment); |
|
1810 | + if ($error == '') { |
|
1811 | + settings::modify_settings($settings); |
|
1812 | + } |
|
1813 | + if ($error == '') { |
|
1814 | + settings::comment_settings($settings_comment); |
|
1815 | + } |
|
1452 | 1816 | if ($error != '') { |
1453 | 1817 | print '<div class="info column">'.$error.'</div>'; |
1454 | 1818 | require('../footer.php'); |
1455 | 1819 | exit; |
1456 | 1820 | } else { |
1457 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
1458 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
1821 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
1822 | + $_SESSION['waypoints'] = 1; |
|
1823 | + } |
|
1824 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
1825 | + $_SESSION['owner'] = 1; |
|
1826 | + } |
|
1459 | 1827 | if (isset($_POST['createdb'])) { |
1460 | 1828 | $_SESSION['install'] = 'database_create'; |
1461 | 1829 | } else { |
@@ -1492,10 +1860,18 @@ discard block |
||
1492 | 1860 | $popw = false; |
1493 | 1861 | foreach ($_SESSION['done'] as $done) { |
1494 | 1862 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
1495 | - if ($done == 'Create database') $pop = true; |
|
1496 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1497 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1498 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1863 | + if ($done == 'Create database') { |
|
1864 | + $pop = true; |
|
1865 | + } |
|
1866 | + if ($_SESSION['install'] == 'database_create') { |
|
1867 | + $pop = true; |
|
1868 | + } |
|
1869 | + if ($_SESSION['install'] == 'database_import') { |
|
1870 | + $popi = true; |
|
1871 | + } |
|
1872 | + if ($_SESSION['install'] == 'waypoints') { |
|
1873 | + $popw = true; |
|
1874 | + } |
|
1499 | 1875 | } |
1500 | 1876 | if ($pop) { |
1501 | 1877 | sleep(5); |
@@ -1506,7 +1882,9 @@ discard block |
||
1506 | 1882 | } else if ($popw) { |
1507 | 1883 | sleep(5); |
1508 | 1884 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
1509 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1885 | + } else { |
|
1886 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1887 | + } |
|
1510 | 1888 | print '</div></ul>'; |
1511 | 1889 | print '<div id="error"></div>'; |
1512 | 1890 | /* foreach ($_SESSION['done'] as $done) { |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | public function __construct($dbc = null) { |
10 | 10 | $Connection = new Connection($dbc); |
11 | 11 | $this->db = $Connection->db(); |
12 | - if ($this->db === null) die('Error: No DB connection.'); |
|
12 | + if ($this->db === null) { |
|
13 | + die('Error: No DB connection.'); |
|
14 | + } |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
26 | 28 | $reg = $registration; |
27 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
29 | + if ($reg == '' && $aircraft_icao != '') { |
|
30 | + $reg = $aircraft_icao.$airline_icao; |
|
31 | + } |
|
28 | 32 | $reg = trim($reg); |
29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | $sth = $this->db->prepare($query); |
33 | 37 | $sth->execute(array(':registration' => $reg)); |
34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | - if (!empty($result)) return $result; |
|
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
37 | - else return array(); |
|
39 | + if (!empty($result)) { |
|
40 | + return $result; |
|
41 | + } elseif ($registration != '') { |
|
42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
38 | 46 | } |
39 | 47 | |
40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
77 | 85 | public function getExifCopyright($url) { |
78 | 86 | $exif = exif_read_data($url); |
79 | 87 | $copyright = ''; |
80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
90 | + } elseif (isset($exif['copyright'])) { |
|
91 | + $copyright = $exif['copyright']; |
|
92 | + } |
|
82 | 93 | if ($copyright != '') { |
83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
97 | 108 | { |
98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
111 | + return ''; |
|
112 | + } |
|
100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
101 | 114 | $registration = trim($registration); |
102 | 115 | //getting the aircraft image |
103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
116 | + if ($globalDebug && $registration != '') { |
|
117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
122 | + } |
|
106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
124 | + if ($registration == '' && $aircraft_icao != '') { |
|
125 | + $registration = $aircraft_icao.$airline_icao; |
|
126 | + } |
|
108 | 127 | if ($image_url['original'] != '') { |
109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
128 | + if ($globalDebug) { |
|
129 | + echo 'Found !'."\n"; |
|
130 | + } |
|
110 | 131 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
111 | 132 | try { |
112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
115 | 136 | echo $e->getMessage()."\n"; |
116 | 137 | return "error"; |
117 | 138 | } |
118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
139 | + } elseif ($globalDebug) { |
|
140 | + echo "Not found :'(\n"; |
|
141 | + } |
|
119 | 142 | return "success"; |
120 | 143 | } |
121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
129 | 152 | { |
130 | 153 | global $globalDebug,$globalMarineImageFetch; |
131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
155 | + return ''; |
|
156 | + } |
|
132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
138 | 163 | $identity = $Marine->getIdentity($mmsi); |
139 | 164 | if (isset($identity[0]['mmsi'])) { |
140 | 165 | $imo = $identity[0]['imo']; |
141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
166 | + if ($identity[0]['ship_name'] != '') { |
|
167 | + $name = $identity[0]['ship_name']; |
|
168 | + } |
|
142 | 169 | } |
143 | 170 | } |
144 | 171 | unset($Marine); |
145 | 172 | |
146 | 173 | //getting the aircraft image |
147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
174 | + if ($globalDebug && $name != '') { |
|
175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
176 | + } |
|
148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
149 | 178 | if ($image_url['original'] != '') { |
150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo 'Found !'."\n"; |
|
181 | + } |
|
151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
152 | 183 | try { |
153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
156 | 187 | echo $e->getMessage()."\n"; |
157 | 188 | return "error"; |
158 | 189 | } |
159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
190 | + } elseif ($globalDebug) { |
|
191 | + echo "Not found :'(\n"; |
|
192 | + } |
|
160 | 193 | return "success"; |
161 | 194 | } |
162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
171 | 204 | { |
172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 206 | $Spotter = new Spotter($this->db); |
174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
207 | + if (!isset($globalIVAO)) { |
|
208 | + $globalIVAO = FALSE; |
|
209 | + } |
|
175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
176 | 211 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
214 | + } |
|
178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
181 | - else $aircraft_name = ''; |
|
182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
183 | - else $aircraft_icao = ''; |
|
184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
185 | - else $airline_icao = ''; |
|
217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
219 | + } else { |
|
220 | + $aircraft_name = ''; |
|
221 | + } |
|
222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
224 | + } else { |
|
225 | + $aircraft_icao = ''; |
|
226 | + } |
|
227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
229 | + } else { |
|
230 | + $airline_icao = ''; |
|
231 | + } |
|
186 | 232 | } elseif ($aircraft_icao != '') { |
187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
189 | - else $aircraft_name = ''; |
|
234 | + if (isset($aircraft_info[0]['type'])) { |
|
235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
236 | + } else { |
|
237 | + $aircraft_name = ''; |
|
238 | + } |
|
190 | 239 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
240 | + } else { |
|
241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
242 | + } |
|
192 | 243 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
244 | + if (!isset($globalAircraftImageSources)) { |
|
245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
246 | + } |
|
194 | 247 | foreach ($globalAircraftImageSources as $source) { |
195 | 248 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
207 | - } |
|
208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
251 | + } |
|
252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'bing') { |
|
259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'wikimedia') { |
|
265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if ($source == 'customsources') { |
|
277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
278 | + } |
|
279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
280 | + return $images_array; |
|
281 | + } |
|
282 | + } |
|
283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
284 | + return $this->findAircraftImage($aircraft_icao); |
|
285 | + } |
|
209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
210 | 287 | } |
211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
227 | 304 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
305 | + if (strlen($name) < 4) { |
|
306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
307 | + } |
|
229 | 308 | /* |
230 | 309 | $Marine = new Marine($this->db); |
231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
237 | 316 | } |
238 | 317 | unset($Marine); |
239 | 318 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
319 | + if (!isset($globalMarineImageSources)) { |
|
320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
321 | + } |
|
241 | 322 | foreach ($globalMarineImageSources as $source) { |
242 | 323 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
324 | + if ($source == 'flickr') { |
|
325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'bing') { |
|
328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'deviantart') { |
|
331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'wikimedia') { |
|
334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if ($source == 'customsources') { |
|
337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
338 | + } |
|
339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
340 | + return $images_array; |
|
341 | + } |
|
249 | 342 | } |
250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
251 | 344 | } |
@@ -268,7 +361,9 @@ discard block |
||
268 | 361 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
269 | 362 | } |
270 | 363 | $data = $Common->getData($url); |
271 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
364 | + if (substr($data, 0, 5) != "<?xml") { |
|
365 | + return false; |
|
366 | + } |
|
272 | 367 | if ($xml = simplexml_load_string($data)) { |
273 | 368 | if (isset($xml->channel->item)) { |
274 | 369 | $image_url = array(); |
@@ -307,7 +402,9 @@ discard block |
||
307 | 402 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
308 | 403 | } |
309 | 404 | $data = $Common->getData($url); |
310 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
405 | + if (substr($data, 0, 5) != "<?xml") { |
|
406 | + return false; |
|
407 | + } |
|
311 | 408 | if ($xml = simplexml_load_string($data)) { |
312 | 409 | if (isset($xml->channel->item->link)) { |
313 | 410 | $image_url = array(); |
@@ -411,14 +508,22 @@ discard block |
||
411 | 508 | public function fromFlickr($type,$registration,$name='') { |
412 | 509 | $Common = new Common(); |
413 | 510 | if ($type == 'aircraft') { |
414 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
415 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
511 | + if ($name != '') { |
|
512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
513 | + } else { |
|
514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
515 | + } |
|
416 | 516 | } elseif ($type == 'marine') { |
417 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
418 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
517 | + if ($name != '') { |
|
518 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
519 | + } else { |
|
520 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
521 | + } |
|
419 | 522 | } |
420 | 523 | $data = $Common->getData($url); |
421 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
524 | + if (substr($data, 0, 5) != "<?xml") { |
|
525 | + return false; |
|
526 | + } |
|
422 | 527 | if ($xml = simplexml_load_string($data)) { |
423 | 528 | if (isset($xml->channel->item)) { |
424 | 529 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -461,13 +566,21 @@ discard block |
||
461 | 566 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
462 | 567 | global $globalImageBingKey; |
463 | 568 | $Common = new Common(); |
464 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
569 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
570 | + return false; |
|
571 | + } |
|
465 | 572 | if ($type == 'aircraft') { |
466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
573 | + if ($aircraft_name != '') { |
|
574 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
575 | + } else { |
|
576 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
577 | + } |
|
468 | 578 | } elseif ($type == 'marine') { |
469 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
470 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
579 | + if ($aircraft_name != '') { |
|
580 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
581 | + } else { |
|
582 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
583 | + } |
|
471 | 584 | } |
472 | 585 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
473 | 586 | $data = $Common->getData($url,'get','',$headers); |
@@ -523,17 +636,25 @@ discard block |
||
523 | 636 | public function fromWikimedia($type,$registration,$name='') { |
524 | 637 | $Common = new Common(); |
525 | 638 | if ($type == 'aircraft') { |
526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
527 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
639 | + if ($name != '') { |
|
640 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
641 | + } else { |
|
642 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
643 | + } |
|
528 | 644 | } elseif ($type == 'marine') { |
529 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
530 | - else return false; |
|
645 | + if ($name != '') { |
|
646 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
647 | + } else { |
|
648 | + return false; |
|
649 | + } |
|
531 | 650 | } |
532 | 651 | $data = $Common->getData($url); |
533 | 652 | $result = json_decode($data); |
534 | 653 | if (isset($result->query->search[0]->title)) { |
535 | 654 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
655 | + if (substr($fileo,-3) == 'pdf') { |
|
656 | + return false; |
|
657 | + } |
|
537 | 658 | $file = urlencode($fileo); |
538 | 659 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 660 | $data2 = $Common->getData($url2); |
@@ -604,18 +725,27 @@ discard block |
||
604 | 725 | $image_url = array(); |
605 | 726 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 727 | $image_url['original'] = $url; |
607 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
608 | - else $exifCopyright = ''; |
|
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
611 | - else $image_url['copyright'] = $source['source_website']; |
|
728 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
729 | + $exifCopyright = $this->getExifCopyright($url); |
|
730 | + } else { |
|
731 | + $exifCopyright = ''; |
|
732 | + } |
|
733 | + if ($exifCopyright != '') { |
|
734 | + $image_url['copyright'] = $exifCopyright; |
|
735 | + } elseif (isset($source['copyright'])) { |
|
736 | + $image_url['copyright'] = $source['copyright']; |
|
737 | + } else { |
|
738 | + $image_url['copyright'] = $source['source_website']; |
|
739 | + } |
|
612 | 740 | $image_url['source_website'] = $source['source_website']; |
613 | 741 | $image_url['source'] = $source['source']; |
614 | 742 | return $image_url; |
615 | 743 | } |
616 | 744 | } |
617 | 745 | return false; |
618 | - } else return false; |
|
746 | + } else { |
|
747 | + return false; |
|
748 | + } |
|
619 | 749 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
620 | 750 | $customsources = array(); |
621 | 751 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -640,18 +770,27 @@ discard block |
||
640 | 770 | $image_url = array(); |
641 | 771 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 772 | $image_url['original'] = $url; |
643 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
644 | - else $exifCopyright = ''; |
|
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
647 | - else $image_url['copyright'] = $source['source_website']; |
|
773 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
774 | + $exifCopyright = $this->getExifCopyright($url); |
|
775 | + } else { |
|
776 | + $exifCopyright = ''; |
|
777 | + } |
|
778 | + if ($exifCopyright != '') { |
|
779 | + $image_url['copyright'] = $exifCopyright; |
|
780 | + } elseif (isset($source['copyright'])) { |
|
781 | + $image_url['copyright'] = $source['copyright']; |
|
782 | + } else { |
|
783 | + $image_url['copyright'] = $source['source_website']; |
|
784 | + } |
|
648 | 785 | $image_url['source_website'] = $source['source_website']; |
649 | 786 | $image_url['source'] = $source['source']; |
650 | 787 | return $image_url; |
651 | 788 | } |
652 | 789 | } |
653 | 790 | return false; |
654 | - } else return false; |
|
791 | + } else { |
|
792 | + return false; |
|
793 | + } |
|
655 | 794 | } |
656 | 795 | } |
657 | 796 |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | public function checkAll() { |
44 | 44 | global $globalDebug; |
45 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
45 | + if ($globalDebug) { |
|
46 | + echo "Update last seen tracked data...\n"; |
|
47 | + } |
|
46 | 48 | foreach ($this->all_tracked as $key => $flight) { |
47 | 49 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -55,12 +57,16 @@ discard block |
||
55 | 57 | public function del() { |
56 | 58 | global $globalDebug; |
57 | 59 | // Delete old infos |
58 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
60 | + if ($globalDebug) { |
|
61 | + echo 'Delete old values and update latest data...'."\n"; |
|
62 | + } |
|
59 | 63 | foreach ($this->all_tracked as $key => $flight) { |
60 | 64 | if (isset($flight['lastupdate'])) { |
61 | 65 | if ($flight['lastupdate'] < (time()-3000)) { |
62 | 66 | if (isset($this->all_tracked[$key]['id'])) { |
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
67 | + if ($globalDebug) { |
|
68 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
69 | + } |
|
64 | 70 | /* |
65 | 71 | $TrackerLive = new TrackerLive(); |
66 | 72 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | $Tracker = new Tracker($this->db); |
71 | 77 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | 78 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
79 | + if ($globalDebug && $result != 'success') { |
|
80 | + echo '!!! ERROR : '.$result."\n"; |
|
81 | + } |
|
74 | 82 | } |
75 | 83 | // Put in archive |
76 | 84 | // $Tracker->db = null; |
@@ -83,7 +91,9 @@ discard block |
||
83 | 91 | |
84 | 92 | public function add($line) { |
85 | 93 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | - if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
|
94 | + if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') { |
|
95 | + $globalCoordMinChangeTracker = '0.015'; |
|
96 | + } |
|
87 | 97 | date_default_timezone_set('UTC'); |
88 | 98 | $dataFound = false; |
89 | 99 | $send = false; |
@@ -97,19 +107,29 @@ discard block |
||
97 | 107 | // Increment message number |
98 | 108 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | 109 | $current_date = date('Y-m-d'); |
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
110 | + if (isset($line['source_name'])) { |
|
111 | + $source = $line['source_name']; |
|
112 | + } else { |
|
113 | + $source = ''; |
|
114 | + } |
|
115 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
116 | + $source = $line['format_source']; |
|
117 | + } |
|
103 | 118 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
104 | 119 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
105 | 120 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
121 | + } else { |
|
122 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
123 | + } |
|
107 | 124 | } |
108 | 125 | |
109 | 126 | |
110 | 127 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
128 | + if (!isset($line['id'])) { |
|
129 | + $id = trim($line['ident']); |
|
130 | + } else { |
|
131 | + $id = trim($line['id']); |
|
132 | + } |
|
113 | 133 | |
114 | 134 | if (!isset($this->all_tracked[$id])) { |
115 | 135 | $this->all_tracked[$id] = array(); |
@@ -117,31 +137,46 @@ discard block |
||
117 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
118 | 138 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
119 | 139 | if (!isset($line['id'])) { |
120 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
140 | + if (!isset($globalDaemon)) { |
|
141 | + $globalDaemon = TRUE; |
|
142 | + } |
|
121 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
144 | + } else { |
|
145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
146 | + } |
|
147 | + if ($globalAllTracked !== FALSE) { |
|
148 | + $dataFound = true; |
|
149 | + } |
|
124 | 150 | } |
125 | 151 | |
126 | 152 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | 153 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | 155 | } else { |
130 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
131 | - 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]['ident']." - format : ".$line['format_source']."\n"; |
|
156 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
157 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
158 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
159 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
|
160 | + } |
|
132 | 161 | return ''; |
133 | 162 | } |
134 | 163 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
166 | + } |
|
136 | 167 | return ''; |
137 | 168 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
138 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
171 | + } |
|
139 | 172 | return ''; |
140 | 173 | } elseif (!isset($line['datetime'])) { |
141 | 174 | date_default_timezone_set('UTC'); |
142 | 175 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
143 | 176 | } else { |
144 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
177 | + if ($globalDebug) { |
|
178 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
|
179 | + } |
|
145 | 180 | return ''; |
146 | 181 | } |
147 | 182 | |
@@ -153,11 +188,17 @@ discard block |
||
153 | 188 | $Tracker = new Tracker($this->db); |
154 | 189 | $fromsource = NULL; |
155 | 190 | $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
156 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
191 | + if ($globalDebug && $result != 'success') { |
|
192 | + echo '!!! ERROR : '.$result."\n"; |
|
193 | + } |
|
157 | 194 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
195 | + if ($globalDebugTimeElapsed) { |
|
196 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
197 | + } |
|
198 | + } |
|
199 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | 201 | } |
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 202 | } |
162 | 203 | |
163 | 204 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -168,14 +209,21 @@ discard block |
||
168 | 209 | if ($distance > 100 && $distance < 10000) { |
169 | 210 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 211 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
172 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
212 | + if ($speed < 1000) { |
|
213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
214 | + } |
|
215 | + if ($globalDebug) { |
|
216 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
|
217 | + } |
|
173 | 218 | } |
174 | 219 | } |
175 | 220 | |
176 | 221 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
222 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
223 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
224 | + } else { |
|
225 | + unset($timediff); |
|
226 | + } |
|
179 | 227 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
180 | 228 | 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'])) { |
181 | 229 | 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'],0.1)) { |
@@ -183,20 +231,30 @@ discard block |
||
183 | 231 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 232 | $this->all_tracked[$id]['putinarchive'] = true; |
185 | 233 | |
186 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
234 | + if ($globalDebug) { |
|
235 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
236 | + } |
|
187 | 237 | $timeelapsed = microtime(true); |
188 | 238 | $Tracker = new Tracker($this->db); |
189 | 239 | $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
190 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
240 | + if (!empty($all_country)) { |
|
241 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
242 | + } |
|
191 | 243 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
244 | + if ($globalDebugTimeElapsed) { |
|
245 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
246 | + } |
|
193 | 247 | $this->tmd = 0; |
194 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
250 | + } |
|
195 | 251 | } |
196 | 252 | } |
197 | 253 | |
198 | 254 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
255 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
256 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
257 | + } |
|
200 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | 259 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 260 | $dataFound = true; |
@@ -205,8 +263,12 @@ discard block |
||
205 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 264 | } |
207 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
266 | + if ($line['longitude'] > 180) { |
|
267 | + $line['longitude'] = $line['longitude'] - 360; |
|
268 | + } |
|
269 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
270 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
271 | + } |
|
210 | 272 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | 273 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 274 | $dataFound = true; |
@@ -226,7 +288,9 @@ discard block |
||
226 | 288 | } |
227 | 289 | } |
228 | 290 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
291 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
292 | + $dataFound = true; |
|
293 | + } |
|
230 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
231 | 295 | } |
232 | 296 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -246,7 +310,9 @@ discard block |
||
246 | 310 | |
247 | 311 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 312 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
313 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) { |
|
314 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
315 | + } |
|
250 | 316 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 317 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 318 | //$dataFound = true; |
@@ -258,15 +324,21 @@ discard block |
||
258 | 324 | } |
259 | 325 | |
260 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
329 | + } |
|
262 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
263 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
264 | 332 | //$dataFound = true; |
265 | 333 | } 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']) { |
266 | 334 | $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']); |
267 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
341 | + } |
|
270 | 342 | } |
271 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 344 | |
@@ -275,20 +347,31 @@ discard block |
||
275 | 347 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | 348 | 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'])) { |
277 | 349 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
350 | + if ($globalDebug) { |
|
351 | + echo "Check if aircraft is already in DB..."; |
|
352 | + } |
|
279 | 353 | $timeelapsed = microtime(true); |
280 | 354 | $TrackerLive = new TrackerLive($this->db); |
281 | 355 | if (isset($line['id'])) { |
282 | 356 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
357 | + if ($globalDebugTimeElapsed) { |
|
358 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
359 | + } |
|
284 | 360 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 361 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | - } else $recent_ident = ''; |
|
362 | + if ($globalDebugTimeElapsed) { |
|
363 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
364 | + } |
|
365 | + } else { |
|
366 | + $recent_ident = ''; |
|
367 | + } |
|
288 | 368 | $TrackerLive->db=null; |
289 | 369 | |
290 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
291 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
370 | + if ($globalDebug && $recent_ident == '') { |
|
371 | + echo " Not in DB.\n"; |
|
372 | + } elseif ($globalDebug && $recent_ident != '') { |
|
373 | + echo " Already in DB.\n"; |
|
374 | + } |
|
292 | 375 | } else { |
293 | 376 | $recent_ident = ''; |
294 | 377 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -296,27 +379,41 @@ discard block |
||
296 | 379 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | 380 | if($recent_ident == "") |
298 | 381 | { |
299 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
382 | + if ($globalDebug) { |
|
383 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
384 | + } |
|
300 | 385 | //adds the spotter data for the archive |
301 | 386 | $highlight = ''; |
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
387 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
388 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
389 | + } |
|
303 | 390 | $timeelapsed = microtime(true); |
304 | 391 | $Tracker = new Tracker($this->db); |
305 | 392 | $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
306 | 393 | $Tracker->db = null; |
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
394 | + if ($globalDebug && isset($result)) { |
|
395 | + echo $result."\n"; |
|
396 | + } |
|
397 | + if ($globalDebugTimeElapsed) { |
|
398 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
399 | + } |
|
309 | 400 | |
310 | 401 | |
311 | 402 | // Add source stat in DB |
312 | 403 | $Stats = new Stats($this->db); |
313 | 404 | if (!empty($this->stats)) { |
314 | - if ($globalDebug) echo 'Add source stats : '; |
|
405 | + if ($globalDebug) { |
|
406 | + echo 'Add source stats : '; |
|
407 | + } |
|
315 | 408 | foreach($this->stats as $date => $data) { |
316 | 409 | foreach($data as $source => $sourced) { |
317 | 410 | //print_r($sourced); |
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
411 | + if (isset($sourced['polar'])) { |
|
412 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
413 | + } |
|
414 | + if (isset($sourced['hist'])) { |
|
415 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
416 | + } |
|
320 | 417 | if (isset($sourced['msg'])) { |
321 | 418 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 419 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -329,7 +426,9 @@ discard block |
||
329 | 426 | unset($this->stats[$date]); |
330 | 427 | } |
331 | 428 | } |
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
429 | + if ($globalDebug) { |
|
430 | + echo 'Done'."\n"; |
|
431 | + } |
|
333 | 432 | |
334 | 433 | } |
335 | 434 | $Stats->db = null; |
@@ -339,12 +438,16 @@ discard block |
||
339 | 438 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 439 | //print_r($this->all_tracked[$id]); |
341 | 440 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
441 | + if ($globalDebug) { |
|
442 | + echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
443 | + } |
|
343 | 444 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 445 | $TrackerLive = new TrackerLive($this->db); |
345 | 446 | $TrackerLive->deleteLiveTrackerData(); |
346 | 447 | $TrackerLive->db=null; |
347 | - if ($globalDebug) echo " Done\n"; |
|
448 | + if ($globalDebug) { |
|
449 | + echo " Done\n"; |
|
450 | + } |
|
348 | 451 | $this->last_delete = time(); |
349 | 452 | } |
350 | 453 | } else { |
@@ -367,19 +470,25 @@ discard block |
||
367 | 470 | |
368 | 471 | if (!$ignoreImport) { |
369 | 472 | 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'])) { |
370 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
473 | + if ($globalDebug) { |
|
474 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
475 | + } |
|
371 | 476 | $timeelapsed = microtime(true); |
372 | 477 | $TrackerLive = new TrackerLive($this->db); |
373 | 478 | $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
374 | 479 | $TrackerLive->db = null; |
375 | 480 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
481 | + if ($globalDebugTimeElapsed) { |
|
482 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
483 | + } |
|
377 | 484 | |
378 | 485 | // Put statistics in $this->stats variable |
379 | 486 | |
380 | 487 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
381 | 488 | $source = $this->all_tracked[$id]['source_name']; |
382 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
489 | + if ($source == '') { |
|
490 | + $source = $this->all_tracked[$id]['format_source']; |
|
491 | + } |
|
383 | 492 | if (!isset($this->source_location[$source])) { |
384 | 493 | $Location = new Source($this->db); |
385 | 494 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -400,7 +509,9 @@ discard block |
||
400 | 509 | $stats_heading = round($stats_heading/22.5); |
401 | 510 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
402 | 511 | $current_date = date('Y-m-d'); |
403 | - if ($stats_heading == 16) $stats_heading = 0; |
|
512 | + if ($stats_heading == 16) { |
|
513 | + $stats_heading = 0; |
|
514 | + } |
|
404 | 515 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 516 | for ($i=0;$i<=15;$i++) { |
406 | 517 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -418,7 +529,9 @@ discard block |
||
418 | 529 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 530 | end($this->stats[$current_date][$source]['hist']); |
420 | 531 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
421 | - } else $mini = 0; |
|
532 | + } else { |
|
533 | + $mini = 0; |
|
534 | + } |
|
422 | 535 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | 536 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 537 | } |
@@ -429,19 +542,29 @@ discard block |
||
429 | 542 | } |
430 | 543 | |
431 | 544 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
433 | - if ($globalDebug) echo $result."\n"; |
|
434 | - } 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"; |
|
545 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
546 | + $send = true; |
|
547 | + } |
|
548 | + if ($globalDebug) { |
|
549 | + echo $result."\n"; |
|
550 | + } |
|
551 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
552 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
553 | + } |
|
435 | 554 | //$this->del(); |
436 | 555 | |
437 | 556 | |
438 | 557 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
558 | + if ($globalDebug) { |
|
559 | + echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
560 | + } |
|
440 | 561 | $TrackerLive = new TrackerLive($this->db); |
441 | 562 | $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
442 | 563 | $TrackerLive->db = null; |
443 | 564 | //TrackerLive->deleteLiveTrackerData(); |
444 | - if ($globalDebug) echo " Done\n"; |
|
565 | + if ($globalDebug) { |
|
566 | + echo " Done\n"; |
|
567 | + } |
|
445 | 568 | $this->last_delete_hourly = time(); |
446 | 569 | } |
447 | 570 | |
@@ -449,7 +572,9 @@ discard block |
||
449 | 572 | //$ignoreImport = false; |
450 | 573 | } |
451 | 574 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | - if ($send) return $this->all_tracked[$id]; |
|
575 | + if ($send) { |
|
576 | + return $this->all_tracked[$id]; |
|
577 | + } |
|
453 | 578 | } |
454 | 579 | } |
455 | 580 | } |
@@ -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.'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection.'); |
|
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) { |
@@ -69,8 +73,11 @@ discard block |
||
69 | 73 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
70 | 74 | } |
71 | 75 | } |
72 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
73 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
76 | + if ($filter_query_where == '' && $where) { |
|
77 | + $filter_query_where = ' WHERE'; |
|
78 | + } elseif ($filter_query_where != '' && $and) { |
|
79 | + $filter_query_where .= ' AND'; |
|
80 | + } |
|
74 | 81 | if ($filter_query_where != '') { |
75 | 82 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
76 | 83 | } |
@@ -124,32 +131,54 @@ discard block |
||
124 | 131 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
125 | 132 | } elseif (isset($row['spotter_archive_output_id'])) { |
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
127 | - */} |
|
128 | - elseif (isset($row['marineid'])) { |
|
134 | + */} elseif (isset($row['marineid'])) { |
|
129 | 135 | $temp_array['marine_id'] = $row['marineid']; |
130 | 136 | } else { |
131 | 137 | $temp_array['marine_id'] = ''; |
132 | 138 | } |
133 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
134 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
136 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
137 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
139 | + if (isset($row['fammarine_id'])) { |
|
140 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
141 | + } |
|
142 | + if (isset($row['mmsi'])) { |
|
143 | + $temp_array['mmsi'] = $row['mmsi']; |
|
144 | + } |
|
145 | + if (isset($row['type'])) { |
|
146 | + $temp_array['type'] = $row['type']; |
|
147 | + } |
|
148 | + if (isset($row['type_id'])) { |
|
149 | + $temp_array['type_id'] = $row['type_id']; |
|
150 | + } |
|
151 | + if (isset($row['ident'])) { |
|
152 | + $temp_array['ident'] = $row['ident']; |
|
153 | + } |
|
154 | + if (isset($row['latitude'])) { |
|
155 | + $temp_array['latitude'] = $row['latitude']; |
|
156 | + } |
|
157 | + if (isset($row['longitude'])) { |
|
158 | + $temp_array['longitude'] = $row['longitude']; |
|
159 | + } |
|
160 | + if (isset($row['format_source'])) { |
|
161 | + $temp_array['format_source'] = $row['format_source']; |
|
162 | + } |
|
141 | 163 | if (isset($row['heading'])) { |
142 | 164 | $temp_array['heading'] = $row['heading']; |
143 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
145 | 172 | } |
146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 173 | |
148 | 174 | if($temp_array['mmsi'] != "") |
149 | 175 | { |
150 | 176 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
152 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
177 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
178 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
179 | + } else { |
|
180 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
181 | + } |
|
153 | 182 | unset($Image); |
154 | 183 | if (count($image_array) > 0) { |
155 | 184 | $temp_array['image'] = $image_array[0]['image']; |
@@ -201,13 +230,21 @@ discard block |
||
201 | 230 | } |
202 | 231 | |
203 | 232 | $fromsource = NULL; |
204 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
205 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
206 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
233 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
234 | + $temp_array['source_name'] = $row['source_name']; |
|
235 | + } |
|
236 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
237 | + $temp_array['over_country'] = $row['over_country']; |
|
238 | + } |
|
239 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
240 | + $temp_array['distance'] = $row['distance']; |
|
241 | + } |
|
207 | 242 | $temp_array['query_number_rows'] = $num_rows; |
208 | 243 | $spotter_array[] = $temp_array; |
209 | 244 | } |
210 | - if ($num_rows == 0) return array(); |
|
245 | + if ($num_rows == 0) { |
|
246 | + return array(); |
|
247 | + } |
|
211 | 248 | $spotter_array[0]['query_number_rows'] = $num_rows; |
212 | 249 | return $spotter_array; |
213 | 250 | } |
@@ -233,8 +270,12 @@ discard block |
||
233 | 270 | { |
234 | 271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
235 | 272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
236 | - } else $limit_query = ""; |
|
237 | - } else $limit_query = ""; |
|
273 | + } else { |
|
274 | + $limit_query = ""; |
|
275 | + } |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
238 | 279 | if ($sort != "") |
239 | 280 | { |
240 | 281 | $search_orderby_array = $this->getOrderBy(); |
@@ -258,7 +299,9 @@ discard block |
||
258 | 299 | global $global_query; |
259 | 300 | |
260 | 301 | date_default_timezone_set('UTC'); |
261 | - if ($id == '') return array(); |
|
302 | + if ($id == '') { |
|
303 | + return array(); |
|
304 | + } |
|
262 | 305 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 306 | $query_values = array(':id' => $id); |
264 | 307 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -401,8 +444,11 @@ discard block |
||
401 | 444 | $query .= " ORDER BY marine_output.source_name ASC"; |
402 | 445 | |
403 | 446 | $sth = $this->db->prepare($query); |
404 | - if (!empty($query_values)) $sth->execute($query_values); |
|
405 | - else $sth->execute(); |
|
447 | + if (!empty($query_values)) { |
|
448 | + $sth->execute($query_values); |
|
449 | + } else { |
|
450 | + $sth->execute(); |
|
451 | + } |
|
406 | 452 | |
407 | 453 | $source_array = array(); |
408 | 454 | $temp_array = array(); |
@@ -457,8 +503,11 @@ discard block |
||
457 | 503 | $sth = $this->db->prepare($query); |
458 | 504 | $sth->execute(array(':mmsi' => $mmsi)); |
459 | 505 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - if (isset($result[0])) return $result[0]; |
|
461 | - else return array(); |
|
506 | + if (isset($result[0])) { |
|
507 | + return $result[0]; |
|
508 | + } else { |
|
509 | + return array(); |
|
510 | + } |
|
462 | 511 | } |
463 | 512 | |
464 | 513 | /* |
@@ -474,7 +523,9 @@ discard block |
||
474 | 523 | date_default_timezone_set($globalTimezone); |
475 | 524 | $datetime = new DateTime(); |
476 | 525 | $offset = $datetime->format('P'); |
477 | - } else $offset = '+00:00'; |
|
526 | + } else { |
|
527 | + $offset = '+00:00'; |
|
528 | + } |
|
478 | 529 | |
479 | 530 | if ($globalDBdriver == 'mysql') { |
480 | 531 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -704,9 +755,15 @@ discard block |
||
704 | 755 | $latitude = 0; |
705 | 756 | $longitude = 0; |
706 | 757 | } |
707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
758 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
759 | + $heading = 0; |
|
760 | + } |
|
761 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
762 | + $groundspeed = 0; |
|
763 | + } |
|
764 | + if ($arrival_date == '') { |
|
765 | + $arrival_date = NULL; |
|
766 | + } |
|
710 | 767 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
711 | 768 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 769 | |
@@ -814,7 +871,9 @@ discard block |
||
814 | 871 | global $globalDBdriver, $globalArchive; |
815 | 872 | //$filter_query = $this->getFilter($filters,true,true); |
816 | 873 | $Connection= new Connection($this->db); |
817 | - if (!$Connection->tableExists('countries')) return array(); |
|
874 | + if (!$Connection->tableExists('countries')) { |
|
875 | + return array(); |
|
876 | + } |
|
818 | 877 | require_once('class.SpotterLive.php'); |
819 | 878 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 879 | $MarineLive = new MarineLive($this->db); |
@@ -858,7 +917,9 @@ discard block |
||
858 | 917 | $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 "; |
859 | 918 | } |
860 | 919 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
861 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
920 | + if ($limit) { |
|
921 | + $query .= " LIMIT 10 OFFSET 0"; |
|
922 | + } |
|
862 | 923 | |
863 | 924 | $sth = $this->db->prepare($query); |
864 | 925 | $sth->execute(); |
@@ -892,12 +953,18 @@ discard block |
||
892 | 953 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
893 | 954 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 955 | if ($olderthanmonths > 0) { |
895 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
896 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
956 | + if ($globalDBdriver == 'mysql') { |
|
957 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
958 | + } else { |
|
959 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
960 | + } |
|
897 | 961 | } |
898 | 962 | if ($sincedate != '') { |
899 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
900 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
963 | + if ($globalDBdriver == 'mysql') { |
|
964 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
965 | + } else { |
|
966 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
967 | + } |
|
901 | 968 | } |
902 | 969 | $query_values = array(); |
903 | 970 | if ($year != '') { |
@@ -928,7 +995,9 @@ discard block |
||
928 | 995 | } |
929 | 996 | } |
930 | 997 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
931 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
998 | + if ($limit) { |
|
999 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1000 | + } |
|
932 | 1001 | |
933 | 1002 | $sth = $this->db->prepare($query); |
934 | 1003 | $sth->execute($query_values); |
@@ -963,7 +1032,9 @@ discard block |
||
963 | 1032 | date_default_timezone_set($globalTimezone); |
964 | 1033 | $datetime = new DateTime(); |
965 | 1034 | $offset = $datetime->format('P'); |
966 | - } else $offset = '+00:00'; |
|
1035 | + } else { |
|
1036 | + $offset = '+00:00'; |
|
1037 | + } |
|
967 | 1038 | |
968 | 1039 | if ($globalDBdriver == 'mysql') { |
969 | 1040 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1084,9 @@ discard block |
||
1013 | 1084 | date_default_timezone_set($globalTimezone); |
1014 | 1085 | $datetime = new DateTime(); |
1015 | 1086 | $offset = $datetime->format('P'); |
1016 | - } else $offset = '+00:00'; |
|
1087 | + } else { |
|
1088 | + $offset = '+00:00'; |
|
1089 | + } |
|
1017 | 1090 | $filter_query = $this->getFilter($filters,true,true); |
1018 | 1091 | if ($globalDBdriver == 'mysql') { |
1019 | 1092 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1059,7 +1132,9 @@ discard block |
||
1059 | 1132 | date_default_timezone_set($globalTimezone); |
1060 | 1133 | $datetime = new DateTime(); |
1061 | 1134 | $offset = $datetime->format('P'); |
1062 | - } else $offset = '+00:00'; |
|
1135 | + } else { |
|
1136 | + $offset = '+00:00'; |
|
1137 | + } |
|
1063 | 1138 | $filter_query = $this->getFilter($filters,true,true); |
1064 | 1139 | if ($globalDBdriver == 'mysql') { |
1065 | 1140 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1107,7 +1182,9 @@ discard block |
||
1107 | 1182 | date_default_timezone_set($globalTimezone); |
1108 | 1183 | $datetime = new DateTime(); |
1109 | 1184 | $offset = $datetime->format('P'); |
1110 | - } else $offset = '+00:00'; |
|
1185 | + } else { |
|
1186 | + $offset = '+00:00'; |
|
1187 | + } |
|
1111 | 1188 | |
1112 | 1189 | if ($globalDBdriver == 'mysql') { |
1113 | 1190 | $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 |
@@ -1156,7 +1233,9 @@ discard block |
||
1156 | 1233 | date_default_timezone_set($globalTimezone); |
1157 | 1234 | $datetime = new DateTime(); |
1158 | 1235 | $offset = $datetime->format('P'); |
1159 | - } else $offset = '+00:00'; |
|
1236 | + } else { |
|
1237 | + $offset = '+00:00'; |
|
1238 | + } |
|
1160 | 1239 | $filter_query = $this->getFilter($filters,true,true); |
1161 | 1240 | if ($globalDBdriver == 'mysql') { |
1162 | 1241 | $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 |
@@ -1205,7 +1284,9 @@ discard block |
||
1205 | 1284 | date_default_timezone_set($globalTimezone); |
1206 | 1285 | $datetime = new DateTime(); |
1207 | 1286 | $offset = $datetime->format('P'); |
1208 | - } else $offset = '+00:00'; |
|
1287 | + } else { |
|
1288 | + $offset = '+00:00'; |
|
1289 | + } |
|
1209 | 1290 | |
1210 | 1291 | $orderby_sql = ''; |
1211 | 1292 | if ($orderby == "hour") |
@@ -1274,7 +1355,9 @@ discard block |
||
1274 | 1355 | date_default_timezone_set($globalTimezone); |
1275 | 1356 | $datetime = new DateTime($date); |
1276 | 1357 | $offset = $datetime->format('P'); |
1277 | - } else $offset = '+00:00'; |
|
1358 | + } else { |
|
1359 | + $offset = '+00:00'; |
|
1360 | + } |
|
1278 | 1361 | |
1279 | 1362 | if ($globalDBdriver == 'mysql') { |
1280 | 1363 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1322,7 +1405,9 @@ discard block |
||
1322 | 1405 | date_default_timezone_set($globalTimezone); |
1323 | 1406 | $datetime = new DateTime(); |
1324 | 1407 | $offset = $datetime->format('P'); |
1325 | - } else $offset = '+00:00'; |
|
1408 | + } else { |
|
1409 | + $offset = '+00:00'; |
|
1410 | + } |
|
1326 | 1411 | |
1327 | 1412 | if ($globalDBdriver == 'mysql') { |
1328 | 1413 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1387,8 +1472,11 @@ discard block |
||
1387 | 1472 | $query_values = array_merge($query_values,array(':month' => $month)); |
1388 | 1473 | } |
1389 | 1474 | } |
1390 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1475 | + if (empty($query_values)) { |
|
1476 | + $queryi .= $this->getFilter($filters); |
|
1477 | + } else { |
|
1478 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1479 | + } |
|
1392 | 1480 | |
1393 | 1481 | $sth = $this->db->prepare($queryi); |
1394 | 1482 | $sth->execute($query_values); |
@@ -1425,8 +1513,11 @@ discard block |
||
1425 | 1513 | $query_values = array_merge($query_values,array(':month' => $month)); |
1426 | 1514 | } |
1427 | 1515 | } |
1428 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1516 | + if (empty($query_values)) { |
|
1517 | + $queryi .= $this->getFilter($filters); |
|
1518 | + } else { |
|
1519 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1520 | + } |
|
1430 | 1521 | |
1431 | 1522 | $sth = $this->db->prepare($queryi); |
1432 | 1523 | $sth->execute($query_values); |
@@ -1448,7 +1539,9 @@ discard block |
||
1448 | 1539 | date_default_timezone_set($globalTimezone); |
1449 | 1540 | $datetime = new DateTime(); |
1450 | 1541 | $offset = $datetime->format('P'); |
1451 | - } else $offset = '+00:00'; |
|
1542 | + } else { |
|
1543 | + $offset = '+00:00'; |
|
1544 | + } |
|
1452 | 1545 | |
1453 | 1546 | if ($globalDBdriver == 'mysql') { |
1454 | 1547 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1552,7 +1645,9 @@ discard block |
||
1552 | 1645 | */ |
1553 | 1646 | public function parseDirection($direction = 0) |
1554 | 1647 | { |
1555 | - if ($direction == '') $direction = 0; |
|
1648 | + if ($direction == '') { |
|
1649 | + $direction = 0; |
|
1650 | + } |
|
1556 | 1651 | $direction_array = array(); |
1557 | 1652 | $temp_array = array(); |
1558 | 1653 | |
@@ -1641,7 +1736,9 @@ discard block |
||
1641 | 1736 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1642 | 1737 | |
1643 | 1738 | $Connection = new Connection($this->db); |
1644 | - if (!$Connection->tableExists('countries')) return ''; |
|
1739 | + if (!$Connection->tableExists('countries')) { |
|
1740 | + return ''; |
|
1741 | + } |
|
1645 | 1742 | |
1646 | 1743 | try { |
1647 | 1744 | /* |
@@ -1661,9 +1758,13 @@ discard block |
||
1661 | 1758 | $sth->closeCursor(); |
1662 | 1759 | if (count($row) > 0) { |
1663 | 1760 | return $row; |
1664 | - } else return ''; |
|
1761 | + } else { |
|
1762 | + return ''; |
|
1763 | + } |
|
1665 | 1764 | } catch (PDOException $e) { |
1666 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1765 | + if (isset($globalDebug) && $globalDebug) { |
|
1766 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1767 | + } |
|
1667 | 1768 | return ''; |
1668 | 1769 | } |
1669 | 1770 | |
@@ -1681,7 +1782,9 @@ discard block |
||
1681 | 1782 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1682 | 1783 | |
1683 | 1784 | $Connection = new Connection($this->db); |
1684 | - if (!$Connection->tableExists('countries')) return ''; |
|
1785 | + if (!$Connection->tableExists('countries')) { |
|
1786 | + return ''; |
|
1787 | + } |
|
1685 | 1788 | |
1686 | 1789 | try { |
1687 | 1790 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1693,9 +1796,13 @@ discard block |
||
1693 | 1796 | $sth->closeCursor(); |
1694 | 1797 | if (count($row) > 0) { |
1695 | 1798 | return $row; |
1696 | - } else return ''; |
|
1799 | + } else { |
|
1800 | + return ''; |
|
1801 | + } |
|
1697 | 1802 | } catch (PDOException $e) { |
1698 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1803 | + if (isset($globalDebug) && $globalDebug) { |
|
1804 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1805 | + } |
|
1699 | 1806 | return ''; |
1700 | 1807 | } |
1701 | 1808 | |
@@ -1713,7 +1820,9 @@ discard block |
||
1713 | 1820 | { |
1714 | 1821 | global $globalBitlyAccessToken; |
1715 | 1822 | |
1716 | - if ($globalBitlyAccessToken == '') return $url; |
|
1823 | + if ($globalBitlyAccessToken == '') { |
|
1824 | + return $url; |
|
1825 | + } |
|
1717 | 1826 | |
1718 | 1827 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1719 | 1828 | |
@@ -1789,7 +1898,9 @@ discard block |
||
1789 | 1898 | } |
1790 | 1899 | } |
1791 | 1900 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1792 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1901 | + if ($limit) { |
|
1902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1903 | + } |
|
1793 | 1904 | $sth = $this->db->prepare($query); |
1794 | 1905 | $sth->execute($query_values); |
1795 | 1906 | $marine_array = array(); |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection.'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection.'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | public function get() { |
@@ -109,8 +111,11 @@ discard block |
||
109 | 111 | $data = array(); |
110 | 112 | if ($row['registration'] != '') { |
111 | 113 | $image_array = $Image->getSpotterImage($row['registration']); |
112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
114 | + if (count($image_array) > 0) { |
|
115 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
116 | + } else { |
|
117 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
118 | + } |
|
114 | 119 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
115 | 120 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
116 | 121 | if (!empty($aircraft_info)) { |
@@ -126,17 +131,30 @@ discard block |
||
126 | 131 | $data['aircraft_base'] = $owner_data['base']; |
127 | 132 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
128 | 133 | } |
129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
130 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
131 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
134 | + } else { |
|
135 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
136 | + } |
|
137 | + if ($row['registration'] == '') { |
|
138 | + $row['registration'] = 'NA'; |
|
139 | + } |
|
140 | + if ($row['ident'] == '') { |
|
141 | + $row['ident'] = 'NA'; |
|
142 | + } |
|
132 | 143 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
133 | 144 | if (isset($identicao[0])) { |
134 | 145 | if (substr($row['ident'],0,2) == 'AF') { |
135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
146 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
147 | + $icao = $row['ident']; |
|
148 | + } else { |
|
149 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
150 | + } |
|
151 | + } else { |
|
152 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
153 | + } |
|
138 | 154 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
139 | - } else $icao = $row['ident']; |
|
155 | + } else { |
|
156 | + $icao = $row['ident']; |
|
157 | + } |
|
140 | 158 | $icao = $Translation->checkTranslation($icao,false); |
141 | 159 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
142 | 160 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -151,10 +169,14 @@ discard block |
||
151 | 169 | //else echo 'No data...'."\n"; |
152 | 170 | } |
153 | 171 | $data = array_merge($row,$data); |
154 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
172 | + if ($data['ident'] == null) { |
|
173 | + $data['ident'] = $icao; |
|
174 | + } |
|
155 | 175 | if ($data['title'] == null) { |
156 | 176 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
157 | - } else $data['message'] = strtolower($data['title']); |
|
177 | + } else { |
|
178 | + $data['message'] = strtolower($data['title']); |
|
179 | + } |
|
158 | 180 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
159 | 181 | $date = $data['date']; |
160 | 182 | if (isset($ids[$date])) { |
@@ -173,8 +195,9 @@ discard block |
||
173 | 195 | if (isset($result)) { |
174 | 196 | $result[0]['query_number_rows'] = $i; |
175 | 197 | return $result; |
198 | + } else { |
|
199 | + return array(); |
|
176 | 200 | } |
177 | - else return array(); |
|
178 | 201 | } |
179 | 202 | |
180 | 203 | /* |
@@ -219,7 +242,9 @@ discard block |
||
219 | 242 | */ |
220 | 243 | public function import($file) { |
221 | 244 | global $globalTransaction, $globalDebug; |
222 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo 'Import '.$file."\n"; |
|
247 | + } |
|
223 | 248 | $result = array(); |
224 | 249 | if (file_exists($file)) { |
225 | 250 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -230,8 +255,11 @@ discard block |
||
230 | 255 | } |
231 | 256 | fclose($handle); |
232 | 257 | } |
233 | - if (!empty($result)) $this->add($result,true); |
|
234 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
258 | + if (!empty($result)) { |
|
259 | + $this->add($result,true); |
|
260 | + } elseif ($globalDebug) { |
|
261 | + echo 'Nothing to import'; |
|
262 | + } |
|
235 | 263 | } |
236 | 264 | } |
237 | 265 | |
@@ -267,14 +295,23 @@ discard block |
||
267 | 295 | } |
268 | 296 | } |
269 | 297 | fclose($handle); |
270 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
271 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
298 | + } elseif ($globalDebug) { |
|
299 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
300 | + } |
|
301 | + } elseif ($globalDebug) { |
|
302 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
303 | + } |
|
272 | 304 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
273 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
305 | + if (empty($result) && $globalDebug) { |
|
306 | + echo 'Nothing to update'; |
|
307 | + } |
|
274 | 308 | foreach ($result as $file => $md5) { |
275 | 309 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
276 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
277 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
310 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
311 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
312 | + } elseif ($globalDebug) { |
|
313 | + echo 'Download '.$file.' failed'; |
|
314 | + } |
|
278 | 315 | } |
279 | 316 | } |
280 | 317 | |
@@ -291,13 +328,17 @@ discard block |
||
291 | 328 | $Image = new Image($this->db); |
292 | 329 | $Spotter = new Spotter($this->db); |
293 | 330 | |
294 | - if (empty($crash)) return false; |
|
331 | + if (empty($crash)) { |
|
332 | + return false; |
|
333 | + } |
|
295 | 334 | if (!$new) { |
296 | 335 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
297 | 336 | $sthd = $Connection->db->prepare($query_delete); |
298 | 337 | $sthd->execute(array(':source' => $crash[0]['source'])); |
299 | 338 | } |
300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
339 | + if ($globalTransaction) { |
|
340 | + $Connection->db->beginTransaction(); |
|
341 | + } |
|
301 | 342 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
302 | 343 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
303 | 344 | $sth_check = $Connection->db->prepare($query_check); |
@@ -312,7 +353,9 @@ discard block |
||
312 | 353 | return $value === "" ? NULL : $value; |
313 | 354 | }, $cr); |
314 | 355 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
356 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
357 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
358 | + } |
|
316 | 359 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
317 | 360 | $sth_check->execute($query_check_values); |
318 | 361 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -321,13 +364,19 @@ discard block |
||
321 | 364 | $sth->execute($query_values); |
322 | 365 | if ($cr['date'] > time()-(30*86400)) { |
323 | 366 | if (empty($Image->getSpotterImage($cr['registration']))) { |
324 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
367 | + if ($globalDebug) { |
|
368 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
369 | + } |
|
325 | 370 | $Image->addSpotterImage($cr['registration']); |
326 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
371 | + if ($globalDebug) { |
|
372 | + echo "\t".'Done'."\n"; |
|
373 | + } |
|
327 | 374 | } |
328 | 375 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
329 | 376 | } |
330 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
377 | + if ($cr['title'] == '') { |
|
378 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
379 | + } |
|
331 | 380 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
332 | 381 | } |
333 | 382 | } |
@@ -336,9 +385,13 @@ discard block |
||
336 | 385 | $Connection->db->beginTransaction(); |
337 | 386 | } |
338 | 387 | } |
339 | - if ($globalTransaction) $Connection->db->commit(); |
|
388 | + if ($globalTransaction) { |
|
389 | + $Connection->db->commit(); |
|
390 | + } |
|
340 | 391 | } catch(PDOException $e) { |
341 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
392 | + if ($globalTransaction) { |
|
393 | + $Connection->db->rollBack(); |
|
394 | + } |
|
342 | 395 | echo $e->getMessage(); |
343 | 396 | } |
344 | 397 | $sth_check->closeCursor(); |
@@ -377,8 +430,11 @@ discard block |
||
377 | 430 | return "error : ".$e->getMessage(); |
378 | 431 | } |
379 | 432 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
380 | - if ($row['nb'] > 0) return false; |
|
381 | - else return true; |
|
433 | + if ($row['nb'] > 0) { |
|
434 | + return false; |
|
435 | + } else { |
|
436 | + return true; |
|
437 | + } |
|
382 | 438 | } |
383 | 439 | |
384 | 440 | public static function insert_last_accidents_update() { |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug; |
56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo "Update last seen tracked data...\n"; |
|
58 | + } |
|
57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
66 | 68 | public function del() { |
67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 70 | // Delete old infos |
69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
71 | + if ($globalDebug) { |
|
72 | + echo 'Delete old values and update latest data...'."\n"; |
|
73 | + } |
|
70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
71 | 75 | if (isset($flight['lastupdate'])) { |
72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + } |
|
76 | 82 | /* |
77 | 83 | $MarineLive = new MarineLive(); |
78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
82 | 88 | $Marine = new Marine($this->db); |
83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
84 | 90 | $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']); |
85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
91 | + if ($globalDebug && $result != 'success') { |
|
92 | + echo '!!! ERROR : '.$result."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | // Put in archive |
88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
96 | 104 | |
97 | 105 | public function add($line) { |
98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
108 | + $globalCoordMinChange = '0.02'; |
|
109 | + } |
|
100 | 110 | date_default_timezone_set('UTC'); |
101 | 111 | $dataFound = false; |
102 | 112 | $send = false; |
@@ -110,20 +120,30 @@ discard block |
||
110 | 120 | // Increment message number |
111 | 121 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
112 | 122 | $current_date = date('Y-m-d'); |
113 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
114 | - else $source = ''; |
|
115 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
123 | + if (isset($line['source_name'])) { |
|
124 | + $source = $line['source_name']; |
|
125 | + } else { |
|
126 | + $source = ''; |
|
127 | + } |
|
128 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
129 | + $source = $line['format_source']; |
|
130 | + } |
|
116 | 131 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
117 | 132 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
118 | 133 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
119 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
134 | + } else { |
|
135 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } |
|
120 | 137 | } |
121 | 138 | |
122 | 139 | |
123 | 140 | $Common = new Common(); |
124 | 141 | $AIS = new AIS(); |
125 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
126 | - else $id = trim($line['id']); |
|
142 | + if (!isset($line['id'])) { |
|
143 | + $id = trim($line['mmsi']); |
|
144 | + } else { |
|
145 | + $id = trim($line['id']); |
|
146 | + } |
|
127 | 147 | |
128 | 148 | if (!isset($this->all_tracked[$id])) { |
129 | 149 | $this->all_tracked[$id] = array(); |
@@ -131,10 +151,16 @@ discard block |
||
131 | 151 | $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' => '')); |
132 | 152 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
133 | 153 | if (!isset($line['id'])) { |
134 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
154 | + if (!isset($globalDaemon)) { |
|
155 | + $globalDaemon = TRUE; |
|
156 | + } |
|
135 | 157 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
136 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
158 | + } else { |
|
159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
160 | + } |
|
161 | + if ($globalAllTracked !== FALSE) { |
|
162 | + $dataFound = true; |
|
163 | + } |
|
138 | 164 | } |
139 | 165 | |
140 | 166 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -184,34 +210,49 @@ discard block |
||
184 | 210 | $Marine = new Marine($this->db); |
185 | 211 | $fromsource = NULL; |
186 | 212 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
213 | + if ($globalDebug && $result != 'success') { |
|
214 | + echo '!!! ERROR : '.$result."\n"; |
|
215 | + } |
|
188 | 216 | $Marine->db = null; |
189 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
217 | + if ($globalDebugTimeElapsed) { |
|
218 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
219 | + } |
|
190 | 220 | } |
191 | 221 | } |
192 | 222 | } |
193 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
223 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
225 | + } |
|
194 | 226 | } |
195 | 227 | |
196 | 228 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
197 | 229 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
198 | 230 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
199 | 231 | } else { |
200 | - 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"; |
|
201 | - 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"; |
|
232 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
233 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
234 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
235 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
236 | + } |
|
202 | 237 | return ''; |
203 | 238 | } |
204 | 239 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
205 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
240 | + if ($globalDebug) { |
|
241 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
242 | + } |
|
206 | 243 | return ''; |
207 | 244 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
208 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
247 | + } |
|
209 | 248 | return ''; |
210 | 249 | } elseif (!isset($line['datetime'])) { |
211 | 250 | date_default_timezone_set('UTC'); |
212 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
213 | 252 | } else { |
214 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
253 | + if ($globalDebug) { |
|
254 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
255 | + } |
|
215 | 256 | return ''; |
216 | 257 | } |
217 | 258 | |
@@ -224,14 +265,21 @@ discard block |
||
224 | 265 | if ($distance > 1000 && $distance < 10000) { |
225 | 266 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
226 | 267 | $speed = $speed*3.6; |
227 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
228 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
268 | + if ($speed < 1000) { |
|
269 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
270 | + } |
|
271 | + if ($globalDebug) { |
|
272 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
273 | + } |
|
229 | 274 | } |
230 | 275 | } |
231 | 276 | |
232 | 277 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
233 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
234 | - else unset($timediff); |
|
278 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
279 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
280 | + } else { |
|
281 | + unset($timediff); |
|
282 | + } |
|
235 | 283 | 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')))) { |
236 | 284 | 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'])) { |
237 | 285 | 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'])) { |
@@ -239,22 +287,32 @@ discard block |
||
239 | 287 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
240 | 288 | $this->all_tracked[$id]['putinarchive'] = true; |
241 | 289 | |
242 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
290 | + if ($globalDebug) { |
|
291 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
292 | + } |
|
243 | 293 | $timeelapsed = microtime(true); |
244 | 294 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | 295 | $Marine = new Marine($this->db); |
246 | 296 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
247 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
297 | + if (!empty($all_country)) { |
|
298 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
299 | + } |
|
248 | 300 | $Marine->db = null; |
249 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + if ($globalDebugTimeElapsed) { |
|
302 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
303 | + } |
|
250 | 304 | } |
251 | 305 | $this->tmd = 0; |
252 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
306 | + if ($globalDebug) { |
|
307 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
308 | + } |
|
253 | 309 | } |
254 | 310 | } |
255 | 311 | |
256 | 312 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
257 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
313 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
314 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
315 | + } |
|
258 | 316 | 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') { |
259 | 317 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
260 | 318 | $dataFound = true; |
@@ -263,8 +321,12 @@ discard block |
||
263 | 321 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
264 | 322 | } |
265 | 323 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
266 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
267 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
324 | + if ($line['longitude'] > 180) { |
|
325 | + $line['longitude'] = $line['longitude'] - 360; |
|
326 | + } |
|
327 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
328 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
329 | + } |
|
268 | 330 | 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') { |
269 | 331 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
270 | 332 | $dataFound = true; |
@@ -282,7 +344,9 @@ discard block |
||
282 | 344 | } |
283 | 345 | } |
284 | 346 | if (isset($line['last_update']) && $line['last_update'] != '') { |
285 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
347 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
348 | + $dataFound = true; |
|
349 | + } |
|
286 | 350 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
287 | 351 | } |
288 | 352 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -312,15 +376,21 @@ discard block |
||
312 | 376 | } |
313 | 377 | |
314 | 378 | if (isset($line['heading']) && $line['heading'] != '') { |
315 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
379 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
380 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
381 | + } |
|
316 | 382 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
317 | 383 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
318 | 384 | //$dataFound = true; |
319 | 385 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
320 | 386 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
321 | 387 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
322 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
389 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
393 | + } |
|
324 | 394 | } |
325 | 395 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
326 | 396 | |
@@ -332,23 +402,38 @@ discard block |
||
332 | 402 | 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'])) { |
333 | 403 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
334 | 404 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
335 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
405 | + if ($globalDebug) { |
|
406 | + echo "Check if aircraft is already in DB..."; |
|
407 | + } |
|
336 | 408 | $timeelapsed = microtime(true); |
337 | 409 | $MarineLive = new MarineLive($this->db); |
338 | 410 | if (isset($line['id'])) { |
339 | 411 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
340 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
412 | + if ($globalDebugTimeElapsed) { |
|
413 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + } |
|
341 | 415 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
342 | 416 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + if ($globalDebugTimeElapsed) { |
|
418 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + } |
|
344 | 420 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
345 | 421 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
347 | - } else $recent_ident = ''; |
|
422 | + if ($globalDebugTimeElapsed) { |
|
423 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
424 | + } |
|
425 | + } else { |
|
426 | + $recent_ident = ''; |
|
427 | + } |
|
348 | 428 | $MarineLive->db=null; |
349 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
350 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
351 | - } else $recent_ident = ''; |
|
429 | + if ($globalDebug && $recent_ident == '') { |
|
430 | + echo " Not in DB.\n"; |
|
431 | + } elseif ($globalDebug && $recent_ident != '') { |
|
432 | + echo " Already in DB.\n"; |
|
433 | + } |
|
434 | + } else { |
|
435 | + $recent_ident = ''; |
|
436 | + } |
|
352 | 437 | } else { |
353 | 438 | $recent_ident = ''; |
354 | 439 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -356,30 +441,44 @@ discard block |
||
356 | 441 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
357 | 442 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
358 | 443 | { |
359 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
444 | + if ($globalDebug) { |
|
445 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
446 | + } |
|
360 | 447 | //adds the spotter data for the archive |
361 | 448 | $highlight = ''; |
362 | - 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'))); |
|
449 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
450 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
451 | + } |
|
363 | 452 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
364 | 453 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
365 | 454 | $timeelapsed = microtime(true); |
366 | 455 | $Marine = new Marine($this->db); |
367 | 456 | $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']); |
368 | 457 | $Marine->db = null; |
369 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
370 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebug && isset($result)) { |
|
459 | + echo $result."\n"; |
|
460 | + } |
|
461 | + if ($globalDebugTimeElapsed) { |
|
462 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
463 | + } |
|
371 | 464 | } |
372 | 465 | } |
373 | 466 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
374 | 467 | // Add source stat in DB |
375 | 468 | $Stats = new Stats($this->db); |
376 | 469 | if (!empty($this->stats)) { |
377 | - if ($globalDebug) echo 'Add source stats : '; |
|
470 | + if ($globalDebug) { |
|
471 | + echo 'Add source stats : '; |
|
472 | + } |
|
378 | 473 | foreach($this->stats as $date => $data) { |
379 | 474 | foreach($data as $source => $sourced) { |
380 | 475 | //print_r($sourced); |
381 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
382 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
476 | + if (isset($sourced['polar'])) { |
|
477 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
478 | + } |
|
479 | + if (isset($sourced['hist'])) { |
|
480 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
481 | + } |
|
383 | 482 | if (isset($sourced['msg'])) { |
384 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
385 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -392,7 +491,9 @@ discard block |
||
392 | 491 | unset($this->stats[$date]); |
393 | 492 | } |
394 | 493 | } |
395 | - if ($globalDebug) echo 'Done'."\n"; |
|
494 | + if ($globalDebug) { |
|
495 | + echo 'Done'."\n"; |
|
496 | + } |
|
396 | 497 | } |
397 | 498 | $Stats->db = null; |
398 | 499 | } |
@@ -402,13 +503,17 @@ discard block |
||
402 | 503 | $this->all_tracked[$id]['addedMarine'] = 1; |
403 | 504 | //print_r($this->all_tracked[$id]); |
404 | 505 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
405 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
506 | + if ($globalDebug) { |
|
507 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
508 | + } |
|
406 | 509 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
407 | 510 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
408 | 511 | $MarineLive = new MarineLive($this->db); |
409 | 512 | $MarineLive->deleteLiveMarineData(); |
410 | 513 | $MarineLive->db=null; |
411 | - if ($globalDebug) echo " Done\n"; |
|
514 | + if ($globalDebug) { |
|
515 | + echo " Done\n"; |
|
516 | + } |
|
412 | 517 | } |
413 | 518 | $this->last_delete = time(); |
414 | 519 | } |
@@ -434,15 +539,21 @@ discard block |
||
434 | 539 | |
435 | 540 | if (!$ignoreImport) { |
436 | 541 | 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'])) { |
437 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
542 | + if ($globalDebug) { |
|
543 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
544 | + } |
|
438 | 545 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
439 | 546 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 547 | $timeelapsed = microtime(true); |
441 | 548 | $MarineLive = new MarineLive($this->db); |
442 | 549 | $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']); |
443 | 550 | $MarineLive->db = null; |
444 | - if ($globalDebug) echo $result."\n"; |
|
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | + if ($globalDebug) { |
|
552 | + echo $result."\n"; |
|
553 | + } |
|
554 | + if ($globalDebugTimeElapsed) { |
|
555 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
556 | + } |
|
446 | 557 | } |
447 | 558 | } |
448 | 559 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -454,7 +565,9 @@ discard block |
||
454 | 565 | |
455 | 566 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
456 | 567 | $source = $this->all_tracked[$id]['source_name']; |
457 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
568 | + if ($source == '') { |
|
569 | + $source = $this->all_tracked[$id]['format_source']; |
|
570 | + } |
|
458 | 571 | if (!isset($this->source_location[$source])) { |
459 | 572 | $Location = new Source($this->db); |
460 | 573 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -475,7 +588,9 @@ discard block |
||
475 | 588 | $stats_heading = round($stats_heading/22.5); |
476 | 589 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
477 | 590 | $current_date = date('Y-m-d'); |
478 | - if ($stats_heading == 16) $stats_heading = 0; |
|
591 | + if ($stats_heading == 16) { |
|
592 | + $stats_heading = 0; |
|
593 | + } |
|
479 | 594 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
480 | 595 | for ($i=0;$i<=15;$i++) { |
481 | 596 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -493,7 +608,9 @@ discard block |
||
493 | 608 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
494 | 609 | end($this->stats[$current_date][$source]['hist']); |
495 | 610 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
496 | - } else $mini = 0; |
|
611 | + } else { |
|
612 | + $mini = 0; |
|
613 | + } |
|
497 | 614 | for ($i=$mini;$i<=$distance;$i+=10) { |
498 | 615 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
499 | 616 | } |
@@ -505,19 +622,27 @@ discard block |
||
505 | 622 | |
506 | 623 | |
507 | 624 | $this->all_tracked[$id]['lastupdate'] = time(); |
508 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
509 | - } 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"; |
|
625 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
626 | + $send = true; |
|
627 | + } |
|
628 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
629 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
630 | + } |
|
510 | 631 | //$this->del(); |
511 | 632 | |
512 | 633 | |
513 | 634 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
514 | 635 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
515 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
636 | + if ($globalDebug) { |
|
637 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
638 | + } |
|
516 | 639 | $MarineLive = new MarineLive($this->db); |
517 | 640 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
518 | 641 | $MarineLive->db = null; |
519 | 642 | //MarineLive->deleteLiveMarineData(); |
520 | - if ($globalDebug) echo " Done\n"; |
|
643 | + if ($globalDebug) { |
|
644 | + echo " Done\n"; |
|
645 | + } |
|
521 | 646 | } |
522 | 647 | $this->last_delete_hourly = time(); |
523 | 648 | } |
@@ -526,7 +651,9 @@ discard block |
||
526 | 651 | //$ignoreImport = false; |
527 | 652 | } |
528 | 653 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
529 | - if ($send) return $this->all_tracked[$id]; |
|
654 | + if ($send) { |
|
655 | + return $this->all_tracked[$id]; |
|
656 | + } |
|
530 | 657 | } |
531 | 658 | } |
532 | 659 | } |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection.'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection.'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 76 | } |
73 | 77 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
78 | + if ($filter_query_where == '' && $where) { |
|
79 | + $filter_query_where = ' WHERE'; |
|
80 | + } elseif ($filter_query_where != '' && $and) { |
|
81 | + $filter_query_where .= ' AND'; |
|
82 | + } |
|
76 | 83 | if ($filter_query_where != '') { |
77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
127 | 134 | } elseif (isset($row['spotter_archive_output_id'])) { |
128 | 135 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
129 | - */} |
|
130 | - elseif (isset($row['trackerid'])) { |
|
136 | + */} elseif (isset($row['trackerid'])) { |
|
131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
132 | 138 | } else { |
133 | 139 | $temp_array['trackerid'] = ''; |
134 | 140 | } |
135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
141 | + if (isset($row['famtrackid'])) { |
|
142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
147 | + if (isset($row['comment'])) { |
|
148 | + $temp_array['comment'] = $row['comment']; |
|
149 | + } |
|
138 | 150 | $temp_array['ident'] = $row['ident']; |
139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
160 | + if (isset($row['altitude'])) { |
|
161 | + $temp_array['altitude'] = $row['altitude']; |
|
162 | + } |
|
143 | 163 | if (isset($row['heading'])) { |
144 | 164 | $temp_array['heading'] = $row['heading']; |
145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 172 | } |
148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
149 | 173 | |
150 | 174 | if (isset($row['date'])) { |
151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
188 | 212 | } |
189 | 213 | |
190 | 214 | $fromsource = NULL; |
191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
216 | + $temp_array['source_name'] = $row['source_name']; |
|
217 | + } |
|
218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
219 | + $temp_array['over_country'] = $row['over_country']; |
|
220 | + } |
|
221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
222 | + $temp_array['distance'] = $row['distance']; |
|
223 | + } |
|
194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
195 | 225 | $spotter_array[] = $temp_array; |
196 | 226 | } |
197 | - if ($num_rows == 0) return array(); |
|
227 | + if ($num_rows == 0) { |
|
228 | + return array(); |
|
229 | + } |
|
198 | 230 | $spotter_array[0]['query_number_rows'] = $num_rows; |
199 | 231 | return $spotter_array; |
200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
225 | 257 | { |
226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
228 | - } else $limit_query = ""; |
|
229 | - } else $limit_query = ""; |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
230 | 266 | |
231 | 267 | if ($sort != "") |
232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
254 | 290 | global $global_query; |
255 | 291 | |
256 | 292 | date_default_timezone_set('UTC'); |
257 | - if ($id == '') return array(); |
|
293 | + if ($id == '') { |
|
294 | + return array(); |
|
295 | + } |
|
258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 297 | $query_values = array(':id' => $id); |
260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
398 | 436 | |
399 | 437 | $sth = $this->db->prepare($query); |
400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
401 | - else $sth->execute(); |
|
438 | + if (!empty($query_values)) { |
|
439 | + $sth->execute($query_values); |
|
440 | + } else { |
|
441 | + $sth->execute(); |
|
442 | + } |
|
402 | 443 | |
403 | 444 | $source_array = array(); |
404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
453 | 494 | date_default_timezone_set($globalTimezone); |
454 | 495 | $datetime = new DateTime(); |
455 | 496 | $offset = $datetime->format('P'); |
456 | - } else $offset = '+00:00'; |
|
497 | + } else { |
|
498 | + $offset = '+00:00'; |
|
499 | + } |
|
457 | 500 | |
458 | 501 | if ($globalDBdriver == 'mysql') { |
459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
609 | 652 | { |
610 | 653 | return false; |
611 | 654 | } |
612 | - } else $altitude = 0; |
|
655 | + } else { |
|
656 | + $altitude = 0; |
|
657 | + } |
|
613 | 658 | |
614 | 659 | if ($heading != "") |
615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
648 | 693 | $latitude = 0; |
649 | 694 | $longitude = 0; |
650 | 695 | } |
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
697 | + $heading = 0; |
|
698 | + } |
|
699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
700 | + $groundspeed = 0; |
|
701 | + } |
|
653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 704 | |
@@ -758,7 +807,9 @@ discard block |
||
758 | 807 | global $globalDBdriver, $globalArchive; |
759 | 808 | //$filter_query = $this->getFilter($filters,true,true); |
760 | 809 | $Connection= new Connection($this->db); |
761 | - if (!$Connection->tableExists('countries')) return array(); |
|
810 | + if (!$Connection->tableExists('countries')) { |
|
811 | + return array(); |
|
812 | + } |
|
762 | 813 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 814 | require_once('class.TrackerLive.php'); |
764 | 815 | $TrackerLive = new TrackerLive($this->db); |
@@ -801,7 +852,9 @@ discard block |
||
801 | 852 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
802 | 853 | } |
803 | 854 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
804 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
855 | + if ($limit) { |
|
856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
857 | + } |
|
805 | 858 | |
806 | 859 | |
807 | 860 | $sth = $this->db->prepare($query); |
@@ -834,12 +887,18 @@ discard block |
||
834 | 887 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
835 | 888 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 889 | if ($olderthanmonths > 0) { |
837 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
838 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
890 | + if ($globalDBdriver == 'mysql') { |
|
891 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
892 | + } else { |
|
893 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
894 | + } |
|
839 | 895 | } |
840 | 896 | if ($sincedate != '') { |
841 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
842 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
897 | + if ($globalDBdriver == 'mysql') { |
|
898 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
899 | + } else { |
|
900 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
901 | + } |
|
843 | 902 | } |
844 | 903 | $query_values = array(); |
845 | 904 | if ($year != '') { |
@@ -870,7 +929,9 @@ discard block |
||
870 | 929 | } |
871 | 930 | } |
872 | 931 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
873 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
932 | + if ($limit) { |
|
933 | + $query .= " LIMIT 10 OFFSET 0"; |
|
934 | + } |
|
874 | 935 | |
875 | 936 | $sth = $this->db->prepare($query); |
876 | 937 | $sth->execute($query_values); |
@@ -905,7 +966,9 @@ discard block |
||
905 | 966 | date_default_timezone_set($globalTimezone); |
906 | 967 | $datetime = new DateTime(); |
907 | 968 | $offset = $datetime->format('P'); |
908 | - } else $offset = '+00:00'; |
|
969 | + } else { |
|
970 | + $offset = '+00:00'; |
|
971 | + } |
|
909 | 972 | |
910 | 973 | if ($globalDBdriver == 'mysql') { |
911 | 974 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -955,7 +1018,9 @@ discard block |
||
955 | 1018 | date_default_timezone_set($globalTimezone); |
956 | 1019 | $datetime = new DateTime(); |
957 | 1020 | $offset = $datetime->format('P'); |
958 | - } else $offset = '+00:00'; |
|
1021 | + } else { |
|
1022 | + $offset = '+00:00'; |
|
1023 | + } |
|
959 | 1024 | $filter_query = $this->getFilter($filters,true,true); |
960 | 1025 | if ($globalDBdriver == 'mysql') { |
961 | 1026 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1001,7 +1066,9 @@ discard block |
||
1001 | 1066 | date_default_timezone_set($globalTimezone); |
1002 | 1067 | $datetime = new DateTime(); |
1003 | 1068 | $offset = $datetime->format('P'); |
1004 | - } else $offset = '+00:00'; |
|
1069 | + } else { |
|
1070 | + $offset = '+00:00'; |
|
1071 | + } |
|
1005 | 1072 | $filter_query = $this->getFilter($filters,true,true); |
1006 | 1073 | if ($globalDBdriver == 'mysql') { |
1007 | 1074 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1049,7 +1116,9 @@ discard block |
||
1049 | 1116 | date_default_timezone_set($globalTimezone); |
1050 | 1117 | $datetime = new DateTime(); |
1051 | 1118 | $offset = $datetime->format('P'); |
1052 | - } else $offset = '+00:00'; |
|
1119 | + } else { |
|
1120 | + $offset = '+00:00'; |
|
1121 | + } |
|
1053 | 1122 | |
1054 | 1123 | if ($globalDBdriver == 'mysql') { |
1055 | 1124 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1098,7 +1167,9 @@ discard block |
||
1098 | 1167 | date_default_timezone_set($globalTimezone); |
1099 | 1168 | $datetime = new DateTime(); |
1100 | 1169 | $offset = $datetime->format('P'); |
1101 | - } else $offset = '+00:00'; |
|
1170 | + } else { |
|
1171 | + $offset = '+00:00'; |
|
1172 | + } |
|
1102 | 1173 | $filter_query = $this->getFilter($filters,true,true); |
1103 | 1174 | if ($globalDBdriver == 'mysql') { |
1104 | 1175 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1147,7 +1218,9 @@ discard block |
||
1147 | 1218 | date_default_timezone_set($globalTimezone); |
1148 | 1219 | $datetime = new DateTime(); |
1149 | 1220 | $offset = $datetime->format('P'); |
1150 | - } else $offset = '+00:00'; |
|
1221 | + } else { |
|
1222 | + $offset = '+00:00'; |
|
1223 | + } |
|
1151 | 1224 | |
1152 | 1225 | $orderby_sql = ''; |
1153 | 1226 | if ($orderby == "hour") |
@@ -1216,7 +1289,9 @@ discard block |
||
1216 | 1289 | date_default_timezone_set($globalTimezone); |
1217 | 1290 | $datetime = new DateTime($date); |
1218 | 1291 | $offset = $datetime->format('P'); |
1219 | - } else $offset = '+00:00'; |
|
1292 | + } else { |
|
1293 | + $offset = '+00:00'; |
|
1294 | + } |
|
1220 | 1295 | |
1221 | 1296 | if ($globalDBdriver == 'mysql') { |
1222 | 1297 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1264,7 +1339,9 @@ discard block |
||
1264 | 1339 | date_default_timezone_set($globalTimezone); |
1265 | 1340 | $datetime = new DateTime(); |
1266 | 1341 | $offset = $datetime->format('P'); |
1267 | - } else $offset = '+00:00'; |
|
1342 | + } else { |
|
1343 | + $offset = '+00:00'; |
|
1344 | + } |
|
1268 | 1345 | |
1269 | 1346 | if ($globalDBdriver == 'mysql') { |
1270 | 1347 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1329,8 +1406,11 @@ discard block |
||
1329 | 1406 | $query_values = array_merge($query_values,array(':month' => $month)); |
1330 | 1407 | } |
1331 | 1408 | } |
1332 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1409 | + if (empty($query_values)) { |
|
1410 | + $queryi .= $this->getFilter($filters); |
|
1411 | + } else { |
|
1412 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1413 | + } |
|
1334 | 1414 | |
1335 | 1415 | $sth = $this->db->prepare($queryi); |
1336 | 1416 | $sth->execute($query_values); |
@@ -1367,8 +1447,11 @@ discard block |
||
1367 | 1447 | $query_values = array_merge($query_values,array(':month' => $month)); |
1368 | 1448 | } |
1369 | 1449 | } |
1370 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1450 | + if (empty($query_values)) { |
|
1451 | + $queryi .= $this->getFilter($filters); |
|
1452 | + } else { |
|
1453 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1454 | + } |
|
1372 | 1455 | |
1373 | 1456 | $sth = $this->db->prepare($queryi); |
1374 | 1457 | $sth->execute($query_values); |
@@ -1390,7 +1473,9 @@ discard block |
||
1390 | 1473 | date_default_timezone_set($globalTimezone); |
1391 | 1474 | $datetime = new DateTime(); |
1392 | 1475 | $offset = $datetime->format('P'); |
1393 | - } else $offset = '+00:00'; |
|
1476 | + } else { |
|
1477 | + $offset = '+00:00'; |
|
1478 | + } |
|
1394 | 1479 | |
1395 | 1480 | if ($globalDBdriver == 'mysql') { |
1396 | 1481 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1494,7 +1579,9 @@ discard block |
||
1494 | 1579 | */ |
1495 | 1580 | public function parseDirection($direction = 0) |
1496 | 1581 | { |
1497 | - if ($direction == '') $direction = 0; |
|
1582 | + if ($direction == '') { |
|
1583 | + $direction = 0; |
|
1584 | + } |
|
1498 | 1585 | $direction_array = array(); |
1499 | 1586 | $temp_array = array(); |
1500 | 1587 | |
@@ -1583,7 +1670,9 @@ discard block |
||
1583 | 1670 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1584 | 1671 | |
1585 | 1672 | $Connection = new Connection($this->db); |
1586 | - if (!$Connection->tableExists('countries')) return ''; |
|
1673 | + if (!$Connection->tableExists('countries')) { |
|
1674 | + return ''; |
|
1675 | + } |
|
1587 | 1676 | |
1588 | 1677 | try { |
1589 | 1678 | /* |
@@ -1603,9 +1692,13 @@ discard block |
||
1603 | 1692 | $sth->closeCursor(); |
1604 | 1693 | if (count($row) > 0) { |
1605 | 1694 | return $row; |
1606 | - } else return ''; |
|
1695 | + } else { |
|
1696 | + return ''; |
|
1697 | + } |
|
1607 | 1698 | } catch (PDOException $e) { |
1608 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1699 | + if (isset($globalDebug) && $globalDebug) { |
|
1700 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1701 | + } |
|
1609 | 1702 | return ''; |
1610 | 1703 | } |
1611 | 1704 | |
@@ -1623,7 +1716,9 @@ discard block |
||
1623 | 1716 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1624 | 1717 | |
1625 | 1718 | $Connection = new Connection($this->db); |
1626 | - if (!$Connection->tableExists('countries')) return ''; |
|
1719 | + if (!$Connection->tableExists('countries')) { |
|
1720 | + return ''; |
|
1721 | + } |
|
1627 | 1722 | |
1628 | 1723 | try { |
1629 | 1724 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1635,9 +1730,13 @@ discard block |
||
1635 | 1730 | $sth->closeCursor(); |
1636 | 1731 | if (count($row) > 0) { |
1637 | 1732 | return $row; |
1638 | - } else return ''; |
|
1733 | + } else { |
|
1734 | + return ''; |
|
1735 | + } |
|
1639 | 1736 | } catch (PDOException $e) { |
1640 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1737 | + if (isset($globalDebug) && $globalDebug) { |
|
1738 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1739 | + } |
|
1641 | 1740 | return ''; |
1642 | 1741 | } |
1643 | 1742 | |
@@ -1698,7 +1797,9 @@ discard block |
||
1698 | 1797 | } |
1699 | 1798 | } |
1700 | 1799 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1701 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1800 | + if ($limit) { |
|
1801 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1802 | + } |
|
1702 | 1803 | $sth = $this->db->prepare($query); |
1703 | 1804 | $sth->execute($query_values); |
1704 | 1805 | $tracker_array = array(); |
@@ -1725,7 +1826,9 @@ discard block |
||
1725 | 1826 | { |
1726 | 1827 | global $globalBitlyAccessToken; |
1727 | 1828 | |
1728 | - if ($globalBitlyAccessToken == '') return $url; |
|
1829 | + if ($globalBitlyAccessToken == '') { |
|
1830 | + return $url; |
|
1831 | + } |
|
1729 | 1832 | |
1730 | 1833 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1731 | 1834 |
@@ -48,27 +48,52 @@ discard block |
||
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
52 | -else $compress = $globalJsonCompress; |
|
51 | +if (!isset($globalJsonCompress)) { |
|
52 | + $compress = true; |
|
53 | +} else { |
|
54 | + $compress = $globalJsonCompress; |
|
55 | +} |
|
53 | 56 | |
54 | 57 | $from_archive = false; |
55 | 58 | $min = true; |
56 | 59 | $allhistory = false; |
57 | 60 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
63 | +} |
|
64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
66 | +} |
|
67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
69 | +} |
|
70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
71 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
72 | +} |
|
73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
75 | +} |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
78 | +} |
|
79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
81 | +} |
|
82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | +} |
|
85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
87 | +} |
|
88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
90 | +} |
|
68 | 91 | |
69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 93 | $min = true; |
71 | -} else $min = false; |
|
94 | +} else { |
|
95 | + $min = false; |
|
96 | +} |
|
72 | 97 | |
73 | 98 | if (isset($_GET['ident'])) { |
74 | 99 | $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
@@ -162,20 +187,30 @@ discard block |
||
162 | 187 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
163 | 188 | } |
164 | 189 | } |
165 | - if ($flightcnt == '') $flightcnt = 0; |
|
166 | -} else $flightcnt = 0; |
|
190 | + if ($flightcnt == '') { |
|
191 | + $flightcnt = 0; |
|
192 | + } |
|
193 | + } else { |
|
194 | + $flightcnt = 0; |
|
195 | +} |
|
167 | 196 | |
168 | 197 | $sqltime = round(microtime(true)-$begintime,2); |
169 | 198 | |
170 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
171 | -else $usenextlatlon = true; |
|
199 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
200 | + $usenextlatlon = false; |
|
201 | +} else { |
|
202 | + $usenextlatlon = true; |
|
203 | +} |
|
172 | 204 | $j = 0; |
173 | 205 | $prev_flightaware_id = ''; |
174 | 206 | $aircrafts_shadow = array(); |
175 | 207 | $output = '{'; |
176 | 208 | $output .= '"type": "FeatureCollection",'; |
177 | - if ($min) $output .= '"minimal": "true",'; |
|
178 | - else $output .= '"minimal": "false",'; |
|
209 | + if ($min) { |
|
210 | + $output .= '"minimal": "true",'; |
|
211 | + } else { |
|
212 | + $output .= '"minimal": "false",'; |
|
213 | + } |
|
179 | 214 | //$output .= '"fc": "'.$flightcnt.'",'; |
180 | 215 | $output .= '"sqt": "'.$sqltime.'",'; |
181 | 216 | |
@@ -219,18 +254,29 @@ discard block |
||
219 | 254 | } |
220 | 255 | $output .= '"properties": {'; |
221 | 256 | if (isset($spotter_item['flightaware_id'])) { |
222 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
223 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
257 | + if ($compress) { |
|
258 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
259 | + } else { |
|
260 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
261 | + } |
|
224 | 262 | } elseif (isset($spotter_item['famtrackid'])) { |
225 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
226 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
263 | + if ($compress) { |
|
264 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
265 | + } else { |
|
266 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
267 | + } |
|
227 | 268 | } elseif (isset($spotter_item['fammarine_id'])) { |
228 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
229 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
269 | + if ($compress) { |
|
270 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
271 | + } else { |
|
272 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
273 | + } |
|
230 | 274 | } |
231 | 275 | $output .= '"fc": "'.$flightcnt.'",'; |
232 | 276 | $output .= '"sqt": "'.$sqltime.'",'; |
233 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
277 | + if (isset($begindate)) { |
|
278 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
279 | + } |
|
234 | 280 | |
235 | 281 | /* |
236 | 282 | if ($min) $output .= '"minimal": "true",'; |
@@ -238,14 +284,22 @@ discard block |
||
238 | 284 | */ |
239 | 285 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
240 | 286 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
241 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
242 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
287 | + if ($compress) { |
|
288 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
289 | + } else { |
|
290 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
291 | + } |
|
243 | 292 | //" |
244 | 293 | } else { |
245 | - if ($compress) $output .= '"c": "NA",'; |
|
246 | - else $output .= '"callsign": "NA",'; |
|
294 | + if ($compress) { |
|
295 | + $output .= '"c": "NA",'; |
|
296 | + } else { |
|
297 | + $output .= '"callsign": "NA",'; |
|
298 | + } |
|
299 | + } |
|
300 | + if (isset($spotter_item['registration'])) { |
|
301 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
247 | 302 | } |
248 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
249 | 303 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
250 | 304 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
251 | 305 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -258,16 +312,23 @@ discard block |
||
258 | 312 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
259 | 313 | } |
260 | 314 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
261 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
262 | - else { |
|
315 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
316 | + $spotter_item['aircraft_shadow'] = ''; |
|
317 | + } else { |
|
263 | 318 | $aircraft_icao = $spotter_item['aircraft_icao']; |
264 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
265 | - else { |
|
319 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
320 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
321 | + } else { |
|
266 | 322 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
267 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
268 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
269 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
270 | - else $spotter_item['aircraft_shadow'] = ''; |
|
323 | + if (count($aircraft_info) > 0) { |
|
324 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
325 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
326 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
327 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
328 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
329 | + } else { |
|
330 | + $spotter_item['aircraft_shadow'] = ''; |
|
331 | + } |
|
271 | 332 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
272 | 333 | } |
273 | 334 | } |
@@ -275,73 +336,139 @@ discard block |
||
275 | 336 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
276 | 337 | if ($tracker) { |
277 | 338 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
278 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
279 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
339 | + if ($compress) { |
|
340 | + $output .= '"as": "ambulance.png",'; |
|
341 | + } else { |
|
342 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
343 | + } |
|
280 | 344 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
281 | - if ($compress) $output .= '"as": "police.png",'; |
|
282 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
345 | + if ($compress) { |
|
346 | + $output .= '"as": "police.png",'; |
|
347 | + } else { |
|
348 | + $output .= '"aircraft_shadow": "police.png",'; |
|
349 | + } |
|
283 | 350 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
284 | - if ($compress) $output .= '"as": "ship.png",'; |
|
285 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
351 | + if ($compress) { |
|
352 | + $output .= '"as": "ship.png",'; |
|
353 | + } else { |
|
354 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
355 | + } |
|
286 | 356 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
287 | - if ($compress) $output .= '"as": "ship.png",'; |
|
288 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
357 | + if ($compress) { |
|
358 | + $output .= '"as": "ship.png",'; |
|
359 | + } else { |
|
360 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
361 | + } |
|
289 | 362 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
290 | - if ($compress) $output .= '"as": "ship.png",'; |
|
291 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
363 | + if ($compress) { |
|
364 | + $output .= '"as": "ship.png",'; |
|
365 | + } else { |
|
366 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
367 | + } |
|
292 | 368 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
293 | - if ($compress) $output .= '"as": "truck.png",'; |
|
294 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
369 | + if ($compress) { |
|
370 | + $output .= '"as": "truck.png",'; |
|
371 | + } else { |
|
372 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
373 | + } |
|
295 | 374 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
296 | - if ($compress) $output .= '"as": "truck.png",'; |
|
297 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
375 | + if ($compress) { |
|
376 | + $output .= '"as": "truck.png",'; |
|
377 | + } else { |
|
378 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
379 | + } |
|
298 | 380 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
299 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
300 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
381 | + if ($compress) { |
|
382 | + $output .= '"as": "aircraft.png",'; |
|
383 | + } else { |
|
384 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
385 | + } |
|
301 | 386 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
302 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
303 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
387 | + if ($compress) { |
|
388 | + $output .= '"as": "aircraft.png",'; |
|
389 | + } else { |
|
390 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
391 | + } |
|
304 | 392 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
305 | - if ($compress) $output .= '"as": "helico.png",'; |
|
306 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
393 | + if ($compress) { |
|
394 | + $output .= '"as": "helico.png",'; |
|
395 | + } else { |
|
396 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
397 | + } |
|
307 | 398 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
308 | - if ($compress) $output .= '"as": "rail.png",'; |
|
309 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
399 | + if ($compress) { |
|
400 | + $output .= '"as": "rail.png",'; |
|
401 | + } else { |
|
402 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
403 | + } |
|
310 | 404 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
311 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
312 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
405 | + if ($compress) { |
|
406 | + $output .= '"as": "firetruck.png",'; |
|
407 | + } else { |
|
408 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
409 | + } |
|
313 | 410 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
314 | - if ($compress) $output .= '"as": "bus.png",'; |
|
315 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
411 | + if ($compress) { |
|
412 | + $output .= '"as": "bus.png",'; |
|
413 | + } else { |
|
414 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
415 | + } |
|
316 | 416 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
317 | - if ($compress) $output .= '"as": "phone.png",'; |
|
318 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
417 | + if ($compress) { |
|
418 | + $output .= '"as": "phone.png",'; |
|
419 | + } else { |
|
420 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
421 | + } |
|
319 | 422 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
320 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
321 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
423 | + if ($compress) { |
|
424 | + $output .= '"as": "jogger.png",'; |
|
425 | + } else { |
|
426 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
427 | + } |
|
322 | 428 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
323 | - if ($compress) $output .= '"as": "bike.png",'; |
|
324 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
429 | + if ($compress) { |
|
430 | + $output .= '"as": "bike.png",'; |
|
431 | + } else { |
|
432 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
433 | + } |
|
325 | 434 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
326 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
327 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
435 | + if ($compress) { |
|
436 | + $output .= '"as": "motorcycle.png",'; |
|
437 | + } else { |
|
438 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
439 | + } |
|
328 | 440 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
329 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
330 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
441 | + if ($compress) { |
|
442 | + $output .= '"as": "balloon.png",'; |
|
443 | + } else { |
|
444 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
445 | + } |
|
331 | 446 | } else { |
332 | - if ($compress) $output .= '"as": "car.png",'; |
|
333 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
447 | + if ($compress) { |
|
448 | + $output .= '"as": "car.png",'; |
|
449 | + } else { |
|
450 | + $output .= '"aircraft_shadow": "car.png",'; |
|
451 | + } |
|
334 | 452 | } |
335 | 453 | } elseif ($marine) { |
336 | - if ($compress) $output .= '"as": "ship.png",'; |
|
337 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
454 | + if ($compress) { |
|
455 | + $output .= '"as": "ship.png",'; |
|
456 | + } else { |
|
457 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
458 | + } |
|
338 | 459 | } else { |
339 | - if ($compress) $output .= '"as": "default.png",'; |
|
340 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
460 | + if ($compress) { |
|
461 | + $output .= '"as": "default.png",'; |
|
462 | + } else { |
|
463 | + $output .= '"aircraft_shadow": "default.png",'; |
|
464 | + } |
|
341 | 465 | } |
342 | 466 | } else { |
343 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
344 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
467 | + if ($compress) { |
|
468 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
469 | + } else { |
|
470 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
471 | + } |
|
345 | 472 | } |
346 | 473 | if (isset($spotter_item['airline_name'])) { |
347 | 474 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -349,8 +476,11 @@ discard block |
||
349 | 476 | $output .= '"airline_name": "NA",'; |
350 | 477 | } |
351 | 478 | if (isset($spotter_item['departure_airport'])) { |
352 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
353 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
479 | + if ($compress) { |
|
480 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
481 | + } else { |
|
482 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
483 | + } |
|
354 | 484 | } |
355 | 485 | if (isset($spotter_item['departure_airport_city'])) { |
356 | 486 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -362,8 +492,11 @@ discard block |
||
362 | 492 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
363 | 493 | } |
364 | 494 | if (isset($spotter_item['arrival_airport'])) { |
365 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
366 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
495 | + if ($compress) { |
|
496 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
497 | + } else { |
|
498 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
499 | + } |
|
367 | 500 | } |
368 | 501 | if (isset($spotter_item['arrival_airport_city'])) { |
369 | 502 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -382,11 +515,17 @@ discard block |
||
382 | 515 | } |
383 | 516 | |
384 | 517 | if (isset($spotter_item['altitude'])) { |
385 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
386 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
518 | + if ($compress) { |
|
519 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
520 | + } else { |
|
521 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
522 | + } |
|
523 | + } |
|
524 | + if ($compress) { |
|
525 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
526 | + } else { |
|
527 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
387 | 528 | } |
388 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
389 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
390 | 529 | |
391 | 530 | if (isset($archivespeed)) { |
392 | 531 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -396,7 +535,9 @@ discard block |
||
396 | 535 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
397 | 536 | } |
398 | 537 | |
399 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
538 | + if (!$min) { |
|
539 | + $output .= '"image": "'.$image.'",'; |
|
540 | + } |
|
400 | 541 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
401 | 542 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
402 | 543 | } |
@@ -404,8 +545,11 @@ discard block |
||
404 | 545 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
405 | 546 | } |
406 | 547 | if (isset($spotter_item['squawk'])) { |
407 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
408 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
548 | + if ($compress) { |
|
549 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
550 | + } else { |
|
551 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
552 | + } |
|
409 | 553 | } |
410 | 554 | if (isset($spotter_item['squawk_usage'])) { |
411 | 555 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -424,14 +568,23 @@ discard block |
||
424 | 568 | } |
425 | 569 | // type when not aircraft ? |
426 | 570 | if (isset($spotter_item['type'])) { |
427 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
428 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
571 | + if ($compress) { |
|
572 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
573 | + } else { |
|
574 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
575 | + } |
|
429 | 576 | } elseif ($marine) { |
430 | - if ($compress) $output .= '"t": "ship"'; |
|
431 | - else $output .= '"type": "ship"'; |
|
577 | + if ($compress) { |
|
578 | + $output .= '"t": "ship"'; |
|
579 | + } else { |
|
580 | + $output .= '"type": "ship"'; |
|
581 | + } |
|
432 | 582 | } else { |
433 | - if ($compress) $output .= '"t": "aircraft"'; |
|
434 | - else $output .= '"type": "aircraft"'; |
|
583 | + if ($compress) { |
|
584 | + $output .= '"t": "aircraft"'; |
|
585 | + } else { |
|
586 | + $output .= '"type": "aircraft"'; |
|
587 | + } |
|
435 | 588 | } |
436 | 589 | $output .= '},'; |
437 | 590 | $output .= '"geometry": {'; |
@@ -499,7 +652,9 @@ discard block |
||
499 | 652 | } |
500 | 653 | */ |
501 | 654 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
502 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
655 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
656 | + $history = $_COOKIE['history']; |
|
657 | + } |
|
503 | 658 | |
504 | 659 | if ( |
505 | 660 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -543,8 +698,11 @@ discard block |
||
543 | 698 | $output_history .= ']}},'; |
544 | 699 | $output .= $output_history; |
545 | 700 | } |
546 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
547 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
701 | + if ($compress) { |
|
702 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
703 | + } else { |
|
704 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
705 | + } |
|
548 | 706 | } |
549 | 707 | $output_history .= '['; |
550 | 708 | $output_history .= $spotter_history['longitude'].', '; |
@@ -563,9 +721,14 @@ discard block |
||
563 | 721 | $prev_alt = $alt; |
564 | 722 | } else { |
565 | 723 | if ($d == false) { |
566 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
567 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
568 | - } else $d = true; |
|
724 | + if ($compress) { |
|
725 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
726 | + } else { |
|
727 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
728 | + } |
|
729 | + } else { |
|
730 | + $d = true; |
|
731 | + } |
|
569 | 732 | $output_history .= '['; |
570 | 733 | $output_history .= $spotter_history['longitude'].', '; |
571 | 734 | $output_history .= $spotter_history['latitude']; |
@@ -586,7 +749,9 @@ discard block |
||
586 | 749 | $output_historyd = '['; |
587 | 750 | $output_historyd .= $spotter_item['longitude'].', '; |
588 | 751 | $output_historyd .= $spotter_item['latitude']; |
589 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
752 | + if (isset($spotter_history['altitude'])) { |
|
753 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
754 | + } |
|
590 | 755 | $output_historyd .= '],'; |
591 | 756 | //$output_history = $output_historyd.$output_history; |
592 | 757 | $output_history = $output_history.$output_historyd; |
@@ -608,8 +773,11 @@ discard block |
||
608 | 773 | && $spotter_item['arrival_airport'] != 'NA' |
609 | 774 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
610 | 775 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
611 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
612 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
776 | + if ($compress) { |
|
777 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
778 | + } else { |
|
779 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
780 | + } |
|
613 | 781 | if (isset($spotter_item['departure_airport_latitude'])) { |
614 | 782 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
615 | 783 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -642,8 +810,11 @@ discard block |
||
642 | 810 | || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
643 | 811 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
644 | 812 | $havedata = false; |
645 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
646 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
813 | + if ($compress) { |
|
814 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
815 | + } else { |
|
816 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
817 | + } |
|
647 | 818 | $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
648 | 819 | |
649 | 820 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -658,7 +829,9 @@ discard block |
||
658 | 829 | } |
659 | 830 | //$output_dest = substr($output_dest, 0, -1); |
660 | 831 | $output_dest .= ']}},'; |
661 | - if ($havedata) $output .= $output_dest; |
|
832 | + if ($havedata) { |
|
833 | + $output .= $output_dest; |
|
834 | + } |
|
662 | 835 | unset($output_dest); |
663 | 836 | } |
664 | 837 | } |
@@ -666,7 +839,9 @@ discard block |
||
666 | 839 | $output .= ']'; |
667 | 840 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
668 | 841 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
669 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
842 | + if (isset($begindate)) { |
|
843 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
844 | + } |
|
670 | 845 | $output .= '"fc": "'.$j.'"'; |
671 | 846 | } else { |
672 | 847 | $output .= '"features": '; |