@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param Array $headers header to submit with the form |
15 | 15 | * @return String the result |
16 | 16 | */ |
17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
24 | 24 | } |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
33 | 33 | //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'); |
34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
43 | 43 | if ($type == 'post') { |
44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
45 | 45 | if (is_array($data)) { |
46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
47 | 47 | $data_string = ''; |
48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
49 | 49 | rtrim($data_string, '&'); |
50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | if ($cookie != '') { |
59 | 59 | if (is_array($cookie)) { |
60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
61 | 61 | } else { |
62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
63 | 63 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $info = curl_getinfo($ch); |
70 | 70 | //var_dump($info); |
71 | 71 | curl_close($ch); |
72 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
72 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
73 | 73 | echo "Cloudflare Detected\n"; |
74 | 74 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
75 | 75 | $useragent = UAgent::random(); |
76 | 76 | cloudflare::useUserAgent($useragent); |
77 | 77 | if ($clearanceCookie = cloudflare::bypass($url)) { |
78 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
78 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | return $result; |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | fclose($fp); |
107 | 107 | } |
108 | 108 | |
109 | - public static function gunzip($in_file,$out_file_name = '') { |
|
109 | + public static function gunzip($in_file, $out_file_name = '') { |
|
110 | 110 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 111 | $buffer_size = 4096; // read 4kb at a time |
112 | 112 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
113 | 113 | if ($in_file != '' && file_exists($in_file)) { |
114 | 114 | // 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'); |
|
115 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
116 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
117 | 117 | else { |
118 | 118 | echo 'gzopen not available'; |
119 | 119 | die; |
120 | 120 | } |
121 | 121 | $out_file = fopen($out_file_name, 'wb'); |
122 | - while(!gzeof($file)) { |
|
122 | + while (!gzeof($file)) { |
|
123 | 123 | fwrite($out_file, gzread($file, $buffer_size)); |
124 | 124 | } |
125 | 125 | fclose($out_file); |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
130 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
131 | 131 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 132 | $buffer_size = 4096; // read 4kb at a time |
133 | 133 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
134 | 134 | if ($in_file != '' && file_exists($in_file)) { |
135 | 135 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
136 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
137 | 137 | else { |
138 | 138 | echo 'bzopen not available'; |
139 | 139 | die; |
140 | 140 | } |
141 | 141 | $out_file = fopen($out_file_name, 'wb'); |
142 | - while(!feof($file)) { |
|
142 | + while (!feof($file)) { |
|
143 | 143 | fwrite($out_file, bzread($file, $buffer_size)); |
144 | 144 | } |
145 | 145 | fclose($out_file); |
@@ -157,27 +157,27 @@ discard block |
||
157 | 157 | if ($data == '') return array(); |
158 | 158 | $html = str_get_html($data); |
159 | 159 | if ($html === false) return array(); |
160 | - $tabledata=array(); |
|
161 | - foreach($html->find('tr') as $element) |
|
160 | + $tabledata = array(); |
|
161 | + foreach ($html->find('tr') as $element) |
|
162 | 162 | { |
163 | 163 | $td = array(); |
164 | - foreach( $element->find('th') as $row) |
|
164 | + foreach ($element->find('th') as $row) |
|
165 | 165 | { |
166 | 166 | $td [] = trim($row->plaintext); |
167 | 167 | } |
168 | - $td=array_filter($td); |
|
168 | + $td = array_filter($td); |
|
169 | 169 | $tabledata[] = $td; |
170 | 170 | |
171 | 171 | $td = array(); |
172 | 172 | $tdi = array(); |
173 | - foreach( $element->find('td') as $row) |
|
173 | + foreach ($element->find('td') as $row) |
|
174 | 174 | { |
175 | 175 | $td [] = trim($row->plaintext); |
176 | 176 | $tdi [] = trim($row->innertext); |
177 | 177 | } |
178 | - $td=array_filter($td); |
|
179 | - $tdi=array_filter($tdi); |
|
180 | - $tabledata[]=array_merge($td,$tdi); |
|
178 | + $td = array_filter($td); |
|
179 | + $tdi = array_filter($tdi); |
|
180 | + $tabledata[] = array_merge($td, $tdi); |
|
181 | 181 | } |
182 | 182 | $html->clear(); |
183 | 183 | unset($html); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | public function text2array($data) { |
193 | 193 | $html = str_get_html($data); |
194 | 194 | if ($html === false) return array(); |
195 | - $tabledata=array(); |
|
196 | - foreach($html->find('p') as $element) |
|
195 | + $tabledata = array(); |
|
196 | + foreach ($html->find('p') as $element) |
|
197 | 197 | { |
198 | 198 | $tabledata [] = trim($element->plaintext); |
199 | 199 | } |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | 215 | if ($lat == $latc && $lon == $lonc) return 0; |
216 | - $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; |
|
216 | + $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 | 217 | if ($unit == "km") { |
218 | - return round($dist * 1.609344); |
|
218 | + return round($dist*1.609344); |
|
219 | 219 | } elseif ($unit == "m") { |
220 | - return round($dist * 1.609344 * 1000); |
|
220 | + return round($dist*1.609344*1000); |
|
221 | 221 | } elseif ($unit == "mile" || $unit == "mi") { |
222 | 222 | return round($dist); |
223 | 223 | } elseif ($unit == "nm") { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param float $distance distance covered |
234 | 234 | * @return whether distance is realistic |
235 | 235 | */ |
236 | - public function withinThreshold ($timeDifference, $distance) { |
|
236 | + public function withinThreshold($timeDifference, $distance) { |
|
237 | 237 | $x = abs($timeDifference); |
238 | 238 | $d = abs($distance); |
239 | 239 | if ($x == 0 || $d == 0) return true; |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | return ($array !== array_values($array)); |
250 | 250 | } |
251 | 251 | |
252 | - public function isInteger($input){ |
|
252 | + public function isInteger($input) { |
|
253 | 253 | return(ctype_digit(strval($input))); |
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | - public function convertDec($dms,$latlong) { |
|
257 | + public function convertDec($dms, $latlong) { |
|
258 | 258 | if ($latlong == 'latitude') { |
259 | 259 | $deg = substr($dms, 0, 2); |
260 | 260 | $min = substr($dms, 2, 4); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | $deg = substr($dms, 0, 3); |
263 | 263 | $min = substr($dms, 3, 5); |
264 | 264 | } |
265 | - return $deg+(($min*60)/3600); |
|
265 | + return $deg + (($min*60)/3600); |
|
266 | 266 | } |
267 | 267 | |
268 | - public function convertDM($coord,$latlong) { |
|
268 | + public function convertDM($coord, $latlong) { |
|
269 | 269 | if ($latlong == 'latitude') { |
270 | 270 | if ($coord < 0) $NSEW = 'S'; |
271 | 271 | else $NSEW = 'N'; |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | } |
276 | 276 | $coord = abs($coord); |
277 | 277 | $deg = floor($coord); |
278 | - $coord = ($coord-$deg)*60; |
|
278 | + $coord = ($coord - $deg)*60; |
|
279 | 279 | $min = $coord; |
280 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
280 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | public function xcopy($source, $dest) |
290 | 290 | { |
291 | 291 | $files = glob($source.'*.*'); |
292 | - foreach($files as $file){ |
|
293 | - $file_to_go = str_replace($source,$dest,$file); |
|
292 | + foreach ($files as $file) { |
|
293 | + $file_to_go = str_replace($source, $dest, $file); |
|
294 | 294 | copy($file, $file_to_go); |
295 | 295 | } |
296 | 296 | return true; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @param String $url url to check |
302 | 302 | * @return bool Return true on succes false on failure |
303 | 303 | */ |
304 | - public function urlexist($url){ |
|
305 | - $headers=get_headers($url); |
|
306 | - return stripos($headers[0],"200 OK")?true:false; |
|
304 | + public function urlexist($url) { |
|
305 | + $headers = get_headers($url); |
|
306 | + return stripos($headers[0], "200 OK") ? true : false; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | public function hex2str($hex) { |
315 | 315 | $str = ''; |
316 | 316 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
317 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
318 | 318 | return $str; |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return String Return result |
325 | 325 | */ |
326 | 326 | public function hex2rgb($hex) { |
327 | - $hex = str_replace('#','',$hex); |
|
327 | + $hex = str_replace('#', '', $hex); |
|
328 | 328 | return sscanf($hex, "%02x%02x%02x"); |
329 | 329 | } |
330 | 330 | |
@@ -332,33 +332,33 @@ discard block |
||
332 | 332 | //difference in longitudinal coordinates |
333 | 333 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
334 | 334 | //difference in the phi of latitudinal coordinates |
335 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
335 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
336 | 336 | //we need to recalculate $dLon if it is greater than pi |
337 | - if(abs($dLon) > pi()) { |
|
338 | - if($dLon > 0) { |
|
339 | - $dLon = (2 * pi() - $dLon) * -1; |
|
337 | + if (abs($dLon) > pi()) { |
|
338 | + if ($dLon > 0) { |
|
339 | + $dLon = (2*pi() - $dLon)*-1; |
|
340 | 340 | } else { |
341 | - $dLon = 2 * pi() + $dLon; |
|
341 | + $dLon = 2*pi() + $dLon; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | //return the angle, normalized |
345 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
345 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
346 | 346 | } |
347 | 347 | |
348 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
348 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
349 | 349 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
350 | - $a = -($lon2-$lon1); |
|
350 | + $a = -($lon2 - $lon1); |
|
351 | 351 | $b = $lat2 - $lat1; |
352 | - $c = -($a*$lat1+$b*$lon1); |
|
353 | - $d = $a*$lat3+$b*$lon3+$c; |
|
352 | + $c = -($a*$lat1 + $b*$lon1); |
|
353 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
354 | 354 | if ($d > -$approx && $d < $approx) return true; |
355 | 355 | else return false; |
356 | 356 | } |
357 | 357 | |
358 | 358 | public function array_merge_noappend() { |
359 | 359 | $output = array(); |
360 | - foreach(func_get_args() as $array) { |
|
361 | - foreach($array as $key => $value) { |
|
360 | + foreach (func_get_args() as $array) { |
|
361 | + foreach ($array as $key => $value) { |
|
362 | 362 | $output[$key] = isset($output[$key]) ? |
363 | 363 | array_merge($output[$key], $value) : $value; |
364 | 364 | } |
@@ -422,34 +422,34 @@ discard block |
||
422 | 422 | return $result; |
423 | 423 | } |
424 | 424 | |
425 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
425 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
426 | 426 | global $globalMapRefresh; |
427 | 427 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
428 | 428 | $r = 6378; |
429 | 429 | $latitude = deg2rad($latitude); |
430 | 430 | $longitude = deg2rad($longitude); |
431 | 431 | $bearing = deg2rad($heading); |
432 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
433 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
434 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
432 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
433 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
434 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
435 | 435 | } |
436 | 436 | |
437 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
437 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
438 | 438 | // distance in meter |
439 | 439 | $R = 6378.14; |
440 | - $latitude1 = $latitude * (M_PI/180); |
|
441 | - $longitude1 = $longitude * (M_PI/180); |
|
442 | - $brng = $bearing * (M_PI/180); |
|
440 | + $latitude1 = $latitude*(M_PI/180); |
|
441 | + $longitude1 = $longitude*(M_PI/180); |
|
442 | + $brng = $bearing*(M_PI/180); |
|
443 | 443 | $d = $distance; |
444 | 444 | |
445 | 445 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
446 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
446 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
447 | 447 | |
448 | - $latitude2 = $latitude2 * (180/M_PI); |
|
449 | - $longitude2 = $longitude2 * (180/M_PI); |
|
448 | + $latitude2 = $latitude2*(180/M_PI); |
|
449 | + $longitude2 = $longitude2*(180/M_PI); |
|
450 | 450 | |
451 | - $flat = round ($latitude2,6); |
|
452 | - $flong = round ($longitude2,6); |
|
451 | + $flat = round($latitude2, 6); |
|
452 | + $flong = round($longitude2, 6); |
|
453 | 453 | /* |
454 | 454 | $dx = $distance*cos($bearing); |
455 | 455 | $dy = $distance*sin($bearing); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $flong = $longitude + $dlong; |
459 | 459 | $flat = $latitude + $dlat; |
460 | 460 | */ |
461 | - return array('latitude' => $flat,'longitude' => $flong); |
|
461 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -472,14 +472,14 @@ discard block |
||
472 | 472 | * @param integer $level GZIP compression level (default: 9) |
473 | 473 | * @return string New filename (with .gz appended) if success, or false if operation fails |
474 | 474 | */ |
475 | - public function gzCompressFile($source, $level = 9){ |
|
476 | - $dest = $source . '.gz'; |
|
477 | - $mode = 'wb' . $level; |
|
475 | + public function gzCompressFile($source, $level = 9) { |
|
476 | + $dest = $source.'.gz'; |
|
477 | + $mode = 'wb'.$level; |
|
478 | 478 | $error = false; |
479 | 479 | if ($fp_out = gzopen($dest, $mode)) { |
480 | - if ($fp_in = fopen($source,'rb')) { |
|
480 | + if ($fp_in = fopen($source, 'rb')) { |
|
481 | 481 | while (!feof($fp_in)) |
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
482 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
483 | 483 | fclose($fp_in); |
484 | 484 | } else { |
485 | 485 | $error = true; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | } |
496 | 496 | |
497 | 497 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
498 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
499 | 499 | $chars = array( |
500 | 500 | // Decompositions for Latin-1 Supplement |
501 | 501 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
553 | 553 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
554 | 554 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
555 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
555 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
556 | 556 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
557 | 557 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
558 | 558 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -568,13 +568,13 @@ discard block |
||
568 | 568 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
569 | 569 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
570 | 570 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
571 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
572 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
573 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
574 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
575 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
576 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
577 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
571 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
572 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
573 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
574 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
575 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
576 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
577 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
578 | 578 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
579 | 579 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
580 | 580 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
609 | 609 | if (is_numeric($string[$i]) && $concat_flag) { |
610 | 610 | $int .= $string[$i]; |
611 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
611 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
612 | 612 | $concat_flag = false; |
613 | 613 | } |
614 | 614 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | require_once(dirname(__FILE__).'/class.create_db.php'); |
11 | 11 | require_once(dirname(__FILE__).'/class.update_schema.php'); |
12 | 12 | require_once(dirname(__FILE__).'/class.settings.php'); |
13 | -$title="Install"; |
|
13 | +$title = "Install"; |
|
14 | 14 | require(dirname(__FILE__).'/../require/settings.php'); |
15 | 15 | require(dirname(__FILE__).'/header.php'); |
16 | 16 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | if (!extension_loaded('curl')) { |
70 | 70 | $error[] = "Curl is not loaded."; |
71 | 71 | } |
72 | -if(function_exists('apache_get_modules') ){ |
|
73 | - if(!in_array('mod_rewrite',apache_get_modules())) { |
|
72 | +if (function_exists('apache_get_modules')) { |
|
73 | + if (!in_array('mod_rewrite', apache_get_modules())) { |
|
74 | 74 | $error[] = "mod_rewrite is not available."; |
75 | 75 | } |
76 | 76 | /* |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>'; |
87 | 87 | if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) { |
88 | 88 | if (function_exists('get_headers')) { |
89 | - $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"]))); |
|
90 | - if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) { |
|
89 | + $check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"]))); |
|
90 | + if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) { |
|
91 | 91 | print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>'; |
92 | 92 | } |
93 | 93 | } |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'], FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | 460 | } else { |
461 | - $hostport = explode(':',$source['host']); |
|
461 | + $hostport = explode(':', $source['host']); |
|
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
464 | 464 | $port = $hostport[1]; |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | <select name="timezone[]" id="timezone"> |
504 | 504 | <?php |
505 | 505 | $timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL); |
506 | - foreach($timezonelist as $timezone){ |
|
506 | + foreach ($timezonelist as $timezone) { |
|
507 | 507 | if (isset($source['timezone']) && $source['timezone'] == $timezone) { |
508 | 508 | print '<option selected>'.$timezone.'</option>'; |
509 | 509 | } elseif (!isset($source['timezone']) && $timezone == 'UTC') { |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | <select name="timezone[]" id="timezone"> |
554 | 554 | <?php |
555 | 555 | $timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL); |
556 | - foreach($timezonelist as $timezone){ |
|
556 | + foreach ($timezonelist as $timezone) { |
|
557 | 557 | if ($timezone == 'UTC') { |
558 | 558 | print '<option selected>'.$timezone.'</option>'; |
559 | 559 | } else print '<option>'.$timezone.'</option>'; |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | <br /> |
866 | 866 | <p> |
867 | 867 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
868 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
868 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" /> |
|
869 | 869 | </p> |
870 | 870 | <br /> |
871 | 871 | <p> |
@@ -921,14 +921,14 @@ discard block |
||
921 | 921 | $error = ''; |
922 | 922 | |
923 | 923 | if (isset($_POST['dbtype'])) { |
924 | - $dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING); |
|
925 | - $dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING); |
|
926 | - $dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING); |
|
927 | - $dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING); |
|
928 | - $dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING); |
|
929 | - $dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING); |
|
930 | - $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
|
931 | - $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
|
924 | + $dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING); |
|
925 | + $dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING); |
|
926 | + $dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING); |
|
927 | + $dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING); |
|
928 | + $dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING); |
|
929 | + $dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING); |
|
930 | + $dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING); |
|
931 | + $dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING); |
|
932 | 932 | |
933 | 933 | if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
934 | 934 | if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
@@ -948,49 +948,49 @@ discard block |
||
948 | 948 | } else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
949 | 949 | */ |
950 | 950 | |
951 | - $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
|
951 | + $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname)); |
|
952 | 952 | |
953 | - $sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING); |
|
954 | - $siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING); |
|
955 | - $timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING); |
|
956 | - $language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING); |
|
957 | - $settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language)); |
|
953 | + $sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING); |
|
954 | + $siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING); |
|
955 | + $timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING); |
|
956 | + $language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING); |
|
957 | + $settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language)); |
|
958 | 958 | |
959 | - $mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING); |
|
960 | - $mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING); |
|
961 | - $mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING); |
|
962 | - $googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING); |
|
963 | - $bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING); |
|
964 | - $openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING); |
|
965 | - $mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING); |
|
966 | - $hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING); |
|
967 | - $hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING); |
|
968 | - $settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey)); |
|
959 | + $mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING); |
|
960 | + $mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING); |
|
961 | + $mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING); |
|
962 | + $googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING); |
|
963 | + $bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING); |
|
964 | + $openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING); |
|
965 | + $mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING); |
|
966 | + $hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING); |
|
967 | + $hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING); |
|
968 | + $settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey)); |
|
969 | 969 | |
970 | - $latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING); |
|
971 | - $latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING); |
|
972 | - $longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING); |
|
973 | - $longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING); |
|
974 | - $livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT); |
|
975 | - $settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom)); |
|
970 | + $latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING); |
|
971 | + $latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING); |
|
972 | + $longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING); |
|
973 | + $longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING); |
|
974 | + $livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT); |
|
975 | + $settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom)); |
|
976 | 976 | |
977 | - $squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING); |
|
978 | - $settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country)); |
|
977 | + $squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING); |
|
978 | + $settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country)); |
|
979 | 979 | |
980 | - $latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING); |
|
981 | - $longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING); |
|
982 | - $settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter)); |
|
980 | + $latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING); |
|
981 | + $longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING); |
|
982 | + $settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter)); |
|
983 | 983 | |
984 | - $acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING); |
|
984 | + $acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING); |
|
985 | 985 | if ($acars == 'acars') { |
986 | - $settings = array_merge($settings,array('globalACARS' => 'TRUE')); |
|
986 | + $settings = array_merge($settings, array('globalACARS' => 'TRUE')); |
|
987 | 987 | } else { |
988 | - $settings = array_merge($settings,array('globalACARS' => 'FALSE')); |
|
988 | + $settings = array_merge($settings, array('globalACARS' => 'FALSE')); |
|
989 | 989 | } |
990 | 990 | |
991 | - $flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING); |
|
992 | - $flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING); |
|
993 | - $settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword)); |
|
991 | + $flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING); |
|
992 | + $flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING); |
|
993 | + $settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword)); |
|
994 | 994 | |
995 | 995 | $source_name = $_POST['source_name']; |
996 | 996 | $source_latitude = $_POST['source_latitude']; |
@@ -1004,8 +1004,8 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | $sources = array(); |
1006 | 1006 | foreach ($source_name as $keys => $name) { |
1007 | - 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]); |
|
1008 | - 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]); |
|
1007 | + 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]); |
|
1008 | + 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]); |
|
1009 | 1009 | } |
1010 | 1010 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1011 | 1011 | |
@@ -1018,24 +1018,24 @@ discard block |
||
1018 | 1018 | $sbsurl = $_POST['sbsurl']; |
1019 | 1019 | */ |
1020 | 1020 | |
1021 | - $globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING); |
|
1022 | - $globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING); |
|
1023 | - $globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING); |
|
1024 | - $globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING); |
|
1025 | - $globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING); |
|
1026 | - $globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING); |
|
1027 | - $globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING); |
|
1028 | - $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
|
1021 | + $globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING); |
|
1022 | + $globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING); |
|
1023 | + $globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING); |
|
1024 | + $globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING); |
|
1025 | + $globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING); |
|
1026 | + $globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING); |
|
1027 | + $globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING); |
|
1028 | + $datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING); |
|
1029 | 1029 | |
1030 | - $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
|
1031 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1032 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1033 | - $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
|
1034 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1035 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1036 | - $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
|
1037 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1038 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1030 | + $globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING); |
|
1031 | + if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE')); |
|
1032 | + else $settings = array_merge($settings, array('globalAircraft' => 'FALSE')); |
|
1033 | + $globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING); |
|
1034 | + if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE')); |
|
1035 | + else $settings = array_merge($settings, array('globalTracker' => 'FALSE')); |
|
1036 | + $globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING); |
|
1037 | + if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE')); |
|
1038 | + else $settings = array_merge($settings, array('globalMarine' => 'FALSE')); |
|
1039 | 1039 | |
1040 | 1040 | /* |
1041 | 1041 | $globalSBS1Hosts = array(); |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | } |
1052 | 1052 | $settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts)); |
1053 | 1053 | */ |
1054 | - $settings_comment = array_merge($settings_comment,array('globalSBS1Hosts')); |
|
1054 | + $settings_comment = array_merge($settings_comment, array('globalSBS1Hosts')); |
|
1055 | 1055 | $host = $_POST['host']; |
1056 | 1056 | $port = $_POST['port']; |
1057 | 1057 | $name = $_POST['name']; |
@@ -1068,100 +1068,100 @@ discard block |
||
1068 | 1068 | else $cov = 'FALSE'; |
1069 | 1069 | if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
1070 | 1070 | else $arch = 'FALSE'; |
1071 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezone[$key]); |
|
1071 | + if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezone[$key]); |
|
1072 | 1072 | if ($format[$key] == 'airwhere') $forcepilots = true; |
1073 | 1073 | } |
1074 | - $settings = array_merge($settings,array('globalSources' => $gSources)); |
|
1074 | + $settings = array_merge($settings, array('globalSources' => $gSources)); |
|
1075 | 1075 | |
1076 | 1076 | /* |
1077 | 1077 | $sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT); |
1078 | 1078 | $settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout)); |
1079 | 1079 | */ |
1080 | - $acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING); |
|
1081 | - $acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT); |
|
1082 | - $settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport)); |
|
1080 | + $acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING); |
|
1081 | + $acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT); |
|
1082 | + $settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport)); |
|
1083 | 1083 | |
1084 | - $bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING); |
|
1085 | - $settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly)); |
|
1084 | + $bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING); |
|
1085 | + $settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly)); |
|
1086 | 1086 | |
1087 | - $customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING); |
|
1088 | - $settings = array_merge($settings,array('globalCustomCSS' => $customcss)); |
|
1087 | + $customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING); |
|
1088 | + $settings = array_merge($settings, array('globalCustomCSS' => $customcss)); |
|
1089 | 1089 | |
1090 | - $notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING); |
|
1091 | - $settings = array_merge($settings,array('globalNOTAMSource' => $notamsource)); |
|
1092 | - $metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING); |
|
1093 | - $settings = array_merge($settings,array('globalMETARurl' => $metarsource)); |
|
1090 | + $notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING); |
|
1091 | + $settings = array_merge($settings, array('globalNOTAMSource' => $notamsource)); |
|
1092 | + $metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING); |
|
1093 | + $settings = array_merge($settings, array('globalMETARurl' => $metarsource)); |
|
1094 | 1094 | |
1095 | - $zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING); |
|
1096 | - $zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING); |
|
1097 | - $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
|
1095 | + $zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING); |
|
1096 | + $zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING); |
|
1097 | + $zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT); |
|
1098 | 1098 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1099 | - $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
|
1100 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1099 | + $settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance))); |
|
1100 | + } else $settings = array_merge($settings, array('globalDistanceIgnore' => array())); |
|
1101 | 1101 | |
1102 | - $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
|
1103 | - $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
|
1104 | - $maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT); |
|
1105 | - $settings = array_merge($settings,array('globalMapRefresh' => $maprefresh)); |
|
1106 | - $mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT); |
|
1107 | - $settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle)); |
|
1108 | - $closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT); |
|
1109 | - $settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist)); |
|
1102 | + $refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT); |
|
1103 | + $settings = array_merge($settings, array('globalLiveInterval' => $refresh)); |
|
1104 | + $maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT); |
|
1105 | + $settings = array_merge($settings, array('globalMapRefresh' => $maprefresh)); |
|
1106 | + $mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT); |
|
1107 | + $settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle)); |
|
1108 | + $closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT); |
|
1109 | + $settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist)); |
|
1110 | 1110 | |
1111 | - $aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT); |
|
1112 | - $settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize)); |
|
1111 | + $aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT); |
|
1112 | + $settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize)); |
|
1113 | 1113 | |
1114 | - $archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT); |
|
1115 | - $settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths)); |
|
1114 | + $archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT); |
|
1115 | + $settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths)); |
|
1116 | 1116 | |
1117 | - $archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING); |
|
1117 | + $archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING); |
|
1118 | 1118 | if ($archiveyear == "archiveyear") { |
1119 | - $settings = array_merge($settings,array('globalArchiveYear' => 'TRUE')); |
|
1119 | + $settings = array_merge($settings, array('globalArchiveYear' => 'TRUE')); |
|
1120 | 1120 | } else { |
1121 | - $settings = array_merge($settings,array('globalArchiveYear' => 'FALSE')); |
|
1121 | + $settings = array_merge($settings, array('globalArchiveYear' => 'FALSE')); |
|
1122 | 1122 | } |
1123 | - $archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1124 | - $settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1125 | - $archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1126 | - $settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1123 | + $archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1124 | + $settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1125 | + $archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1126 | + $settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1127 | 1127 | |
1128 | - $britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING); |
|
1129 | - $settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways)); |
|
1130 | - $transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING); |
|
1131 | - $settings = array_merge($settings,array('globalTransaviaKey' => $transavia)); |
|
1128 | + $britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING); |
|
1129 | + $settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways)); |
|
1130 | + $transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING); |
|
1131 | + $settings = array_merge($settings, array('globalTransaviaKey' => $transavia)); |
|
1132 | 1132 | |
1133 | - $lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING); |
|
1134 | - $lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING); |
|
1135 | - $settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret))); |
|
1133 | + $lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING); |
|
1134 | + $lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING); |
|
1135 | + $settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret))); |
|
1136 | 1136 | |
1137 | 1137 | // Create in settings.php keys not yet configurable if not already here |
1138 | 1138 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1139 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1139 | + if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE')); |
|
1140 | 1140 | |
1141 | - $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
|
1141 | + $resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING); |
|
1142 | 1142 | if ($resetyearstats == 'resetyearstats') { |
1143 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE')); |
|
1143 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE')); |
|
1144 | 1144 | } else { |
1145 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE')); |
|
1145 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE')); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | - $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
|
1148 | + $archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING); |
|
1149 | 1149 | if ($archive == 'archive') { |
1150 | - $settings = array_merge($settings,array('globalArchive' => 'TRUE')); |
|
1150 | + $settings = array_merge($settings, array('globalArchive' => 'TRUE')); |
|
1151 | 1151 | } else { |
1152 | - $settings = array_merge($settings,array('globalArchive' => 'FALSE')); |
|
1152 | + $settings = array_merge($settings, array('globalArchive' => 'FALSE')); |
|
1153 | 1153 | } |
1154 | - $daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING); |
|
1154 | + $daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING); |
|
1155 | 1155 | if ($daemon == 'daemon') { |
1156 | - $settings = array_merge($settings,array('globalDaemon' => 'TRUE')); |
|
1156 | + $settings = array_merge($settings, array('globalDaemon' => 'TRUE')); |
|
1157 | 1157 | } else { |
1158 | - $settings = array_merge($settings,array('globalDaemon' => 'FALSE')); |
|
1158 | + $settings = array_merge($settings, array('globalDaemon' => 'FALSE')); |
|
1159 | 1159 | } |
1160 | - $schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING); |
|
1160 | + $schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING); |
|
1161 | 1161 | if ($schedules == 'schedules') { |
1162 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE')); |
|
1162 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE')); |
|
1163 | 1163 | } else { |
1164 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE')); |
|
1164 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE')); |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | /* |
@@ -1172,227 +1172,227 @@ discard block |
||
1172 | 1172 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE')); |
1173 | 1173 | } |
1174 | 1174 | */ |
1175 | - $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
|
1176 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1177 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1178 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1179 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1175 | + $settings = array_merge($settings, array('globalFlightAware' => 'FALSE')); |
|
1176 | + if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE')); |
|
1177 | + else $settings = array_merge($settings, array('globalSBS1' => 'FALSE')); |
|
1178 | + if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE')); |
|
1179 | + else $settings = array_merge($settings, array('globalAPRS' => 'FALSE')); |
|
1180 | 1180 | $va = false; |
1181 | 1181 | if ($globalivao == 'ivao') { |
1182 | - $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
|
1182 | + $settings = array_merge($settings, array('globalIVAO' => 'TRUE')); |
|
1183 | 1183 | $va = true; |
1184 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1184 | + } else $settings = array_merge($settings, array('globalIVAO' => 'FALSE')); |
|
1185 | 1185 | if ($globalvatsim == 'vatsim') { |
1186 | - $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
|
1186 | + $settings = array_merge($settings, array('globalVATSIM' => 'TRUE')); |
|
1187 | 1187 | $va = true; |
1188 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1188 | + } else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE')); |
|
1189 | 1189 | if ($globalphpvms == 'phpvms') { |
1190 | - $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
|
1190 | + $settings = array_merge($settings, array('globalphpVMS' => 'TRUE')); |
|
1191 | 1191 | $va = true; |
1192 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1192 | + } else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE')); |
|
1193 | 1193 | if ($globalvam == 'vam') { |
1194 | - $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
|
1194 | + $settings = array_merge($settings, array('globalVAM' => 'TRUE')); |
|
1195 | 1195 | $va = true; |
1196 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1196 | + } else $settings = array_merge($settings, array('globalVAM' => 'FALSE')); |
|
1197 | 1197 | if ($va) { |
1198 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
|
1199 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1198 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE')); |
|
1199 | + } else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE')); |
|
1200 | 1200 | if ($globalva == 'va' || $va) { |
1201 | - $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
|
1202 | - $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1201 | + $settings = array_merge($settings, array('globalVA' => 'TRUE')); |
|
1202 | + $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE')); |
|
1203 | 1203 | } else { |
1204 | - $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
|
1205 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1206 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1204 | + $settings = array_merge($settings, array('globalVA' => 'FALSE')); |
|
1205 | + if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE')); |
|
1206 | + else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE')); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | 1210 | |
1211 | - $notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING); |
|
1211 | + $notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING); |
|
1212 | 1212 | if ($notam == 'notam') { |
1213 | - $settings = array_merge($settings,array('globalNOTAM' => 'TRUE')); |
|
1213 | + $settings = array_merge($settings, array('globalNOTAM' => 'TRUE')); |
|
1214 | 1214 | } else { |
1215 | - $settings = array_merge($settings,array('globalNOTAM' => 'FALSE')); |
|
1215 | + $settings = array_merge($settings, array('globalNOTAM' => 'FALSE')); |
|
1216 | 1216 | } |
1217 | - $owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING); |
|
1217 | + $owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING); |
|
1218 | 1218 | if ($owner == 'owner') { |
1219 | - $settings = array_merge($settings,array('globalOwner' => 'TRUE')); |
|
1219 | + $settings = array_merge($settings, array('globalOwner' => 'TRUE')); |
|
1220 | 1220 | } else { |
1221 | - $settings = array_merge($settings,array('globalOwner' => 'FALSE')); |
|
1221 | + $settings = array_merge($settings, array('globalOwner' => 'FALSE')); |
|
1222 | 1222 | } |
1223 | - $map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING); |
|
1223 | + $map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING); |
|
1224 | 1224 | if ($map3d == 'map3d') { |
1225 | - $settings = array_merge($settings,array('globalMap3D' => 'TRUE')); |
|
1225 | + $settings = array_merge($settings, array('globalMap3D' => 'TRUE')); |
|
1226 | 1226 | } else { |
1227 | - $settings = array_merge($settings,array('globalMap3D' => 'FALSE')); |
|
1227 | + $settings = array_merge($settings, array('globalMap3D' => 'FALSE')); |
|
1228 | 1228 | } |
1229 | - $crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING); |
|
1229 | + $crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING); |
|
1230 | 1230 | if ($crash == 'crash') { |
1231 | - $settings = array_merge($settings,array('globalAccidents' => 'TRUE')); |
|
1231 | + $settings = array_merge($settings, array('globalAccidents' => 'TRUE')); |
|
1232 | 1232 | } else { |
1233 | - $settings = array_merge($settings,array('globalAccidents' => 'FALSE')); |
|
1233 | + $settings = array_merge($settings, array('globalAccidents' => 'FALSE')); |
|
1234 | 1234 | } |
1235 | - $mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING); |
|
1235 | + $mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING); |
|
1236 | 1236 | if ($mapsatellites == 'mapsatellites') { |
1237 | - $settings = array_merge($settings,array('globalMapSatellites' => 'TRUE')); |
|
1237 | + $settings = array_merge($settings, array('globalMapSatellites' => 'TRUE')); |
|
1238 | 1238 | } else { |
1239 | - $settings = array_merge($settings,array('globalMapSatellites' => 'FALSE')); |
|
1239 | + $settings = array_merge($settings, array('globalMapSatellites' => 'FALSE')); |
|
1240 | 1240 | } |
1241 | - $map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING); |
|
1241 | + $map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING); |
|
1242 | 1242 | if ($map3ddefault == 'map3ddefault') { |
1243 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE')); |
|
1243 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE')); |
|
1244 | 1244 | } else { |
1245 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE')); |
|
1245 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE')); |
|
1246 | 1246 | } |
1247 | - $translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING); |
|
1247 | + $translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING); |
|
1248 | 1248 | if ($translate == 'translate') { |
1249 | - $settings = array_merge($settings,array('globalTranslate' => 'TRUE')); |
|
1249 | + $settings = array_merge($settings, array('globalTranslate' => 'TRUE')); |
|
1250 | 1250 | } else { |
1251 | - $settings = array_merge($settings,array('globalTranslate' => 'FALSE')); |
|
1251 | + $settings = array_merge($settings, array('globalTranslate' => 'FALSE')); |
|
1252 | 1252 | } |
1253 | - $realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING); |
|
1253 | + $realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING); |
|
1254 | 1254 | if ($realairlines == 'realairlines') { |
1255 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE')); |
|
1255 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE')); |
|
1256 | 1256 | } else { |
1257 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE')); |
|
1257 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE')); |
|
1258 | 1258 | } |
1259 | - $estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING); |
|
1259 | + $estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING); |
|
1260 | 1260 | if ($estimation == 'estimation') { |
1261 | - $settings = array_merge($settings,array('globalMapEstimation' => 'TRUE')); |
|
1261 | + $settings = array_merge($settings, array('globalMapEstimation' => 'TRUE')); |
|
1262 | 1262 | } else { |
1263 | - $settings = array_merge($settings,array('globalMapEstimation' => 'FALSE')); |
|
1263 | + $settings = array_merge($settings, array('globalMapEstimation' => 'FALSE')); |
|
1264 | 1264 | } |
1265 | - $metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING); |
|
1265 | + $metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING); |
|
1266 | 1266 | if ($metar == 'metar') { |
1267 | - $settings = array_merge($settings,array('globalMETAR' => 'TRUE')); |
|
1267 | + $settings = array_merge($settings, array('globalMETAR' => 'TRUE')); |
|
1268 | 1268 | } else { |
1269 | - $settings = array_merge($settings,array('globalMETAR' => 'FALSE')); |
|
1269 | + $settings = array_merge($settings, array('globalMETAR' => 'FALSE')); |
|
1270 | 1270 | } |
1271 | - $metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING); |
|
1271 | + $metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING); |
|
1272 | 1272 | if ($metarcycle == 'metarcycle') { |
1273 | - $settings = array_merge($settings,array('globalMETARcycle' => 'TRUE')); |
|
1273 | + $settings = array_merge($settings, array('globalMETARcycle' => 'TRUE')); |
|
1274 | 1274 | } else { |
1275 | - $settings = array_merge($settings,array('globalMETARcycle' => 'FALSE')); |
|
1275 | + $settings = array_merge($settings, array('globalMETARcycle' => 'FALSE')); |
|
1276 | 1276 | } |
1277 | - $fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING); |
|
1277 | + $fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING); |
|
1278 | 1278 | if ($fork == 'fork') { |
1279 | - $settings = array_merge($settings,array('globalFork' => 'TRUE')); |
|
1279 | + $settings = array_merge($settings, array('globalFork' => 'TRUE')); |
|
1280 | 1280 | } else { |
1281 | - $settings = array_merge($settings,array('globalFork' => 'FALSE')); |
|
1281 | + $settings = array_merge($settings, array('globalFork' => 'FALSE')); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING); |
|
1284 | + $colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING); |
|
1285 | 1285 | if ($colormap == 'colormap') { |
1286 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE')); |
|
1286 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE')); |
|
1287 | 1287 | } else { |
1288 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE')); |
|
1288 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE')); |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | if (isset($_POST['aircrafticoncolor'])) { |
1292 | - $aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING); |
|
1293 | - $settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1))); |
|
1292 | + $aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING); |
|
1293 | + $settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1))); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | - $airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT); |
|
1297 | - $settings = array_merge($settings,array('globalAirportZoom' => $airportzoom)); |
|
1296 | + $airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT); |
|
1297 | + $settings = array_merge($settings, array('globalAirportZoom' => $airportzoom)); |
|
1298 | 1298 | |
1299 | - $unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING); |
|
1300 | - $settings = array_merge($settings,array('globalUnitDistance' => $unitdistance)); |
|
1301 | - $unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING); |
|
1302 | - $settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude)); |
|
1303 | - $unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING); |
|
1304 | - $settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed)); |
|
1299 | + $unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING); |
|
1300 | + $settings = array_merge($settings, array('globalUnitDistance' => $unitdistance)); |
|
1301 | + $unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING); |
|
1302 | + $settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude)); |
|
1303 | + $unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING); |
|
1304 | + $settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed)); |
|
1305 | 1305 | |
1306 | - $mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING); |
|
1306 | + $mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING); |
|
1307 | 1307 | if ($mappopup == 'mappopup') { |
1308 | - $settings = array_merge($settings,array('globalMapPopup' => 'TRUE')); |
|
1308 | + $settings = array_merge($settings, array('globalMapPopup' => 'TRUE')); |
|
1309 | 1309 | } else { |
1310 | - $settings = array_merge($settings,array('globalMapPopup' => 'FALSE')); |
|
1310 | + $settings = array_merge($settings, array('globalMapPopup' => 'FALSE')); |
|
1311 | 1311 | } |
1312 | - $airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING); |
|
1312 | + $airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING); |
|
1313 | 1313 | if ($airportpopup == 'airportpopup') { |
1314 | - $settings = array_merge($settings,array('globalAirportPopup' => 'TRUE')); |
|
1314 | + $settings = array_merge($settings, array('globalAirportPopup' => 'TRUE')); |
|
1315 | 1315 | } else { |
1316 | - $settings = array_merge($settings,array('globalAirportPopup' => 'FALSE')); |
|
1316 | + $settings = array_merge($settings, array('globalAirportPopup' => 'FALSE')); |
|
1317 | 1317 | } |
1318 | - $maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING); |
|
1318 | + $maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING); |
|
1319 | 1319 | if ($maphistory == 'maphistory') { |
1320 | - $settings = array_merge($settings,array('globalMapHistory' => 'TRUE')); |
|
1320 | + $settings = array_merge($settings, array('globalMapHistory' => 'TRUE')); |
|
1321 | 1321 | } else { |
1322 | - $settings = array_merge($settings,array('globalMapHistory' => 'FALSE')); |
|
1322 | + $settings = array_merge($settings, array('globalMapHistory' => 'FALSE')); |
|
1323 | 1323 | } |
1324 | - $maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING); |
|
1324 | + $maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING); |
|
1325 | 1325 | if ($maptooltip == 'maptooltip') { |
1326 | - $settings = array_merge($settings,array('globalMapTooltip' => 'TRUE')); |
|
1326 | + $settings = array_merge($settings, array('globalMapTooltip' => 'TRUE')); |
|
1327 | 1327 | } else { |
1328 | - $settings = array_merge($settings,array('globalMapTooltip' => 'FALSE')); |
|
1328 | + $settings = array_merge($settings, array('globalMapTooltip' => 'FALSE')); |
|
1329 | 1329 | } |
1330 | - $flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING); |
|
1330 | + $flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING); |
|
1331 | 1331 | if ($flightroute == 'flightroute') { |
1332 | - $settings = array_merge($settings,array('globalMapRoute' => 'TRUE')); |
|
1332 | + $settings = array_merge($settings, array('globalMapRoute' => 'TRUE')); |
|
1333 | 1333 | } else { |
1334 | - $settings = array_merge($settings,array('globalMapRoute' => 'FALSE')); |
|
1334 | + $settings = array_merge($settings, array('globalMapRoute' => 'FALSE')); |
|
1335 | 1335 | } |
1336 | - $flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING); |
|
1336 | + $flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING); |
|
1337 | 1337 | if ($flightremainingroute == 'flightremainingroute') { |
1338 | - $settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE')); |
|
1338 | + $settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE')); |
|
1339 | 1339 | } else { |
1340 | - $settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE')); |
|
1340 | + $settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE')); |
|
1341 | 1341 | } |
1342 | - $allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING); |
|
1342 | + $allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING); |
|
1343 | 1343 | if ($allflights == 'allflights') { |
1344 | - $settings = array_merge($settings,array('globalAllFlights' => 'TRUE')); |
|
1344 | + $settings = array_merge($settings, array('globalAllFlights' => 'TRUE')); |
|
1345 | 1345 | } else { |
1346 | - $settings = array_merge($settings,array('globalAllFlights' => 'FALSE')); |
|
1346 | + $settings = array_merge($settings, array('globalAllFlights' => 'FALSE')); |
|
1347 | 1347 | } |
1348 | - $bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING); |
|
1348 | + $bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING); |
|
1349 | 1349 | if ($bbox == 'bbox') { |
1350 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE')); |
|
1350 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE')); |
|
1351 | 1351 | } else { |
1352 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE')); |
|
1352 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE')); |
|
1353 | 1353 | } |
1354 | - $groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING); |
|
1354 | + $groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING); |
|
1355 | 1355 | if ($groundaltitude == 'groundaltitude') { |
1356 | - $settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE')); |
|
1356 | + $settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE')); |
|
1357 | 1357 | } else { |
1358 | - $settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE')); |
|
1358 | + $settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE')); |
|
1359 | 1359 | } |
1360 | - $waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING); |
|
1360 | + $waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING); |
|
1361 | 1361 | if ($waypoints == 'waypoints') { |
1362 | - $settings = array_merge($settings,array('globalWaypoints' => 'TRUE')); |
|
1362 | + $settings = array_merge($settings, array('globalWaypoints' => 'TRUE')); |
|
1363 | 1363 | } else { |
1364 | - $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
|
1364 | + $settings = array_merge($settings, array('globalWaypoints' => 'FALSE')); |
|
1365 | 1365 | } |
1366 | - $geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING); |
|
1366 | + $geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING); |
|
1367 | 1367 | if ($geoid == 'geoid') { |
1368 | - $settings = array_merge($settings,array('globalGeoid' => 'TRUE')); |
|
1368 | + $settings = array_merge($settings, array('globalGeoid' => 'TRUE')); |
|
1369 | 1369 | } else { |
1370 | - $settings = array_merge($settings,array('globalGeoid' => 'FALSE')); |
|
1370 | + $settings = array_merge($settings, array('globalGeoid' => 'FALSE')); |
|
1371 | 1371 | } |
1372 | - $geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING); |
|
1373 | - $settings = array_merge($settings,array('globalGeoidSource' => $geoid_source)); |
|
1372 | + $geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING); |
|
1373 | + $settings = array_merge($settings, array('globalGeoidSource' => $geoid_source)); |
|
1374 | 1374 | |
1375 | - $noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING); |
|
1375 | + $noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING); |
|
1376 | 1376 | if ($noairlines == 'noairlines') { |
1377 | - $settings = array_merge($settings,array('globalNoAirlines' => 'TRUE')); |
|
1377 | + $settings = array_merge($settings, array('globalNoAirlines' => 'TRUE')); |
|
1378 | 1378 | } else { |
1379 | - $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
|
1379 | + $settings = array_merge($settings, array('globalNoAirlines' => 'FALSE')); |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1382 | + if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE')); |
|
1383 | 1383 | |
1384 | 1384 | // Set some defaults values... |
1385 | 1385 | if (!isset($globalAircraftImageSources)) { |
1386 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1387 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1386 | + $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
1387 | + $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | if (!isset($globalSchedulesSources)) { |
1391 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1392 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1391 | + $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1392 | + $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | - $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
|
1395 | + $settings = array_merge($settings, array('globalInstalled' => 'TRUE')); |
|
1396 | 1396 | |
1397 | 1397 | if ($error == '') settings::modify_settings($settings); |
1398 | 1398 | if ($error == '') settings::comment_settings($settings_comment); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * Translated to PHP of GeographicLib/src/Geoid.cpp |
12 | 12 | * by Ycarus <[email protected]> in 2017 |
13 | 13 | */ |
14 | -class GeoidHeight { |
|
14 | +class GeoidHeight { |
|
15 | 15 | private $c0 = 240; |
16 | 16 | private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]]; |
17 | 17 | private $c0n = 372; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private $v10 = null; |
35 | 35 | private $v11 = null; |
36 | 36 | |
37 | - public function __construct($name='') { |
|
37 | + public function __construct($name = '') { |
|
38 | 38 | global $globalGeoidSource; |
39 | 39 | //if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm'; |
40 | 40 | if ($name == '') { |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | else $name = dirname(__FILE__).'/../data/egm96-15.pgm'; |
43 | 43 | } |
44 | 44 | |
45 | - $f = @fopen($name,"r"); |
|
45 | + $f = @fopen($name, "r"); |
|
46 | 46 | if ($f === FALSE) { |
47 | 47 | throw new Exception("Can't open ".$name); |
48 | 48 | } |
49 | - $line = fgets($f,4096); |
|
49 | + $line = fgets($f, 4096); |
|
50 | 50 | if (trim($line) != 'P5') { |
51 | 51 | throw new Exception('No PGM header'); |
52 | 52 | } |
53 | 53 | $headerlen = strlen($line); |
54 | 54 | while (true) { |
55 | - $line = fgets($f,4096); |
|
55 | + $line = fgets($f, 4096); |
|
56 | 56 | if ((strlen($line) == 0)) { |
57 | 57 | throw new Exception('EOF before end of file header'); |
58 | 58 | } |
59 | 59 | $headerlen += strlen($line); |
60 | - if (strpos($line,'# Offset ') !== FALSE) { |
|
60 | + if (strpos($line, '# Offset ') !== FALSE) { |
|
61 | 61 | $this->offset = substr($line, 9); |
62 | - } else if (strpos($line,'# Scale ') !== FALSE) { |
|
62 | + } else if (strpos($line, '# Scale ') !== FALSE) { |
|
63 | 63 | $this->scale = substr($line, 8); |
64 | - } else if ((strpos($line,'#') === FALSE)) { |
|
65 | - list($this->width, $this->height) = preg_split('/\s+/',$line); |
|
64 | + } else if ((strpos($line, '#') === FALSE)) { |
|
65 | + list($this->width, $this->height) = preg_split('/\s+/', $line); |
|
66 | 66 | break; |
67 | 67 | } |
68 | 68 | } |
69 | - $line = fgets($f,4096); |
|
69 | + $line = fgets($f, 4096); |
|
70 | 70 | $headerlen += strlen($line); |
71 | - $levels = (int)$line; |
|
72 | - $this->width = (int)$this->width; |
|
73 | - $this->height = (int)$this->height; |
|
71 | + $levels = (int) $line; |
|
72 | + $this->width = (int) $this->width; |
|
73 | + $this->height = (int) $this->height; |
|
74 | 74 | if (($levels != 65535)) { |
75 | 75 | throw new Exception('PGM file must have 65535 gray levels ('.$levels.')'); |
76 | 76 | } |
@@ -85,42 +85,42 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | $fullsize = filesize($name); |
88 | - if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) { |
|
88 | + if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) { |
|
89 | 89 | throw new Exception('File has the wrong length'); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $this->headerlen = $headerlen; |
93 | - $this->raw= $f; |
|
94 | - $this->rlonres = ($this->width / 360.0); |
|
95 | - $this->rlatres = (($this->height - 1) / 180.0); |
|
93 | + $this->raw = $f; |
|
94 | + $this->rlonres = ($this->width/360.0); |
|
95 | + $this->rlatres = (($this->height - 1)/180.0); |
|
96 | 96 | } |
97 | 97 | |
98 | - private function _rawval($ix,$iy) { |
|
98 | + private function _rawval($ix, $iy) { |
|
99 | 99 | if (($iy < 0)) { |
100 | 100 | $iy = -$iy; |
101 | - $ix += ($this->width / 2); |
|
101 | + $ix += ($this->width/2); |
|
102 | 102 | } else if (($iy >= $this->height)) { |
103 | - $iy = ((2 * ($this->height - 1)) - $iy); |
|
104 | - $ix += ($this->width / 2); |
|
103 | + $iy = ((2*($this->height - 1)) - $iy); |
|
104 | + $ix += ($this->width/2); |
|
105 | 105 | } |
106 | 106 | if (($ix < 0)) { |
107 | 107 | $ix += $this->width; |
108 | 108 | } else if (($ix >= $this->width)) { |
109 | 109 | $ix -= $this->width; |
110 | 110 | } |
111 | - $k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen; |
|
112 | - fseek($this->raw,$k); |
|
113 | - return unpack('n',fread($this->raw,2))[1]; |
|
111 | + $k = ((($iy*$this->width) + $ix)*2) + $this->headerlen; |
|
112 | + fseek($this->raw, $k); |
|
113 | + return unpack('n', fread($this->raw, 2))[1]; |
|
114 | 114 | } |
115 | 115 | |
116 | - public function get($lat,$lon,$cubic=true) { |
|
116 | + public function get($lat, $lon, $cubic = true) { |
|
117 | 117 | if (($lon < 0)) { |
118 | 118 | $lon += 360; |
119 | 119 | } |
120 | - $fy = ((90 - $lat) * $this->rlatres); |
|
121 | - $fx = ($lon * $this->rlonres); |
|
122 | - $iy = (int)$fy; |
|
123 | - $ix = (int)$fx; |
|
120 | + $fy = ((90 - $lat)*$this->rlatres); |
|
121 | + $fx = ($lon*$this->rlonres); |
|
122 | + $iy = (int) $fy; |
|
123 | + $ix = (int) $fx; |
|
124 | 124 | $fx -= $ix; |
125 | 125 | $fy -= $iy; |
126 | 126 | $t = array(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $c3x = $this->c3; |
148 | 148 | $c0x = $this->c0; |
149 | 149 | } |
150 | - for ($i = 0; $i < 10;++$i) { |
|
150 | + for ($i = 0; $i < 10; ++$i) { |
|
151 | 151 | $t[$i] = 0; |
152 | 152 | for ($j = 0; $j < 12; ++$j) { |
153 | 153 | $t[$i] += $v[$j]*$c3x[$j][$i]; |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | $this->t = $t; |
159 | 159 | } else $t = $this->t; |
160 | 160 | if (!($cubic)) { |
161 | - $a = (((1 - $fx) * $this->v00) + ($fx * $this->v01)); |
|
162 | - $b = (((1 - $fx) * $this->v10) + ($fx * $this->v11)); |
|
163 | - $h = (((1 - $fy) * $a) + ($fy * $b)); |
|
161 | + $a = (((1 - $fx)*$this->v00) + ($fx*$this->v01)); |
|
162 | + $b = (((1 - $fx)*$this->v10) + ($fx*$this->v11)); |
|
163 | + $h = (((1 - $fy)*$a) + ($fy*$b)); |
|
164 | 164 | } else { |
165 | - $h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9])))))); |
|
165 | + $h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9])))))); |
|
166 | 166 | } |
167 | - return ((float)$this->offset + ((float)$this->scale * (float)$h)); |
|
167 | + return ((float) $this->offset + ((float) $this->scale*(float) $h)); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | /* |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php \n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,27 +304,27 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | $Spotter = new Spotter($this->db); |
325 | 325 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
326 | 326 | $Spotter->db = null; |
327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
328 | 328 | } |
329 | 329 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
330 | 330 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $Spotter = new Spotter($this->db); |
333 | 333 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
334 | 334 | $Spotter->db = null; |
335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
335 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
341 | 341 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
342 | 342 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
343 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
344 | 344 | } |
345 | 345 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
346 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
346 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
347 | 347 | } |
348 | 348 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
349 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
349 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
350 | 350 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
352 | 352 | } else { |
353 | 353 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
354 | 354 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -359,31 +359,31 @@ discard block |
||
359 | 359 | */ |
360 | 360 | return ''; |
361 | 361 | } |
362 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
362 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
363 | 363 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
364 | 364 | return ''; |
365 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
365 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
366 | 366 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
367 | 367 | return ''; |
368 | 368 | } elseif (!isset($line['datetime'])) { |
369 | 369 | date_default_timezone_set('UTC'); |
370 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | 371 | } else { |
372 | 372 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
373 | 373 | return ''; |
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
377 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
377 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
378 | 378 | } |
379 | 379 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
380 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
380 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
381 | 381 | } |
382 | 382 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
383 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
384 | 384 | } |
385 | 385 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
386 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
386 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
392 | 392 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | 393 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
395 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
396 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
397 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
398 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
399 | 399 | } else { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
401 | 401 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
402 | 402 | $timeelapsed = microtime(true); |
403 | 403 | $Spotter = new Spotter($this->db); |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
408 | 408 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
409 | 409 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
410 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
410 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
411 | 411 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
412 | 412 | $Spotter->db = null; |
413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
413 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
414 | 414 | } |
415 | 415 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
416 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
417 | 417 | |
418 | 418 | /* |
419 | 419 | if (!isset($line['id'])) { |
@@ -423,25 +423,25 @@ discard block |
||
423 | 423 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 424 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 425 | */ |
426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
426 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | 427 | |
428 | 428 | //$putinarchive = true; |
429 | 429 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
430 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
431 | 431 | } |
432 | 432 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
433 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
434 | 434 | } |
435 | 435 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
436 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
436 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
437 | 437 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
438 | 438 | $timeelapsed = microtime(true); |
439 | 439 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
440 | 440 | $Spotter = new Spotter($this->db); |
441 | 441 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 442 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
445 | 445 | } |
446 | 446 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
447 | 447 | $timeelapsed = microtime(true); |
@@ -455,35 +455,35 @@ discard block |
||
455 | 455 | $Translation->db = null; |
456 | 456 | } |
457 | 457 | $Spotter->db = null; |
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
458 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
459 | 459 | } |
460 | 460 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | 461 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
462 | 462 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
463 | 463 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
464 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
464 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!isset($globalFork)) $globalFork = TRUE; |
468 | 468 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
469 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
475 | 475 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
476 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
476 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
478 | 478 | //$dataFound = true; |
479 | 479 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
480 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
480 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
481 | 481 | if ($distance > 1000 && $distance < 10000) { |
482 | 482 | // use datetime |
483 | 483 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
484 | 484 | $speed = $speed*3.6; |
485 | 485 | if ($speed < 1000) { |
486 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
486 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
487 | 487 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
488 | 488 | } else { |
489 | 489 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
499 | 499 | return false; |
500 | 500 | } |
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
501 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
502 | 502 | else unset($timediff); |
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
503 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
504 | 504 | else unset($timediff_archive); |
505 | 505 | if ($this->tmd > 5 |
506 | 506 | || (isset($line['format_source']) |
@@ -524,14 +524,14 @@ discard block |
||
524 | 524 | || ($timediff > 30 |
525 | 525 | && isset($this->all_flights[$id]['latitude']) |
526 | 526 | && isset($this->all_flights[$id]['longitude']) |
527 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
527 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
528 | 528 | ) |
529 | 529 | ) { |
530 | 530 | |
531 | 531 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
532 | 532 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
533 | 533 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
534 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
534 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
535 | 535 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
536 | 536 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
537 | 537 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | $timeelapsed = microtime(true); |
542 | 542 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
543 | 543 | $Spotter = new Spotter($this->db); |
544 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
544 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
545 | 545 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
546 | 546 | else $this->all_flights[$id]['over_country'] = ''; |
547 | 547 | $Spotter->db = null; |
548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
548 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
549 | 549 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
550 | 550 | } |
551 | 551 | } |
@@ -571,13 +571,13 @@ discard block |
||
571 | 571 | $this->all_flights[$id]['time_last_coord'] = time(); |
572 | 572 | } |
573 | 573 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
574 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
574 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
575 | 575 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
576 | 576 | $dataFound = true; |
577 | 577 | $this->all_flights[$id]['time_last_coord'] = time(); |
578 | 578 | } |
579 | 579 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
580 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
580 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
581 | 581 | /* |
582 | 582 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
583 | 583 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
602 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
602 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
603 | 603 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
604 | 604 | $dataFound = true; |
605 | 605 | $this->all_flights[$id]['time_last_coord'] = time(); |
606 | 606 | } |
607 | 607 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
609 | 609 | /* |
610 | 610 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
611 | 611 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -623,46 +623,46 @@ discard block |
||
623 | 623 | } else if ($globalDebug && $timediff > 30) { |
624 | 624 | $this->tmd = $this->tmd + 1; |
625 | 625 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
626 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
627 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
626 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
627 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
628 | 628 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
629 | 629 | } |
630 | 630 | } |
631 | 631 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | 632 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
633 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
634 | 634 | } |
635 | 635 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
637 | 637 | //$dataFound = true; |
638 | 638 | } |
639 | 639 | if (isset($line['format_source']) && $line['format_source'] != '') { |
640 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
640 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
641 | 641 | } |
642 | 642 | if (isset($line['source_name']) && $line['source_name'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['emergency']) && $line['emergency'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
647 | 647 | //$dataFound = true; |
648 | 648 | } |
649 | 649 | if (isset($line['ground']) && $line['ground'] != '') { |
650 | 650 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
651 | 651 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
653 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
653 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
654 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
655 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
656 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
657 | 657 | } |
658 | 658 | if ($line['ground'] != 1) $line['ground'] = 0; |
659 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
659 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
660 | 660 | //$dataFound = true; |
661 | 661 | } |
662 | 662 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | 663 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
664 | 664 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
666 | 666 | $highlight = ''; |
667 | 667 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
668 | 668 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -671,66 +671,66 @@ discard block |
||
671 | 671 | $timeelapsed = microtime(true); |
672 | 672 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | 673 | $Spotter = new Spotter($this->db); |
674 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
674 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
675 | 675 | $Spotter->db = null; |
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
676 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
677 | 677 | } |
678 | 678 | //$putinarchive = true; |
679 | 679 | //$highlight = ''; |
680 | 680 | } |
681 | 681 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
682 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
683 | 683 | //$dataFound = true; |
684 | 684 | } |
685 | 685 | |
686 | 686 | if (isset($line['altitude']) && $line['altitude'] != '') { |
687 | 687 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
688 | 688 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
689 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
689 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
690 | 690 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
691 | 691 | $line['altitude'] = $line['altitude'] + $geoid; |
692 | 692 | } |
693 | 693 | } |
694 | 694 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
695 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
696 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
698 | 698 | //$dataFound = true; |
699 | 699 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
700 | 700 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
701 | 701 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | 702 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
703 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
703 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
705 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
706 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
707 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
708 | 708 | } |
709 | 709 | } |
710 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
710 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
714 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
714 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
720 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
718 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
720 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
721 | 721 | //$dataFound = true; |
722 | 722 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
723 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
724 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
723 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
725 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | 726 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
727 | 727 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | 728 | // If not enough messages and ACARS set heading to 0 |
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
730 | 730 | } |
731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
731 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false; |
|
734 | 734 | |
735 | 735 | // print_r($this->all_flights[$id]); |
736 | 736 | //gets the callsign from the last hour |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
742 | 742 | $this->all_flights[$id]['lastupdate'] = time(); |
743 | 743 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
744 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
744 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
745 | 745 | //print_r($this->all_flights); |
746 | 746 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
747 | 747 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -752,61 +752,61 @@ discard block |
||
752 | 752 | $SpotterLive = new SpotterLive($this->db); |
753 | 753 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
754 | 754 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
755 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
756 | 756 | } elseif (isset($line['id'])) { |
757 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
758 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
759 | 759 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
760 | 760 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
761 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
762 | 762 | } else $recent_ident = ''; |
763 | - $SpotterLive->db=null; |
|
763 | + $SpotterLive->db = null; |
|
764 | 764 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
765 | 765 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
766 | 766 | } else $recent_ident = ''; |
767 | 767 | } else { |
768 | 768 | $recent_ident = ''; |
769 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
769 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
770 | 770 | } |
771 | 771 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
772 | - if($recent_ident == "") |
|
772 | + if ($recent_ident == "") |
|
773 | 773 | { |
774 | 774 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
775 | 775 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 776 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 777 | //adds the spotter data for the archive |
778 | 778 | $ignoreImport = false; |
779 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
779 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
780 | 780 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
781 | 781 | $ignoreImport = true; |
782 | 782 | } |
783 | 783 | } |
784 | 784 | if (count($globalAirportAccept) > 0) { |
785 | 785 | $ignoreImport = true; |
786 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
786 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
787 | 787 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
788 | 788 | $ignoreImport = false; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | } |
792 | 792 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
793 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
794 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
793 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
794 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
795 | 795 | $ignoreImport = true; |
796 | 796 | } |
797 | 797 | } |
798 | 798 | } |
799 | 799 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
800 | 800 | $ignoreImport = true; |
801 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
801 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
802 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
803 | 803 | $ignoreImport = false; |
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
807 | 807 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
808 | 808 | $ignoreImport = true; |
809 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
809 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | 810 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
811 | 811 | $ignoreImport = false; |
812 | 812 | } |
@@ -818,32 +818,32 @@ discard block |
||
818 | 818 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
819 | 819 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
821 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
822 | 822 | $timeelapsed = microtime(true); |
823 | 823 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
824 | 824 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | 825 | $Spotter = new Spotter($this->db); |
826 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
826 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
827 | 827 | $Spotter->db = null; |
828 | 828 | if ($globalDebug && isset($result)) echo $result."\n"; |
829 | 829 | } |
830 | 830 | } |
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
831 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
832 | 832 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
833 | 833 | |
834 | 834 | // Add source stat in DB |
835 | 835 | $Stats = new Stats($this->db); |
836 | 836 | if (!empty($this->stats)) { |
837 | 837 | if ($globalDebug) echo 'Add source stats : '; |
838 | - foreach($this->stats as $date => $data) { |
|
839 | - foreach($data as $source => $sourced) { |
|
838 | + foreach ($this->stats as $date => $data) { |
|
839 | + foreach ($data as $source => $sourced) { |
|
840 | 840 | //print_r($sourced); |
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
841 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
842 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
843 | 843 | if (isset($sourced['msg'])) { |
844 | 844 | if (time() - $sourced['msg']['date'] > 10) { |
845 | 845 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
846 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
846 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
847 | 847 | unset($this->stats[$date][$source]['msg']); |
848 | 848 | } |
849 | 849 | } |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
882 | 882 | $SpotterLive = new SpotterLive($this->db); |
883 | 883 | $SpotterLive->deleteLiveSpotterData(); |
884 | - $SpotterLive->db=null; |
|
884 | + $SpotterLive->db = null; |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | if ($globalDebug) echo " Done\n"; |
888 | 888 | $this->last_delete = time(); |
889 | 889 | } |
890 | 890 | } else { |
891 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
891 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
892 | 892 | $this->all_flights[$id]['id'] = $recent_ident; |
893 | 893 | $this->all_flights[$id]['addedSpotter'] = 1; |
894 | 894 | } |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
897 | 897 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
898 | 898 | $Spotter = new Spotter($this->db); |
899 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
899 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
900 | 900 | $Spotter->db = null; |
901 | 901 | } |
902 | 902 | } |
@@ -922,37 +922,37 @@ discard block |
||
922 | 922 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
923 | 923 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
924 | 924 | |
925 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
925 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
926 | 926 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
927 | 927 | $ignoreImport = true; |
928 | 928 | } |
929 | 929 | } |
930 | 930 | if (count($globalAirportAccept) > 0) { |
931 | 931 | $ignoreImport = true; |
932 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
932 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
933 | 933 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
934 | 934 | $ignoreImport = false; |
935 | 935 | } |
936 | 936 | } |
937 | 937 | } |
938 | 938 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
939 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
940 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
939 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
940 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
941 | 941 | $ignoreImport = true; |
942 | 942 | } |
943 | 943 | } |
944 | 944 | } |
945 | 945 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
946 | 946 | $ignoreImport = true; |
947 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
948 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
947 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
948 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
949 | 949 | $ignoreImport = false; |
950 | 950 | } |
951 | 951 | } |
952 | 952 | } |
953 | 953 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
954 | 954 | $ignoreImport = true; |
955 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
955 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
956 | 956 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
957 | 957 | $ignoreImport = false; |
958 | 958 | } |
@@ -960,23 +960,23 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | if (!$ignoreImport) { |
963 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
963 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
964 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | 965 | $timeelapsed = microtime(true); |
966 | 966 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | 967 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
968 | 968 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
969 | 969 | $SpotterLive = new SpotterLive($this->db); |
970 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
970 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
971 | 971 | $SpotterLive->db = null; |
972 | 972 | if ($globalDebug) echo $result."\n"; |
973 | 973 | } |
974 | 974 | } |
975 | 975 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
976 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
977 | 977 | } |
978 | 978 | $this->all_flights[$id]['putinarchive'] = false; |
979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
979 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
980 | 980 | |
981 | 981 | // Put statistics in $this->stats variable |
982 | 982 | //if ($line['format_source'] != 'aprs') { |
@@ -995,19 +995,19 @@ discard block |
||
995 | 995 | $latitude = $globalCenterLatitude; |
996 | 996 | $longitude = $globalCenterLongitude; |
997 | 997 | } |
998 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
998 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
999 | 999 | } else { |
1000 | 1000 | $latitude = $this->source_location[$source]['latitude']; |
1001 | 1001 | $longitude = $this->source_location[$source]['longitude']; |
1002 | 1002 | } |
1003 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1003 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1004 | 1004 | //$stats_heading = $stats_heading%22.5; |
1005 | 1005 | $stats_heading = round($stats_heading/22.5); |
1006 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1006 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1007 | 1007 | $current_date = date('Y-m-d'); |
1008 | 1008 | if ($stats_heading == 16) $stats_heading = 0; |
1009 | 1009 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | - for ($i=0;$i<=15;$i++) { |
|
1010 | + for ($i = 0; $i <= 15; $i++) { |
|
1011 | 1011 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1012 | 1012 | } |
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1022,9 +1022,9 @@ discard block |
||
1022 | 1022 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1023 | 1023 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | 1024 | end($this->stats[$current_date][$source]['hist']); |
1025 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1025 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1026 | 1026 | } else $mini = 0; |
1027 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1027 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1028 | 1028 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $this->all_flights[$id]['lastupdate'] = time(); |
1038 | 1038 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1039 | 1039 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1040 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1041 | 1041 | //$this->del(); |
1042 | 1042 | |
1043 | 1043 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | fclose($fp); |
26 | 26 | } |
27 | 27 | |
28 | - public static function gunzip($in_file,$out_file_name = '') { |
|
28 | + public static function gunzip($in_file, $out_file_name = '') { |
|
29 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
30 | 30 | $buffer_size = 4096; // read 4kb at a time |
31 | 31 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
32 | 32 | if ($in_file != '' && file_exists($in_file)) { |
33 | 33 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
34 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
35 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
36 | 36 | else { |
37 | 37 | echo 'gzopen not available'; |
38 | 38 | die; |
39 | 39 | } |
40 | 40 | $out_file = fopen($out_file_name, 'wb'); |
41 | - while(!gzeof($file)) { |
|
41 | + while (!gzeof($file)) { |
|
42 | 42 | fwrite($out_file, gzread($file, $buffer_size)); |
43 | 43 | } |
44 | 44 | fclose($out_file); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | try { |
63 | 63 | self::$db_sqlite = new PDO('sqlite:'.$database); |
64 | 64 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
65 | - } catch(PDOException $e) { |
|
65 | + } catch (PDOException $e) { |
|
66 | 66 | return "error : ".$e->getMessage(); |
67 | 67 | } |
68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | //$Connection = new Connection(); |
78 | 78 | $sth = $Connection->db->prepare($query); |
79 | 79 | $sth->execute(array(':source' => $database_file)); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | try { |
89 | 89 | $sth = update_db::$db_sqlite->prepare($query); |
90 | 90 | $sth->execute(); |
91 | - } catch(PDOException $e) { |
|
91 | + } catch (PDOException $e) { |
|
92 | 92 | return "error : ".$e->getMessage(); |
93 | 93 | } |
94 | 94 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
100 | 100 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
101 | 101 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
102 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
103 | 103 | $sth_dest->execute($query_dest_values); |
104 | 104 | } |
105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | //$Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | 121 | $sth->execute(array(':source' => 'oneworld')); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | |
126 | 126 | if ($globalDebug) echo " - Add routes to DB -"; |
127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
128 | 128 | $Spotter = new Spotter(); |
129 | - if ($fh = fopen($database_file,"r")) { |
|
129 | + if ($fh = fopen($database_file, "r")) { |
|
130 | 130 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
131 | 131 | $Connection = new Connection(); |
132 | 132 | $sth_dest = $Connection->db->prepare($query_dest); |
133 | 133 | if ($globalTransaction) $Connection->db->beginTransaction(); |
134 | 134 | while (!feof($fh)) { |
135 | - $line = fgetcsv($fh,9999,','); |
|
135 | + $line = fgetcsv($fh, 9999, ','); |
|
136 | 136 | if ($line[0] != '') { |
137 | 137 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
138 | 138 | try { |
139 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
139 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
140 | 140 | $sth_dest->execute($query_dest_values); |
141 | - } catch(PDOException $e) { |
|
141 | + } catch (PDOException $e) { |
|
142 | 142 | if ($globalTransaction) $Connection->db->rollBack(); |
143 | 143 | return "error : ".$e->getMessage(); |
144 | 144 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | //$Connection = new Connection(); |
161 | 161 | $sth = $Connection->db->prepare($query); |
162 | 162 | $sth->execute(array(':source' => 'skyteam')); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | return "error : ".$e->getMessage(); |
165 | 165 | } |
166 | 166 | |
@@ -168,24 +168,24 @@ discard block |
||
168 | 168 | |
169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
170 | 170 | $Spotter = new Spotter(); |
171 | - if ($fh = fopen($database_file,"r")) { |
|
171 | + if ($fh = fopen($database_file, "r")) { |
|
172 | 172 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
173 | 173 | $Connection = new Connection(); |
174 | 174 | $sth_dest = $Connection->db->prepare($query_dest); |
175 | 175 | try { |
176 | 176 | if ($globalTransaction) $Connection->db->beginTransaction(); |
177 | 177 | while (!feof($fh)) { |
178 | - $line = fgetcsv($fh,9999,','); |
|
178 | + $line = fgetcsv($fh, 9999, ','); |
|
179 | 179 | if ($line[0] != '') { |
180 | - $datebe = explode(' - ',$line[2]); |
|
180 | + $datebe = explode(' - ', $line[2]); |
|
181 | 181 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
182 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
182 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
183 | 183 | $sth_dest->execute($query_dest_values); |
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
187 | 187 | if ($globalTransaction) $Connection->db->commit(); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | if ($globalTransaction) $Connection->db->rollBack(); |
190 | 190 | return "error : ".$e->getMessage(); |
191 | 191 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = $Connection->db->prepare($query); |
202 | 202 | $sth->execute(array(':source' => $database_file)); |
203 | - } catch(PDOException $e) { |
|
203 | + } catch (PDOException $e) { |
|
204 | 204 | return "error : ".$e->getMessage(); |
205 | 205 | } |
206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $Connection = new Connection(); |
209 | 209 | $sth = $Connection->db->prepare($query); |
210 | 210 | $sth->execute(array(':source' => $database_file)); |
211 | - } catch(PDOException $e) { |
|
211 | + } catch (PDOException $e) { |
|
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
214 | 214 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | try { |
218 | 218 | $sth = update_db::$db_sqlite->prepare($query); |
219 | 219 | $sth->execute(); |
220 | - } catch(PDOException $e) { |
|
220 | + } catch (PDOException $e) { |
|
221 | 221 | return "error : ".$e->getMessage(); |
222 | 222 | } |
223 | 223 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
236 | 236 | else $type = null; |
237 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
237 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
238 | 238 | $sth_dest->execute($query_dest_values); |
239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
241 | 241 | $sth_dest_owner->execute($query_dest_owner_values); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
245 | - } catch(PDOException $e) { |
|
245 | + } catch (PDOException $e) { |
|
246 | 246 | return "error : ".$e->getMessage(); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $Connection = new Connection(); |
253 | 253 | $sth = $Connection->db->prepare($query); |
254 | 254 | $sth->execute(array(':source' => $database_file)); |
255 | - } catch(PDOException $e) { |
|
255 | + } catch (PDOException $e) { |
|
256 | 256 | return "error : ".$e->getMessage(); |
257 | 257 | } |
258 | 258 | return ''; |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | $Connection = new Connection(); |
268 | 268 | $sth = $Connection->db->prepare($query); |
269 | 269 | $sth->execute(array(':source' => $database_file)); |
270 | - } catch(PDOException $e) { |
|
270 | + } catch (PDOException $e) { |
|
271 | 271 | return "error : ".$e->getMessage(); |
272 | 272 | } |
273 | 273 | |
274 | - if ($fh = fopen($database_file,"r")) { |
|
274 | + if ($fh = fopen($database_file, "r")) { |
|
275 | 275 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
276 | 276 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
282 | 282 | while (!feof($fh)) { |
283 | 283 | $values = array(); |
284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
284 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
286 | - $values['ModeS'] = substr($line,0,6); |
|
287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
288 | - $aircraft_name = trim(substr($line,48,6)); |
|
286 | + $values['ModeS'] = substr($line, 0, 6); |
|
287 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
288 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
289 | 289 | // Check if we can find ICAO, else set it to GLID |
290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
291 | 291 | $search_more = ''; |
292 | 292 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
293 | 293 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | if (isset($result['icao']) && $result['icao'] != '') { |
300 | 300 | $values['ICAOTypeCode'] = $result['icao']; |
301 | 301 | } |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
306 | 306 | // Add data to db |
307 | 307 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
308 | 308 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
309 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
309 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
310 | 310 | //print_r($query_dest_values); |
311 | 311 | $sth_dest->execute($query_dest_values); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | if ($globalTransaction) $Connection->db->commit(); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | return "error : ".$e->getMessage(); |
317 | 317 | } |
318 | 318 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $Connection = new Connection(); |
323 | 323 | $sth = $Connection->db->prepare($query); |
324 | 324 | $sth->execute(array(':source' => $database_file)); |
325 | - } catch(PDOException $e) { |
|
325 | + } catch (PDOException $e) { |
|
326 | 326 | return "error : ".$e->getMessage(); |
327 | 327 | } |
328 | 328 | return ''; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | $Connection = new Connection(); |
337 | 337 | $sth = $Connection->db->prepare($query); |
338 | 338 | $sth->execute(array(':source' => $database_file)); |
339 | - } catch(PDOException $e) { |
|
339 | + } catch (PDOException $e) { |
|
340 | 340 | return "error : ".$e->getMessage(); |
341 | 341 | } |
342 | 342 | |
343 | - if ($fh = fopen($database_file,"r")) { |
|
343 | + if ($fh = fopen($database_file, "r")) { |
|
344 | 344 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
345 | 345 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
346 | 346 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | $sth_dest = $Connection->db->prepare($query_dest); |
349 | 349 | try { |
350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
351 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
351 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
352 | 352 | while (!feof($fh)) { |
353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
353 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
354 | 354 | |
355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
356 | 356 | //print_r($line); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $values['ICAOTypeCode'] = ''; |
360 | 360 | $aircraft_name = $line[2]; |
361 | 361 | // Check if we can find ICAO, else set it to GLID |
362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
362 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
363 | 363 | $search_more = ''; |
364 | 364 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
365 | 365 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -368,20 +368,20 @@ discard block |
||
368 | 368 | $sth_search->execute(); |
369 | 369 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
370 | 370 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
371 | - } catch(PDOException $e) { |
|
371 | + } catch (PDOException $e) { |
|
372 | 372 | return "error : ".$e->getMessage(); |
373 | 373 | } |
374 | 374 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
375 | 375 | // Add data to db |
376 | 376 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
377 | 377 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
378 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
378 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
379 | 379 | //print_r($query_dest_values); |
380 | 380 | $sth_dest->execute($query_dest_values); |
381 | 381 | } |
382 | 382 | } |
383 | 383 | if ($globalTransaction) $Connection->db->commit(); |
384 | - } catch(PDOException $e) { |
|
384 | + } catch (PDOException $e) { |
|
385 | 385 | return "error : ".$e->getMessage(); |
386 | 386 | } |
387 | 387 | } |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | $Connection = new Connection(); |
392 | 392 | $sth = $Connection->db->prepare($query); |
393 | 393 | $sth->execute(array(':source' => $database_file)); |
394 | - } catch(PDOException $e) { |
|
394 | + } catch (PDOException $e) { |
|
395 | 395 | return "error : ".$e->getMessage(); |
396 | 396 | } |
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
400 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
400 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
401 | 401 | global $globalTransaction, $globalMasterSource; |
402 | 402 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
403 | 403 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | $Connection = new Connection(); |
406 | 406 | $sth = $Connection->db->prepare($query); |
407 | 407 | $sth->execute(array(':source' => $database_file)); |
408 | - } catch(PDOException $e) { |
|
408 | + } catch (PDOException $e) { |
|
409 | 409 | return "error : ".$e->getMessage(); |
410 | 410 | } |
411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
412 | 412 | $Spotter = new Spotter(); |
413 | - if ($fh = fopen($database_file,"r")) { |
|
413 | + if ($fh = fopen($database_file, "r")) { |
|
414 | 414 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
416 | 416 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | $sth_modes = $Connection->db->prepare($query_modes); |
421 | 421 | try { |
422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
423 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
423 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
424 | 424 | while (!feof($fh)) { |
425 | - $line = fgetcsv($fh,9999,',','"'); |
|
425 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
426 | 426 | $values = array(); |
427 | 427 | //print_r($line); |
428 | 428 | if ($country == 'F') { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $values['base'] = $line[4]; |
431 | 431 | $values['owner'] = $line[5]; |
432 | 432 | if ($line[6] == '') $values['date_first_reg'] = null; |
433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
433 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
434 | 434 | $values['cancel'] = $line[7]; |
435 | 435 | } elseif ($country == 'EI') { |
436 | 436 | // TODO : add modeS & reg to aircraft_modes |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $values['base'] = $line[3]; |
439 | 439 | $values['owner'] = $line[2]; |
440 | 440 | if ($line[1] == '') $values['date_first_reg'] = null; |
441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
441 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
442 | 442 | $values['cancel'] = ''; |
443 | 443 | $values['modes'] = $line[7]; |
444 | 444 | $values['icao'] = $line[8]; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $values['base'] = null; |
459 | 459 | $values['owner'] = $line[5]; |
460 | 460 | if ($line[18] == '') $values['date_first_reg'] = null; |
461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
461 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
462 | 462 | $values['cancel'] = ''; |
463 | 463 | } elseif ($country == 'VH') { |
464 | 464 | // TODO : add modeS & reg to aircraft_modes |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $values['base'] = null; |
467 | 467 | $values['owner'] = $line[12]; |
468 | 468 | if ($line[28] == '') $values['date_first_reg'] = null; |
469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
469 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
470 | 470 | |
471 | 471 | $values['cancel'] = $line[39]; |
472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -486,28 +486,28 @@ discard block |
||
486 | 486 | $values['base'] = null; |
487 | 487 | $values['owner'] = $line[8]; |
488 | 488 | if ($line[7] == '') $values['date_first_reg'] = null; |
489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
489 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
490 | 490 | $values['cancel'] = ''; |
491 | 491 | } elseif ($country == 'PP') { |
492 | 492 | $values['registration'] = $line[0]; |
493 | 493 | $values['base'] = null; |
494 | 494 | $values['owner'] = $line[4]; |
495 | 495 | if ($line[6] == '') $values['date_first_reg'] = null; |
496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
496 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
497 | 497 | $values['cancel'] = $line[7]; |
498 | 498 | } elseif ($country == 'E7') { |
499 | 499 | $values['registration'] = $line[0]; |
500 | 500 | $values['base'] = null; |
501 | 501 | $values['owner'] = $line[4]; |
502 | 502 | if ($line[5] == '') $values['date_first_reg'] = null; |
503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
503 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
504 | 504 | $values['cancel'] = ''; |
505 | 505 | } elseif ($country == '8Q') { |
506 | 506 | $values['registration'] = $line[0]; |
507 | 507 | $values['base'] = null; |
508 | 508 | $values['owner'] = $line[3]; |
509 | 509 | if ($line[7] == '') $values['date_first_reg'] = null; |
510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
510 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
511 | 511 | $values['cancel'] = ''; |
512 | 512 | } elseif ($country == 'ZK') { |
513 | 513 | $values['registration'] = $line[0]; |
@@ -521,18 +521,18 @@ discard block |
||
521 | 521 | $values['registration'] = $line[0]; |
522 | 522 | $values['base'] = null; |
523 | 523 | $values['owner'] = $line[6]; |
524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
524 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
525 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
526 | 526 | $values['modes'] = $line[4]; |
527 | 527 | $values['icao'] = $line[10]; |
528 | 528 | } elseif ($country == 'OY') { |
529 | 529 | $values['registration'] = $line[0]; |
530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
530 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
531 | 531 | $values['modes'] = $line[5]; |
532 | 532 | $values['icao'] = $line[6]; |
533 | 533 | } elseif ($country == 'PH') { |
534 | 534 | $values['registration'] = $line[0]; |
535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
535 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
536 | 536 | $values['modes'] = $line[4]; |
537 | 537 | $values['icao'] = $line[5]; |
538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | $values['cancel'] = ''; |
544 | 544 | } |
545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
546 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
546 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
547 | 547 | $sth_dest->execute($query_dest_values); |
548 | 548 | } |
549 | 549 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
550 | 550 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
551 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
551 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
552 | 552 | $sth_modes->execute($query_modes_values); |
553 | 553 | } |
554 | 554 | } |
555 | 555 | if ($globalTransaction) $Connection->db->commit(); |
556 | - } catch(PDOException $e) { |
|
556 | + } catch (PDOException $e) { |
|
557 | 557 | return "error : ".$e->getMessage(); |
558 | 558 | } |
559 | 559 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | if ($globalTransaction) $Connection->db->beginTransaction(); |
692 | 692 | |
693 | 693 | $i = 0; |
694 | - while($row = sparql_fetch_array($result)) |
|
694 | + while ($row = sparql_fetch_array($result)) |
|
695 | 695 | { |
696 | 696 | if ($i >= 1) { |
697 | 697 | //print_r($row); |
@@ -711,33 +711,33 @@ discard block |
||
711 | 711 | $row['image'] = ''; |
712 | 712 | $row['image_thumb'] = ''; |
713 | 713 | } else { |
714 | - $image = str_replace(' ','_',$row['image']); |
|
714 | + $image = str_replace(' ', '_', $row['image']); |
|
715 | 715 | $digest = md5($image); |
716 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
717 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
718 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
719 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
716 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
717 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
718 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
719 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
720 | 720 | } |
721 | 721 | |
722 | - $country = explode('-',$row['country']); |
|
722 | + $country = explode('-', $row['country']); |
|
723 | 723 | $row['country'] = $country[0]; |
724 | 724 | |
725 | 725 | $row['type'] = trim($row['type']); |
726 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
726 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
727 | 727 | $row['type'] = 'military'; |
728 | 728 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
729 | 729 | $row['type'] = 'small_airport'; |
730 | 730 | } |
731 | 731 | |
732 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
733 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
732 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
733 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
734 | 734 | //print_r($query_dest_values); |
735 | 735 | |
736 | 736 | if ($row['icao'] != '') { |
737 | 737 | try { |
738 | 738 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
739 | 739 | $sth->execute(array(':icao' => $row['icao'])); |
740 | - } catch(PDOException $e) { |
|
740 | + } catch (PDOException $e) { |
|
741 | 741 | return "error : ".$e->getMessage(); |
742 | 742 | } |
743 | 743 | if ($sth->fetchColumn() > 0) { |
@@ -745,15 +745,15 @@ discard block |
||
745 | 745 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
746 | 746 | try { |
747 | 747 | $sth = $Connection->db->prepare($query); |
748 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
749 | - } catch(PDOException $e) { |
|
748 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
749 | + } catch (PDOException $e) { |
|
750 | 750 | return "error : ".$e->getMessage(); |
751 | 751 | } |
752 | 752 | echo $row['icao'].' : '.$row['type']."\n"; |
753 | 753 | } else { |
754 | 754 | try { |
755 | 755 | $sth_dest->execute($query_dest_values); |
756 | - } catch(PDOException $e) { |
|
756 | + } catch (PDOException $e) { |
|
757 | 757 | return "error : ".$e->getMessage(); |
758 | 758 | } |
759 | 759 | } |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | echo "Download data from ourairports.com...\n"; |
805 | 805 | $delimiter = ','; |
806 | 806 | $out_file = $tmp_dir.'airports.csv'; |
807 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
807 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
808 | 808 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
809 | 809 | echo "Add data from ourairports.com...\n"; |
810 | 810 | |
@@ -815,33 +815,33 @@ discard block |
||
815 | 815 | //$Connection->db->beginTransaction(); |
816 | 816 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
817 | 817 | { |
818 | - if(!$header) $header = $row; |
|
818 | + if (!$header) $header = $row; |
|
819 | 819 | else { |
820 | 820 | $data = array(); |
821 | 821 | $data = array_combine($header, $row); |
822 | 822 | try { |
823 | 823 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
824 | 824 | $sth->execute(array(':icao' => $data['ident'])); |
825 | - } catch(PDOException $e) { |
|
825 | + } catch (PDOException $e) { |
|
826 | 826 | return "error : ".$e->getMessage(); |
827 | 827 | } |
828 | 828 | if ($sth->fetchColumn() > 0) { |
829 | 829 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
830 | 830 | try { |
831 | 831 | $sth = $Connection->db->prepare($query); |
832 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
833 | - } catch(PDOException $e) { |
|
832 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
833 | + } catch (PDOException $e) { |
|
834 | 834 | return "error : ".$e->getMessage(); |
835 | 835 | } |
836 | 836 | } else { |
837 | 837 | if ($data['gps_code'] == $data['ident']) { |
838 | 838 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
839 | 839 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
840 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
840 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
841 | 841 | try { |
842 | 842 | $sth = $Connection->db->prepare($query); |
843 | 843 | $sth->execute($query_values); |
844 | - } catch(PDOException $e) { |
|
844 | + } catch (PDOException $e) { |
|
845 | 845 | return "error : ".$e->getMessage(); |
846 | 846 | } |
847 | 847 | $i++; |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | |
857 | 857 | echo "Download data from another free database...\n"; |
858 | 858 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
859 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
859 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
860 | 860 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
861 | 861 | update_db::unzip($out_file); |
862 | 862 | $header = NULL; |
@@ -868,15 +868,15 @@ discard block |
||
868 | 868 | //$Connection->db->beginTransaction(); |
869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 870 | { |
871 | - if(!$header) $header = $row; |
|
871 | + if (!$header) $header = $row; |
|
872 | 872 | else { |
873 | 873 | $data = $row; |
874 | 874 | |
875 | 875 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
876 | 876 | try { |
877 | 877 | $sth = $Connection->db->prepare($query); |
878 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
879 | - } catch(PDOException $e) { |
|
878 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
879 | + } catch (PDOException $e) { |
|
880 | 880 | return "error : ".$e->getMessage(); |
881 | 881 | } |
882 | 882 | } |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
892 | 892 | $sth->execute(); |
893 | - } catch(PDOException $e) { |
|
893 | + } catch (PDOException $e) { |
|
894 | 894 | return "error : ".$e->getMessage(); |
895 | 895 | } |
896 | 896 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
897 | 897 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
898 | 898 | try { |
899 | 899 | $sth2 = $Connection->db->prepare($query2); |
900 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
901 | - } catch(PDOException $e) { |
|
900 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
901 | + } catch (PDOException $e) { |
|
902 | 902 | return "error : ".$e->getMessage(); |
903 | 903 | } |
904 | 904 | } |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | $Connection = new Connection(); |
920 | 920 | $sth = $Connection->db->prepare($query); |
921 | 921 | $sth->execute(array(':source' => 'translation.csv')); |
922 | - } catch(PDOException $e) { |
|
922 | + } catch (PDOException $e) { |
|
923 | 923 | return "error : ".$e->getMessage(); |
924 | 924 | } |
925 | 925 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
937 | 937 | { |
938 | 938 | $i++; |
939 | - if($i > 12) { |
|
939 | + if ($i > 12) { |
|
940 | 940 | $data = $row; |
941 | 941 | $operator = $data[2]; |
942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | //echo substr($operator, 0, 2)."\n";; |
945 | 945 | if (count($airline_array) > 0) { |
946 | 946 | //print_r($airline_array); |
947 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
947 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
@@ -952,14 +952,14 @@ discard block |
||
952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
953 | 953 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
954 | 954 | if (count($airline_array) > 0) { |
955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
956 | 956 | } |
957 | 957 | } |
958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
959 | 959 | try { |
960 | 960 | $sth = $Connection->db->prepare($query); |
961 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
962 | - } catch(PDOException $e) { |
|
961 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
962 | + } catch (PDOException $e) { |
|
963 | 963 | return "error : ".$e->getMessage(); |
964 | 964 | } |
965 | 965 | } |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | $Connection = new Connection(); |
980 | 980 | $sth = $Connection->db->prepare($query); |
981 | 981 | $sth->execute(array(':source' => 'website_fam')); |
982 | - } catch(PDOException $e) { |
|
982 | + } catch (PDOException $e) { |
|
983 | 983 | return "error : ".$e->getMessage(); |
984 | 984 | } |
985 | 985 | |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
1000 | 1000 | try { |
1001 | 1001 | $sth = $Connection->db->prepare($query); |
1002 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1003 | - } catch(PDOException $e) { |
|
1002 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | return "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | $Connection = new Connection(); |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | 1025 | $sth->execute(array(':source' => 'website_faa')); |
1026 | - } catch(PDOException $e) { |
|
1026 | + } catch (PDOException $e) { |
|
1027 | 1027 | return "error : ".$e->getMessage(); |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | $Connection = new Connection(); |
1033 | 1033 | $sth = $Connection->db->prepare($query); |
1034 | 1034 | $sth->execute(array(':source' => 'website_faa')); |
1035 | - } catch(PDOException $e) { |
|
1035 | + } catch (PDOException $e) { |
|
1036 | 1036 | return "error : ".$e->getMessage(); |
1037 | 1037 | } |
1038 | 1038 | |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
1050 | 1050 | try { |
1051 | 1051 | $sths = $Connection->db->prepare($query_search); |
1052 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
1053 | - } catch(PDOException $e) { |
|
1052 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
1053 | + } catch (PDOException $e) { |
|
1054 | 1054 | return "error s : ".$e->getMessage(); |
1055 | 1055 | } |
1056 | 1056 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | //} |
1064 | 1064 | try { |
1065 | 1065 | $sthi = $Connection->db->prepare($queryi); |
1066 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1067 | - } catch(PDOException $e) { |
|
1066 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1067 | + } catch (PDOException $e) { |
|
1068 | 1068 | return "error u : ".$e->getMessage(); |
1069 | 1069 | } |
1070 | 1070 | } else { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | try { |
1073 | 1073 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1074 | 1074 | $sthsm->execute(array(':mfr' => $data[2])); |
1075 | - } catch(PDOException $e) { |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error mfr : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1083 | 1083 | try { |
1084 | 1084 | $sthf = $Connection->db->prepare($queryf); |
1085 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
1086 | - } catch(PDOException $e) { |
|
1085 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
1086 | + } catch (PDOException $e) { |
|
1087 | 1087 | return "error f : ".$e->getMessage(); |
1088 | 1088 | } |
1089 | 1089 | } |
@@ -1093,13 +1093,13 @@ discard block |
||
1093 | 1093 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1094 | 1094 | try { |
1095 | 1095 | $sth = $Connection->db->prepare($query); |
1096 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
1097 | - } catch(PDOException $e) { |
|
1096 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
1097 | + } catch (PDOException $e) { |
|
1098 | 1098 | return "error i : ".$e->getMessage(); |
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | } |
1102 | - if ($i % 90 == 0) { |
|
1102 | + if ($i%90 == 0) { |
|
1103 | 1103 | if ($globalTransaction) $Connection->db->commit(); |
1104 | 1104 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1105 | 1105 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | $Connection = new Connection(); |
1119 | 1119 | $sth = $Connection->db->prepare($query); |
1120 | 1120 | $sth->execute(array(':source' => 'website_fam')); |
1121 | - } catch(PDOException $e) { |
|
1121 | + } catch (PDOException $e) { |
|
1122 | 1122 | return "error : ".$e->getMessage(); |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1140 | try { |
1141 | 1141 | $sth = $Connection->db->prepare($query); |
1142 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
1143 | - } catch(PDOException $e) { |
|
1142 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
1143 | + } catch (PDOException $e) { |
|
1144 | 1144 | return "error : ".$e->getMessage(); |
1145 | 1145 | } |
1146 | 1146 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $Connection = new Connection(); |
1160 | 1160 | $sth = $Connection->db->prepare($query); |
1161 | 1161 | $sth->execute(array(':source' => 'website_fam')); |
1162 | - } catch(PDOException $e) { |
|
1162 | + } catch (PDOException $e) { |
|
1163 | 1163 | return "error : ".$e->getMessage(); |
1164 | 1164 | } |
1165 | 1165 | |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1176 | 1176 | try { |
1177 | 1177 | $sth = $Connection->db->prepare($query); |
1178 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1179 | - } catch(PDOException $e) { |
|
1178 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1179 | + } catch (PDOException $e) { |
|
1180 | 1180 | print_r($data); |
1181 | 1181 | return "error : ".$e->getMessage(); |
1182 | 1182 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | $Connection = new Connection(); |
1197 | 1197 | $sth = $Connection->db->prepare($query); |
1198 | 1198 | $sth->execute(array(':source' => 'website_fam')); |
1199 | - } catch(PDOException $e) { |
|
1199 | + } catch (PDOException $e) { |
|
1200 | 1200 | return "error : ".$e->getMessage(); |
1201 | 1201 | } |
1202 | 1202 | |
@@ -1216,8 +1216,8 @@ discard block |
||
1216 | 1216 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
1217 | 1217 | try { |
1218 | 1218 | $sth = $Connection->db->prepare($query); |
1219 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1220 | - } catch(PDOException $e) { |
|
1219 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1220 | + } catch (PDOException $e) { |
|
1221 | 1221 | return "error : ".$e->getMessage(); |
1222 | 1222 | } |
1223 | 1223 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $Connection = new Connection(); |
1237 | 1237 | $sth = $Connection->db->prepare($query); |
1238 | 1238 | $sth->execute(); |
1239 | - } catch(PDOException $e) { |
|
1239 | + } catch (PDOException $e) { |
|
1240 | 1240 | return "error : ".$e->getMessage(); |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1257,8 +1257,8 @@ discard block |
||
1257 | 1257 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
1258 | 1258 | try { |
1259 | 1259 | $sth = $Connection->db->prepare($query); |
1260 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
1261 | - } catch(PDOException $e) { |
|
1260 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
1261 | + } catch (PDOException $e) { |
|
1262 | 1262 | return "error : ".$e->getMessage(); |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | $Connection = new Connection(); |
1278 | 1278 | $sth = $Connection->db->prepare($query); |
1279 | 1279 | $sth->execute(); |
1280 | - } catch(PDOException $e) { |
|
1280 | + } catch (PDOException $e) { |
|
1281 | 1281 | return "error : ".$e->getMessage(); |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | try { |
1294 | 1294 | $sth = $Connection->db->prepare($query); |
1295 | 1295 | $sth->execute(array(':icao' => $icao)); |
1296 | - } catch(PDOException $e) { |
|
1296 | + } catch (PDOException $e) { |
|
1297 | 1297 | return "error : ".$e->getMessage(); |
1298 | 1298 | } |
1299 | 1299 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | return ''; |
1305 | 1305 | } |
1306 | 1306 | |
1307 | - public static function tle($filename,$tletype) { |
|
1307 | + public static function tle($filename, $tletype) { |
|
1308 | 1308 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1309 | 1309 | global $tmp_dir, $globalTransaction; |
1310 | 1310 | //$Spotter = new Spotter(); |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | $Connection = new Connection(); |
1315 | 1315 | $sth = $Connection->db->prepare($query); |
1316 | 1316 | $sth->execute(array(':source' => $filename)); |
1317 | - } catch(PDOException $e) { |
|
1317 | + } catch (PDOException $e) { |
|
1318 | 1318 | return "error : ".$e->getMessage(); |
1319 | 1319 | } |
1320 | 1320 | |
@@ -1339,8 +1339,8 @@ discard block |
||
1339 | 1339 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1340 | 1340 | try { |
1341 | 1341 | $sth = $Connection->db->prepare($query); |
1342 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1343 | - } catch(PDOException $e) { |
|
1342 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1343 | + } catch (PDOException $e) { |
|
1344 | 1344 | return "error : ".$e->getMessage(); |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1360,28 +1360,28 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | private static function table2array($data) { |
1362 | 1362 | $html = str_get_html($data); |
1363 | - $tabledata=array(); |
|
1364 | - foreach($html->find('tr') as $element) |
|
1363 | + $tabledata = array(); |
|
1364 | + foreach ($html->find('tr') as $element) |
|
1365 | 1365 | { |
1366 | 1366 | $td = array(); |
1367 | - foreach( $element->find('th') as $row) |
|
1367 | + foreach ($element->find('th') as $row) |
|
1368 | 1368 | { |
1369 | 1369 | $td [] = trim($row->plaintext); |
1370 | 1370 | } |
1371 | - $td=array_filter($td); |
|
1371 | + $td = array_filter($td); |
|
1372 | 1372 | $tabledata[] = $td; |
1373 | 1373 | |
1374 | 1374 | $td = array(); |
1375 | 1375 | $tdi = array(); |
1376 | - foreach( $element->find('td') as $row) |
|
1376 | + foreach ($element->find('td') as $row) |
|
1377 | 1377 | { |
1378 | 1378 | $td [] = trim($row->plaintext); |
1379 | 1379 | $tdi [] = trim($row->innertext); |
1380 | 1380 | } |
1381 | - $td=array_filter($td); |
|
1382 | - $tdi=array_filter($tdi); |
|
1381 | + $td = array_filter($td); |
|
1382 | + $tdi = array_filter($tdi); |
|
1383 | 1383 | // $tabledata[]=array_merge($td,$tdi); |
1384 | - $tabledata[]=$td; |
|
1384 | + $tabledata[] = $td; |
|
1385 | 1385 | } |
1386 | 1386 | return(array_filter($tabledata)); |
1387 | 1387 | } |
@@ -1454,13 +1454,13 @@ discard block |
||
1454 | 1454 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1455 | 1455 | { |
1456 | 1456 | $i++; |
1457 | - if($i > 3 && count($row) > 2) { |
|
1457 | + if ($i > 3 && count($row) > 2) { |
|
1458 | 1458 | $data = array_values(array_filter($row)); |
1459 | 1459 | $cntdata = count($data); |
1460 | 1460 | if ($cntdata > 10) { |
1461 | 1461 | $value = $data[9]; |
1462 | 1462 | |
1463 | - for ($i =10;$i < $cntdata;$i++) { |
|
1463 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1464 | 1464 | $value .= ' '.$data[$i]; |
1465 | 1465 | } |
1466 | 1466 | $data[9] = $value; |
@@ -1470,8 +1470,8 @@ discard block |
||
1470 | 1470 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1471 | 1471 | try { |
1472 | 1472 | $sth = $Connection->db->prepare($query); |
1473 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1474 | - } catch(PDOException $e) { |
|
1473 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1474 | + } catch (PDOException $e) { |
|
1475 | 1475 | return "error : ".$e->getMessage(); |
1476 | 1476 | } |
1477 | 1477 | } |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | $Connection = new Connection(); |
1493 | 1493 | $sth = $Connection->db->prepare($query); |
1494 | 1494 | $sth->execute(); |
1495 | - } catch(PDOException $e) { |
|
1495 | + } catch (PDOException $e) { |
|
1496 | 1496 | return "error : ".$e->getMessage(); |
1497 | 1497 | } |
1498 | 1498 | |
@@ -1504,12 +1504,12 @@ discard block |
||
1504 | 1504 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1505 | 1505 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1506 | 1506 | { |
1507 | - if(count($row) > 1) { |
|
1507 | + if (count($row) > 1) { |
|
1508 | 1508 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1509 | 1509 | try { |
1510 | 1510 | $sth = $Connection->db->prepare($query); |
1511 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1512 | - } catch(PDOException $e) { |
|
1511 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1512 | + } catch (PDOException $e) { |
|
1513 | 1513 | return "error : ".$e->getMessage(); |
1514 | 1514 | } |
1515 | 1515 | } |
@@ -1529,21 +1529,21 @@ discard block |
||
1529 | 1529 | try { |
1530 | 1530 | $sth = $Connection->db->prepare($query); |
1531 | 1531 | $sth->execute(); |
1532 | - } catch(PDOException $e) { |
|
1532 | + } catch (PDOException $e) { |
|
1533 | 1533 | return "error : ".$e->getMessage(); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | |
1538 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1538 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1539 | 1539 | else { |
1540 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1540 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1541 | 1541 | $query = "CREATE EXTENSION postgis"; |
1542 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1542 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error : ".$e->getMessage(); |
1548 | 1548 | } |
1549 | 1549 | } |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | include_once('class.create_db.php'); |
1557 | 1557 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1558 | 1558 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1559 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1559 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1560 | 1560 | $error = ''; |
1561 | 1561 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1562 | 1562 | if ($globalDebug) echo "Gunzip..."; |
@@ -1588,14 +1588,14 @@ discard block |
||
1588 | 1588 | try { |
1589 | 1589 | $sth = $Connection->db->prepare($query); |
1590 | 1590 | $sth->execute(); |
1591 | - } catch(PDOException $e) { |
|
1591 | + } catch (PDOException $e) { |
|
1592 | 1592 | echo "error : ".$e->getMessage(); |
1593 | 1593 | } |
1594 | 1594 | } |
1595 | 1595 | if ($globalDBdriver == 'mysql') { |
1596 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1596 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1597 | 1597 | } else { |
1598 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1598 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1599 | 1599 | } |
1600 | 1600 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1601 | 1601 | return $error; |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1609 | 1609 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1610 | 1610 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1611 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1611 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1612 | 1612 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1613 | 1613 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1614 | 1614 | return $error; |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1629 | 1629 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1630 | 1630 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1631 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1631 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1632 | 1632 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1633 | 1633 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1634 | 1634 | if ($error != '') { |
@@ -1641,7 +1641,7 @@ discard block |
||
1641 | 1641 | global $tmp_dir, $globalDebug; |
1642 | 1642 | $error = ''; |
1643 | 1643 | if ($globalDebug) echo "Routes : Download..."; |
1644 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1644 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1645 | 1645 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1646 | 1646 | if ($globalDebug) echo "Gunzip..."; |
1647 | 1647 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | global $tmp_dir, $globalDebug; |
1658 | 1658 | $error = ''; |
1659 | 1659 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1660 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1660 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1661 | 1661 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1662 | 1662 | if ($globalDebug) echo "Gunzip..."; |
1663 | 1663 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | global $tmp_dir, $globalDebug; |
1674 | 1674 | $error = ''; |
1675 | 1675 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1676 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1676 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1677 | 1677 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1678 | 1678 | if ($globalDebug) echo "Gunzip..."; |
1679 | 1679 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1701,7 +1701,7 @@ discard block |
||
1701 | 1701 | */ |
1702 | 1702 | if ($globalDebug) echo "Modes : Download..."; |
1703 | 1703 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1704 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1704 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1705 | 1705 | |
1706 | 1706 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1707 | 1707 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | public static function update_ModeS_faa() { |
1722 | 1722 | global $tmp_dir, $globalDebug; |
1723 | 1723 | if ($globalDebug) echo "Modes FAA: Download..."; |
1724 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
1724 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
1725 | 1725 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1726 | 1726 | if ($globalDebug) echo "Unzip..."; |
1727 | 1727 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | public static function update_ModeS_flarm() { |
1738 | 1738 | global $tmp_dir, $globalDebug; |
1739 | 1739 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1740 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1740 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1741 | 1741 | if (file_exists($tmp_dir.'data.fln')) { |
1742 | 1742 | if ($globalDebug) echo "Add to DB..."; |
1743 | 1743 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1751,7 +1751,7 @@ discard block |
||
1751 | 1751 | public static function update_ModeS_ogn() { |
1752 | 1752 | global $tmp_dir, $globalDebug; |
1753 | 1753 | if ($globalDebug) echo "Modes OGN: Download..."; |
1754 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1754 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1755 | 1755 | if (file_exists($tmp_dir.'ogn.csv')) { |
1756 | 1756 | if ($globalDebug) echo "Add to DB..."; |
1757 | 1757 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1766,201 +1766,201 @@ discard block |
||
1766 | 1766 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1767 | 1767 | |
1768 | 1768 | if ($globalDebug) echo "Owner France: Download..."; |
1769 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1769 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1770 | 1770 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1771 | 1771 | if ($globalDebug) echo "Add to DB..."; |
1772 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1772 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1773 | 1773 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1774 | 1774 | if ($error != '') { |
1775 | 1775 | return $error; |
1776 | 1776 | } elseif ($globalDebug) echo "Done\n"; |
1777 | 1777 | |
1778 | 1778 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1779 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1779 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1780 | 1780 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1781 | 1781 | if ($globalDebug) echo "Add to DB..."; |
1782 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1782 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1783 | 1783 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1784 | 1784 | if ($error != '') { |
1785 | 1785 | return $error; |
1786 | 1786 | } elseif ($globalDebug) echo "Done\n"; |
1787 | 1787 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1788 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1788 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1789 | 1789 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1790 | 1790 | if ($globalDebug) echo "Add to DB..."; |
1791 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1791 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1792 | 1792 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1793 | 1793 | if ($error != '') { |
1794 | 1794 | return $error; |
1795 | 1795 | } elseif ($globalDebug) echo "Done\n"; |
1796 | 1796 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1797 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1797 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1798 | 1798 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1799 | 1799 | if ($globalDebug) echo "Add to DB..."; |
1800 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1800 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1801 | 1801 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1802 | 1802 | if ($error != '') { |
1803 | 1803 | return $error; |
1804 | 1804 | } elseif ($globalDebug) echo "Done\n"; |
1805 | 1805 | if ($globalDebug) echo "Owner Australia: Download..."; |
1806 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1806 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1807 | 1807 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1808 | 1808 | if ($globalDebug) echo "Add to DB..."; |
1809 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1809 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1810 | 1810 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1811 | 1811 | if ($error != '') { |
1812 | 1812 | return $error; |
1813 | 1813 | } elseif ($globalDebug) echo "Done\n"; |
1814 | 1814 | if ($globalDebug) echo "Owner Austria: Download..."; |
1815 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1815 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1816 | 1816 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1817 | 1817 | if ($globalDebug) echo "Add to DB..."; |
1818 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1818 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1819 | 1819 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1820 | 1820 | if ($error != '') { |
1821 | 1821 | return $error; |
1822 | 1822 | } elseif ($globalDebug) echo "Done\n"; |
1823 | 1823 | if ($globalDebug) echo "Owner Chile: Download..."; |
1824 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1824 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1825 | 1825 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1826 | 1826 | if ($globalDebug) echo "Add to DB..."; |
1827 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1827 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1828 | 1828 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1829 | 1829 | if ($error != '') { |
1830 | 1830 | return $error; |
1831 | 1831 | } elseif ($globalDebug) echo "Done\n"; |
1832 | 1832 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1833 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1833 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1834 | 1834 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1835 | 1835 | if ($globalDebug) echo "Add to DB..."; |
1836 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1836 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1837 | 1837 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1838 | 1838 | if ($error != '') { |
1839 | 1839 | return $error; |
1840 | 1840 | } elseif ($globalDebug) echo "Done\n"; |
1841 | 1841 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1842 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1842 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1843 | 1843 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1844 | 1844 | if ($globalDebug) echo "Add to DB..."; |
1845 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1845 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1846 | 1846 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1847 | 1847 | if ($error != '') { |
1848 | 1848 | return $error; |
1849 | 1849 | } elseif ($globalDebug) echo "Done\n"; |
1850 | 1850 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1851 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1851 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1852 | 1852 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1853 | 1853 | if ($globalDebug) echo "Add to DB..."; |
1854 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1854 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1855 | 1855 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1856 | 1856 | if ($error != '') { |
1857 | 1857 | return $error; |
1858 | 1858 | } elseif ($globalDebug) echo "Done\n"; |
1859 | 1859 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1860 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1860 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1861 | 1861 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1862 | 1862 | if ($globalDebug) echo "Add to DB..."; |
1863 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1863 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1864 | 1864 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1865 | 1865 | if ($error != '') { |
1866 | 1866 | return $error; |
1867 | 1867 | } elseif ($globalDebug) echo "Done\n"; |
1868 | 1868 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1869 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1869 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1870 | 1870 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1871 | 1871 | if ($globalDebug) echo "Add to DB..."; |
1872 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1872 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1873 | 1873 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1874 | 1874 | if ($error != '') { |
1875 | 1875 | return $error; |
1876 | 1876 | } elseif ($globalDebug) echo "Done\n"; |
1877 | 1877 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1878 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1878 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1879 | 1879 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1880 | 1880 | if ($globalDebug) echo "Add to DB..."; |
1881 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1881 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1882 | 1882 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1883 | 1883 | if ($error != '') { |
1884 | 1884 | return $error; |
1885 | 1885 | } elseif ($globalDebug) echo "Done\n"; |
1886 | 1886 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1887 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1887 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1888 | 1888 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1889 | 1889 | if ($globalDebug) echo "Add to DB..."; |
1890 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1890 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1891 | 1891 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1892 | 1892 | if ($error != '') { |
1893 | 1893 | return $error; |
1894 | 1894 | } elseif ($globalDebug) echo "Done\n"; |
1895 | 1895 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1896 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1896 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1897 | 1897 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1898 | 1898 | if ($globalDebug) echo "Add to DB..."; |
1899 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1899 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1900 | 1900 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1901 | 1901 | if ($error != '') { |
1902 | 1902 | return $error; |
1903 | 1903 | } elseif ($globalDebug) echo "Done\n"; |
1904 | 1904 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1905 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1905 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1906 | 1906 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1907 | 1907 | if ($globalDebug) echo "Add to DB..."; |
1908 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1908 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1909 | 1909 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1910 | 1910 | if ($error != '') { |
1911 | 1911 | return $error; |
1912 | 1912 | } elseif ($globalDebug) echo "Done\n"; |
1913 | 1913 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1914 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1914 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1915 | 1915 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1916 | 1916 | if ($globalDebug) echo "Add to DB..."; |
1917 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1917 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1918 | 1918 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1919 | 1919 | if ($error != '') { |
1920 | 1920 | return $error; |
1921 | 1921 | } elseif ($globalDebug) echo "Done\n"; |
1922 | 1922 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1923 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1923 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1924 | 1924 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1925 | 1925 | if ($globalDebug) echo "Add to DB..."; |
1926 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1926 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1927 | 1927 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1928 | 1928 | if ($error != '') { |
1929 | 1929 | return $error; |
1930 | 1930 | } elseif ($globalDebug) echo "Done\n"; |
1931 | 1931 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1932 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1932 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1933 | 1933 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1934 | 1934 | if ($globalDebug) echo "Add to DB..."; |
1935 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1935 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1936 | 1936 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1937 | 1937 | if ($error != '') { |
1938 | 1938 | return $error; |
1939 | 1939 | } elseif ($globalDebug) echo "Done\n"; |
1940 | 1940 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
1941 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
1941 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
1942 | 1942 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1943 | 1943 | if ($globalDebug) echo "Add to DB..."; |
1944 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
1944 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
1945 | 1945 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
1946 | 1946 | if ($error != '') { |
1947 | 1947 | return $error; |
1948 | 1948 | } elseif ($globalDebug) echo "Done\n"; |
1949 | 1949 | if ($globalMasterSource) { |
1950 | 1950 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
1951 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
1951 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
1952 | 1952 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1953 | 1953 | if ($globalDebug) echo "Add to DB..."; |
1954 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
1954 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
1955 | 1955 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
1956 | 1956 | if ($error != '') { |
1957 | 1957 | return $error; |
1958 | 1958 | } elseif ($globalDebug) echo "Done\n"; |
1959 | 1959 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
1960 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
1960 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
1961 | 1961 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1962 | 1962 | if ($globalDebug) echo "Add to DB..."; |
1963 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
1963 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
1964 | 1964 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
1965 | 1965 | if ($error != '') { |
1966 | 1966 | return $error; |
@@ -1973,7 +1973,7 @@ discard block |
||
1973 | 1973 | global $tmp_dir, $globalDebug; |
1974 | 1974 | $error = ''; |
1975 | 1975 | if ($globalDebug) echo "Translation : Download..."; |
1976 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1976 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1977 | 1977 | if (file_exists($tmp_dir.'translation.zip')) { |
1978 | 1978 | if ($globalDebug) echo "Unzip..."; |
1979 | 1979 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | public static function update_translation_fam() { |
1990 | 1990 | global $tmp_dir, $globalDebug; |
1991 | 1991 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1992 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1992 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1993 | 1993 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1994 | 1994 | if ($globalDebug) echo "Gunzip..."; |
1995 | 1995 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | public static function update_ModeS_fam() { |
2005 | 2005 | global $tmp_dir, $globalDebug; |
2006 | 2006 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
2007 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
2007 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
2008 | 2008 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
2009 | 2009 | if ($globalDebug) echo "Gunzip..."; |
2010 | 2010 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -2020,9 +2020,9 @@ discard block |
||
2020 | 2020 | global $tmp_dir, $globalDebug, $globalOwner; |
2021 | 2021 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
2022 | 2022 | if ($globalOwner === TRUE) { |
2023 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2023 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2024 | 2024 | } else { |
2025 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2025 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2026 | 2026 | } |
2027 | 2027 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
2028 | 2028 | if ($globalDebug) echo "Gunzip..."; |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | public static function update_routes_fam() { |
2039 | 2039 | global $tmp_dir, $globalDebug; |
2040 | 2040 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
2041 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
2041 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
2042 | 2042 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
2043 | 2043 | if ($globalDebug) echo "Gunzip..."; |
2044 | 2044 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -2052,13 +2052,13 @@ discard block |
||
2052 | 2052 | } |
2053 | 2053 | public static function update_marine_identity_fam() { |
2054 | 2054 | global $tmp_dir, $globalDebug; |
2055 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2055 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2056 | 2056 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
2057 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2057 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2058 | 2058 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2059 | 2059 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2060 | 2060 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
2061 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
2061 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
2062 | 2062 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2063 | 2063 | if ($globalDebug) echo "Gunzip..."; |
2064 | 2064 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
@@ -2078,7 +2078,7 @@ discard block |
||
2078 | 2078 | public static function update_banned_fam() { |
2079 | 2079 | global $tmp_dir, $globalDebug; |
2080 | 2080 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
2081 | - update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
2081 | + update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
2082 | 2082 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2083 | 2083 | //if ($globalDebug) echo "Gunzip..."; |
2084 | 2084 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2097,18 +2097,18 @@ discard block |
||
2097 | 2097 | $error = ''; |
2098 | 2098 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
2099 | 2099 | if ($globalDBdriver == 'mysql') { |
2100 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2100 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2101 | 2101 | } else { |
2102 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2102 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2103 | 2103 | } |
2104 | 2104 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
2105 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2105 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2106 | 2106 | $airspace_md5 = $airspace_md5_file[0]; |
2107 | 2107 | if (!update_db::check_airspace_version($airspace_md5)) { |
2108 | 2108 | if ($globalDBdriver == 'mysql') { |
2109 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2109 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2110 | 2110 | } else { |
2111 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2111 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2112 | 2112 | } |
2113 | 2113 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2114 | 2114 | if ($globalDebug) echo "Gunzip..."; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error : ".$e->getMessage(); |
2125 | 2125 | } |
2126 | 2126 | } |
@@ -2139,15 +2139,15 @@ discard block |
||
2139 | 2139 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2140 | 2140 | $error = ''; |
2141 | 2141 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
2142 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2142 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2143 | 2143 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2144 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2144 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2145 | 2145 | $geoid_md5 = $geoid_md5_file[0]; |
2146 | 2146 | if (!update_db::check_geoid_version($geoid_md5)) { |
2147 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2147 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2148 | 2148 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2149 | 2149 | if ($globalDebug) echo "Gunzip..."; |
2150 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2150 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2151 | 2151 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2152 | 2152 | update_db::insert_geoid_version($geoid_md5); |
2153 | 2153 | } |
@@ -2163,15 +2163,15 @@ discard block |
||
2163 | 2163 | public static function update_tle() { |
2164 | 2164 | global $tmp_dir, $globalDebug; |
2165 | 2165 | if ($globalDebug) echo "Download TLE : Download..."; |
2166 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
2167 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
2168 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
2166 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
2167 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
2168 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
2169 | 2169 | foreach ($alltle as $filename) { |
2170 | 2170 | if ($globalDebug) echo "downloading ".$filename.'...'; |
2171 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
2171 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
2172 | 2172 | if (file_exists($tmp_dir.$filename)) { |
2173 | 2173 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
2174 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
2174 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
2175 | 2175 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
2176 | 2176 | if ($error != '') { |
2177 | 2177 | echo $error."\n"; |
@@ -2184,32 +2184,32 @@ discard block |
||
2184 | 2184 | global $tmp_dir, $globalDebug; |
2185 | 2185 | $error = ''; |
2186 | 2186 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
2187 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
2187 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
2188 | 2188 | if (file_exists($tmp_dir.'models.md5sum')) { |
2189 | 2189 | if ($globalDebug) echo "Check files...\n"; |
2190 | 2190 | $newmodelsdb = array(); |
2191 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2192 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2191 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2192 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2193 | 2193 | $model = trim($row[2]); |
2194 | 2194 | $newmodelsdb[$model] = trim($row[0]); |
2195 | 2195 | } |
2196 | 2196 | } |
2197 | 2197 | $modelsdb = array(); |
2198 | 2198 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2199 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2200 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2199 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2200 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2201 | 2201 | $model = trim($row[2]); |
2202 | 2202 | $modelsdb[$model] = trim($row[0]); |
2203 | 2203 | } |
2204 | 2204 | } |
2205 | 2205 | } |
2206 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2206 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2207 | 2207 | foreach ($diff as $key => $value) { |
2208 | 2208 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2209 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2209 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2210 | 2210 | |
2211 | 2211 | } |
2212 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2212 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2213 | 2213 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2214 | 2214 | if ($error != '') { |
2215 | 2215 | return $error; |
@@ -2221,32 +2221,32 @@ discard block |
||
2221 | 2221 | global $tmp_dir, $globalDebug; |
2222 | 2222 | $error = ''; |
2223 | 2223 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
2224 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
2224 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
2225 | 2225 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2226 | 2226 | if ($globalDebug) echo "Check files...\n"; |
2227 | 2227 | $newmodelsdb = array(); |
2228 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
2229 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2228 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
2229 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2230 | 2230 | $model = trim($row[2]); |
2231 | 2231 | $newmodelsdb[$model] = trim($row[0]); |
2232 | 2232 | } |
2233 | 2233 | } |
2234 | 2234 | $modelsdb = array(); |
2235 | 2235 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
2236 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
2237 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2236 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
2237 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2238 | 2238 | $model = trim($row[2]); |
2239 | 2239 | $modelsdb[$model] = trim($row[0]); |
2240 | 2240 | } |
2241 | 2241 | } |
2242 | 2242 | } |
2243 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2243 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2244 | 2244 | foreach ($diff as $key => $value) { |
2245 | 2245 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
2246 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
2246 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
2247 | 2247 | |
2248 | 2248 | } |
2249 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2249 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2250 | 2250 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2251 | 2251 | if ($error != '') { |
2252 | 2252 | return $error; |
@@ -2258,32 +2258,32 @@ discard block |
||
2258 | 2258 | global $tmp_dir, $globalDebug; |
2259 | 2259 | $error = ''; |
2260 | 2260 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
2261 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
2261 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
2262 | 2262 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2263 | 2263 | if ($globalDebug) echo "Check files...\n"; |
2264 | 2264 | $newmodelsdb = array(); |
2265 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
2266 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2265 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2266 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2267 | 2267 | $model = trim($row[2]); |
2268 | 2268 | $newmodelsdb[$model] = trim($row[0]); |
2269 | 2269 | } |
2270 | 2270 | } |
2271 | 2271 | $modelsdb = array(); |
2272 | 2272 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
2273 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
2274 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2273 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2274 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2275 | 2275 | $model = trim($row[2]); |
2276 | 2276 | $modelsdb[$model] = trim($row[0]); |
2277 | 2277 | } |
2278 | 2278 | } |
2279 | 2279 | } |
2280 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2280 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2281 | 2281 | foreach ($diff as $key => $value) { |
2282 | 2282 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
2283 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2283 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2284 | 2284 | |
2285 | 2285 | } |
2286 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2286 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2287 | 2287 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2288 | 2288 | if ($error != '') { |
2289 | 2289 | return $error; |
@@ -2306,8 +2306,8 @@ discard block |
||
2306 | 2306 | */ |
2307 | 2307 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2308 | 2308 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
2309 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2310 | - $result = fread($fh,100000000); |
|
2309 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
2310 | + $result = fread($fh, 100000000); |
|
2311 | 2311 | //echo $result; |
2312 | 2312 | //var_dump(str_get_html($result)); |
2313 | 2313 | //print_r(self::table2array($result)); |
@@ -2325,23 +2325,23 @@ discard block |
||
2325 | 2325 | $Connection = new Connection(); |
2326 | 2326 | $sth = $Connection->db->prepare($query); |
2327 | 2327 | $sth->execute(); |
2328 | - } catch(PDOException $e) { |
|
2328 | + } catch (PDOException $e) { |
|
2329 | 2329 | return "error : ".$e->getMessage(); |
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | $error = ''; |
2333 | 2333 | if ($globalDebug) echo "Notam : Download..."; |
2334 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
2334 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
2335 | 2335 | if (file_exists($tmp_dir.'notam.rss')) { |
2336 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
2336 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
2337 | 2337 | foreach ($notams['channel']['item'] as $notam) { |
2338 | - $title = explode(':',$notam['title']); |
|
2338 | + $title = explode(':', $notam['title']); |
|
2339 | 2339 | $data['ref'] = trim($title[0]); |
2340 | 2340 | unset($title[0]); |
2341 | - $data['title'] = trim(implode(':',$title)); |
|
2342 | - $description = strip_tags($notam['description'],'<pre>'); |
|
2343 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
2344 | - $q = explode('/',$match[1]); |
|
2341 | + $data['title'] = trim(implode(':', $title)); |
|
2342 | + $description = strip_tags($notam['description'], '<pre>'); |
|
2343 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
2344 | + $q = explode('/', $match[1]); |
|
2345 | 2345 | $data['fir'] = $q[0]; |
2346 | 2346 | $data['code'] = $q[1]; |
2347 | 2347 | $ifrvfr = $q[2]; |
@@ -2357,30 +2357,30 @@ discard block |
||
2357 | 2357 | $data['lower_limit'] = $q[5]; |
2358 | 2358 | $data['upper_limit'] = $q[6]; |
2359 | 2359 | $latlonrad = $q[7]; |
2360 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
2361 | - $latitude = $Common->convertDec($las,'latitude'); |
|
2362 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
2360 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
2361 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
2362 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
2363 | 2363 | if ($lac == 'S') $latitude = '-'.$latitude; |
2364 | 2364 | if ($lnc == 'W') $longitude = '-'.$longitude; |
2365 | 2365 | $data['center_latitude'] = $latitude; |
2366 | 2366 | $data['center_longitude'] = $longitude; |
2367 | 2367 | $data['radius'] = intval($radius); |
2368 | 2368 | |
2369 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
2369 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
2370 | 2370 | $data['text'] = $match[1]; |
2371 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
2371 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
2372 | 2372 | $fromto = $match[1]; |
2373 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
2373 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
2374 | 2374 | $fromall = trim($match[1]); |
2375 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
2375 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
2376 | 2376 | $from = trim($match[1]); |
2377 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
2378 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
2377 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
2378 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
2379 | 2379 | $toall = trim($match[1]); |
2380 | - if (!preg_match(':Permanent:',$toall)) { |
|
2381 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
2380 | + if (!preg_match(':Permanent:', $toall)) { |
|
2381 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
2382 | 2382 | $to = trim($match[1]); |
2383 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
2383 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
2384 | 2384 | $data['permanent'] = 0; |
2385 | 2385 | } else { |
2386 | 2386 | $data['date_end'] = NULL; |
@@ -2388,7 +2388,7 @@ discard block |
||
2388 | 2388 | } |
2389 | 2389 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2390 | 2390 | $NOTAM = new NOTAM(); |
2391 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
2391 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
2392 | 2392 | unset($data); |
2393 | 2393 | } |
2394 | 2394 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2411,16 +2411,16 @@ discard block |
||
2411 | 2411 | $Connection = new Connection(); |
2412 | 2412 | $sth = $Connection->db->prepare($query); |
2413 | 2413 | $sth->execute(); |
2414 | - } catch(PDOException $e) { |
|
2414 | + } catch (PDOException $e) { |
|
2415 | 2415 | return "error : ".$e->getMessage(); |
2416 | 2416 | } |
2417 | 2417 | } |
2418 | 2418 | $Common = new Common(); |
2419 | 2419 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2420 | - $airspace_json = json_decode($airspace_lst,true); |
|
2420 | + $airspace_json = json_decode($airspace_lst, true); |
|
2421 | 2421 | foreach ($airspace_json['records'] as $airspace) { |
2422 | 2422 | if ($globalDebug) echo $airspace['name']."...\n"; |
2423 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
2423 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
2424 | 2424 | if (file_exists($tmp_dir.$airspace['name'])) { |
2425 | 2425 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
2426 | 2426 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2442,7 +2442,7 @@ discard block |
||
2442 | 2442 | $Connection = new Connection(); |
2443 | 2443 | $sth = $Connection->db->prepare($query); |
2444 | 2444 | $sth->execute(array(':new' => $new, ':old' => $old)); |
2445 | - } catch(PDOException $e) { |
|
2445 | + } catch (PDOException $e) { |
|
2446 | 2446 | return "error : ".$e->getMessage(); |
2447 | 2447 | } |
2448 | 2448 | } |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | $Connection = new Connection(); |
2460 | 2460 | $sth = $Connection->db->prepare($query); |
2461 | 2461 | $sth->execute(); |
2462 | - } catch(PDOException $e) { |
|
2462 | + } catch (PDOException $e) { |
|
2463 | 2463 | return "error : ".$e->getMessage(); |
2464 | 2464 | } |
2465 | 2465 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | $Connection = new Connection(); |
2475 | 2475 | $sth = $Connection->db->prepare($query); |
2476 | 2476 | $sth->execute(); |
2477 | - } catch(PDOException $e) { |
|
2477 | + } catch (PDOException $e) { |
|
2478 | 2478 | return "error : ".$e->getMessage(); |
2479 | 2479 | } |
2480 | 2480 | } |
@@ -2485,7 +2485,7 @@ discard block |
||
2485 | 2485 | $Connection = new Connection(); |
2486 | 2486 | $sth = $Connection->db->prepare($query); |
2487 | 2487 | $sth->execute(array(':version' => $version)); |
2488 | - } catch(PDOException $e) { |
|
2488 | + } catch (PDOException $e) { |
|
2489 | 2489 | return "error : ".$e->getMessage(); |
2490 | 2490 | } |
2491 | 2491 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2499,7 +2499,7 @@ discard block |
||
2499 | 2499 | $Connection = new Connection(); |
2500 | 2500 | $sth = $Connection->db->prepare($query); |
2501 | 2501 | $sth->execute(array(':version' => $version)); |
2502 | - } catch(PDOException $e) { |
|
2502 | + } catch (PDOException $e) { |
|
2503 | 2503 | return "error : ".$e->getMessage(); |
2504 | 2504 | } |
2505 | 2505 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2513,7 +2513,7 @@ discard block |
||
2513 | 2513 | $Connection = new Connection(); |
2514 | 2514 | $sth = $Connection->db->prepare($query); |
2515 | 2515 | $sth->execute(array(':version' => $version)); |
2516 | - } catch(PDOException $e) { |
|
2516 | + } catch (PDOException $e) { |
|
2517 | 2517 | return "error : ".$e->getMessage(); |
2518 | 2518 | } |
2519 | 2519 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2529,7 +2529,7 @@ discard block |
||
2529 | 2529 | $Connection = new Connection(); |
2530 | 2530 | $sth = $Connection->db->prepare($query); |
2531 | 2531 | $sth->execute(array(':version' => $version)); |
2532 | - } catch(PDOException $e) { |
|
2532 | + } catch (PDOException $e) { |
|
2533 | 2533 | return "error : ".$e->getMessage(); |
2534 | 2534 | } |
2535 | 2535 | } |
@@ -2541,7 +2541,7 @@ discard block |
||
2541 | 2541 | $Connection = new Connection(); |
2542 | 2542 | $sth = $Connection->db->prepare($query); |
2543 | 2543 | $sth->execute(array(':version' => $version)); |
2544 | - } catch(PDOException $e) { |
|
2544 | + } catch (PDOException $e) { |
|
2545 | 2545 | return "error : ".$e->getMessage(); |
2546 | 2546 | } |
2547 | 2547 | } |
@@ -2553,7 +2553,7 @@ discard block |
||
2553 | 2553 | $Connection = new Connection(); |
2554 | 2554 | $sth = $Connection->db->prepare($query); |
2555 | 2555 | $sth->execute(array(':version' => $version)); |
2556 | - } catch(PDOException $e) { |
|
2556 | + } catch (PDOException $e) { |
|
2557 | 2557 | return "error : ".$e->getMessage(); |
2558 | 2558 | } |
2559 | 2559 | } |
@@ -2569,7 +2569,7 @@ discard block |
||
2569 | 2569 | $Connection = new Connection(); |
2570 | 2570 | $sth = $Connection->db->prepare($query); |
2571 | 2571 | $sth->execute(); |
2572 | - } catch(PDOException $e) { |
|
2572 | + } catch (PDOException $e) { |
|
2573 | 2573 | return "error : ".$e->getMessage(); |
2574 | 2574 | } |
2575 | 2575 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2584,7 +2584,7 @@ discard block |
||
2584 | 2584 | $Connection = new Connection(); |
2585 | 2585 | $sth = $Connection->db->prepare($query); |
2586 | 2586 | $sth->execute(); |
2587 | - } catch(PDOException $e) { |
|
2587 | + } catch (PDOException $e) { |
|
2588 | 2588 | return "error : ".$e->getMessage(); |
2589 | 2589 | } |
2590 | 2590 | } |
@@ -2600,7 +2600,7 @@ discard block |
||
2600 | 2600 | $Connection = new Connection(); |
2601 | 2601 | $sth = $Connection->db->prepare($query); |
2602 | 2602 | $sth->execute(); |
2603 | - } catch(PDOException $e) { |
|
2603 | + } catch (PDOException $e) { |
|
2604 | 2604 | return "error : ".$e->getMessage(); |
2605 | 2605 | } |
2606 | 2606 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2615,7 +2615,7 @@ discard block |
||
2615 | 2615 | $Connection = new Connection(); |
2616 | 2616 | $sth = $Connection->db->prepare($query); |
2617 | 2617 | $sth->execute(); |
2618 | - } catch(PDOException $e) { |
|
2618 | + } catch (PDOException $e) { |
|
2619 | 2619 | return "error : ".$e->getMessage(); |
2620 | 2620 | } |
2621 | 2621 | } |
@@ -2631,7 +2631,7 @@ discard block |
||
2631 | 2631 | $Connection = new Connection(); |
2632 | 2632 | $sth = $Connection->db->prepare($query); |
2633 | 2633 | $sth->execute(); |
2634 | - } catch(PDOException $e) { |
|
2634 | + } catch (PDOException $e) { |
|
2635 | 2635 | return "error : ".$e->getMessage(); |
2636 | 2636 | } |
2637 | 2637 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2646,7 +2646,7 @@ discard block |
||
2646 | 2646 | $Connection = new Connection(); |
2647 | 2647 | $sth = $Connection->db->prepare($query); |
2648 | 2648 | $sth->execute(); |
2649 | - } catch(PDOException $e) { |
|
2649 | + } catch (PDOException $e) { |
|
2650 | 2650 | return "error : ".$e->getMessage(); |
2651 | 2651 | } |
2652 | 2652 | } |
@@ -2662,7 +2662,7 @@ discard block |
||
2662 | 2662 | $Connection = new Connection(); |
2663 | 2663 | $sth = $Connection->db->prepare($query); |
2664 | 2664 | $sth->execute(); |
2665 | - } catch(PDOException $e) { |
|
2665 | + } catch (PDOException $e) { |
|
2666 | 2666 | return "error : ".$e->getMessage(); |
2667 | 2667 | } |
2668 | 2668 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2677,7 +2677,7 @@ discard block |
||
2677 | 2677 | $Connection = new Connection(); |
2678 | 2678 | $sth = $Connection->db->prepare($query); |
2679 | 2679 | $sth->execute(); |
2680 | - } catch(PDOException $e) { |
|
2680 | + } catch (PDOException $e) { |
|
2681 | 2681 | return "error : ".$e->getMessage(); |
2682 | 2682 | } |
2683 | 2683 | } |
@@ -2692,7 +2692,7 @@ discard block |
||
2692 | 2692 | $Connection = new Connection(); |
2693 | 2693 | $sth = $Connection->db->prepare($query); |
2694 | 2694 | $sth->execute(); |
2695 | - } catch(PDOException $e) { |
|
2695 | + } catch (PDOException $e) { |
|
2696 | 2696 | return "error : ".$e->getMessage(); |
2697 | 2697 | } |
2698 | 2698 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2707,7 +2707,7 @@ discard block |
||
2707 | 2707 | $Connection = new Connection(); |
2708 | 2708 | $sth = $Connection->db->prepare($query); |
2709 | 2709 | $sth->execute(); |
2710 | - } catch(PDOException $e) { |
|
2710 | + } catch (PDOException $e) { |
|
2711 | 2711 | return "error : ".$e->getMessage(); |
2712 | 2712 | } |
2713 | 2713 | } |
@@ -2722,7 +2722,7 @@ discard block |
||
2722 | 2722 | $Connection = new Connection(); |
2723 | 2723 | $sth = $Connection->db->prepare($query); |
2724 | 2724 | $sth->execute(); |
2725 | - } catch(PDOException $e) { |
|
2725 | + } catch (PDOException $e) { |
|
2726 | 2726 | return "error : ".$e->getMessage(); |
2727 | 2727 | } |
2728 | 2728 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2737,7 +2737,7 @@ discard block |
||
2737 | 2737 | $Connection = new Connection(); |
2738 | 2738 | $sth = $Connection->db->prepare($query); |
2739 | 2739 | $sth->execute(); |
2740 | - } catch(PDOException $e) { |
|
2740 | + } catch (PDOException $e) { |
|
2741 | 2741 | return "error : ".$e->getMessage(); |
2742 | 2742 | } |
2743 | 2743 | } |
@@ -2752,7 +2752,7 @@ discard block |
||
2752 | 2752 | $Connection = new Connection(); |
2753 | 2753 | $sth = $Connection->db->prepare($query); |
2754 | 2754 | $sth->execute(); |
2755 | - } catch(PDOException $e) { |
|
2755 | + } catch (PDOException $e) { |
|
2756 | 2756 | return "error : ".$e->getMessage(); |
2757 | 2757 | } |
2758 | 2758 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2767,7 +2767,7 @@ discard block |
||
2767 | 2767 | $Connection = new Connection(); |
2768 | 2768 | $sth = $Connection->db->prepare($query); |
2769 | 2769 | $sth->execute(); |
2770 | - } catch(PDOException $e) { |
|
2770 | + } catch (PDOException $e) { |
|
2771 | 2771 | return "error : ".$e->getMessage(); |
2772 | 2772 | } |
2773 | 2773 | } |
@@ -2782,7 +2782,7 @@ discard block |
||
2782 | 2782 | $Connection = new Connection(); |
2783 | 2783 | $sth = $Connection->db->prepare($query); |
2784 | 2784 | $sth->execute(); |
2785 | - } catch(PDOException $e) { |
|
2785 | + } catch (PDOException $e) { |
|
2786 | 2786 | return "error : ".$e->getMessage(); |
2787 | 2787 | } |
2788 | 2788 | } |
@@ -2797,7 +2797,7 @@ discard block |
||
2797 | 2797 | $Connection = new Connection(); |
2798 | 2798 | $sth = $Connection->db->prepare($query); |
2799 | 2799 | $sth->execute(); |
2800 | - } catch(PDOException $e) { |
|
2800 | + } catch (PDOException $e) { |
|
2801 | 2801 | return "error : ".$e->getMessage(); |
2802 | 2802 | } |
2803 | 2803 | } |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | die; |
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
49 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | 57 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
59 | 59 | else $globalSources[] = array('host' => $options['s']); |
60 | 60 | } elseif (isset($options['source'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['source']); |
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; |
79 | - $SI=new SpotterServer(); |
|
79 | + $SI = new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
83 | 83 | $SI->connect(); |
84 | 84 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | +} else $SI = new SpotterImport($Connection->db); |
|
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | 88 | $AIS = new AIS(); |
89 | 89 | $MI = new MarineImport($Connection->db); |
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | -$SBS=new SBS(); |
|
93 | -$ACARS=new ACARS($Connection->db); |
|
94 | -$Source=new Source($Connection->db); |
|
95 | -$Common=new Common(); |
|
92 | +$SBS = new SBS(); |
|
93 | +$ACARS = new ACARS($Connection->db); |
|
94 | +$Source = new Source($Connection->db); |
|
95 | +$Common = new Common(); |
|
96 | 96 | date_default_timezone_set('UTC'); |
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | 101 | global $sockets; |
102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
103 | 103 | die("Bye!\n"); |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
117 | 117 | $reset++; |
118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
119 | 119 | foreach ($hosts as $id => $value) { |
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'deltadbtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 127 | //$last_exec['deltadbtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'vatsimtxt'; |
131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 132 | //$last_exec['vatsimtxt'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
139 | + } else if (preg_match('/opensky/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'planeupdatefaa'; |
158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 159 | //$last_exec['planeupdatefaa'] = 0; |
@@ -162,29 +162,29 @@ discard block |
||
162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 163 | exit(0); |
164 | 164 | } |
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 168 | //$last_exec['phpvmacars'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
170 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'phpvmacars'; |
172 | 172 | $globalSources[$id]['format'] = 'vam'; |
173 | 173 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
174 | + } else if (preg_match('/whazzup/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'whazzup'; |
176 | 176 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 177 | //$last_exec['whazzup'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
179 | + } else if (preg_match('/airwhere/i', $host)) { |
|
180 | 180 | $globalSources[$id]['format'] = 'airwhere'; |
181 | 181 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
182 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
183 | 183 | //$formats[$id] = 'pirepsjson'; |
184 | 184 | $globalSources[$id]['format'] = 'pirepsjson'; |
185 | 185 | //$last_exec['pirepsjson'] = 0; |
186 | 186 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
188 | 188 | //$formats[$id] = 'fr24json'; |
189 | 189 | $globalSources[$id]['format'] = 'fr24json'; |
190 | 190 | //$last_exec['fr24json'] = 0; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
194 | 194 | exit(0); |
195 | 195 | } |
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
196 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
197 | 197 | //$formats[$id] = 'fr24json'; |
198 | 198 | $globalSources[$id]['format'] = 'myshiptracking'; |
199 | 199 | //$last_exec['fr24json'] = 0; |
@@ -203,22 +203,22 @@ discard block |
||
203 | 203 | exit(0); |
204 | 204 | } |
205 | 205 | //} else if (preg_match('/10001/',$host)) { |
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
206 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | 207 | //$formats[$id] = 'tsv'; |
208 | 208 | $globalSources[$id]['format'] = 'tsv'; |
209 | 209 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
210 | 210 | } |
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
211 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
212 | 212 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
213 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
214 | 214 | if ($idf !== false) { |
215 | 215 | $httpfeeds[$id] = $idf; |
216 | 216 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
217 | 217 | } |
218 | 218 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
219 | 219 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
220 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':', $host); |
|
222 | 222 | if (isset($hostport[1])) { |
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | } |
229 | 229 | $Common = new Common(); |
230 | 230 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
231 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
232 | 232 | } else { |
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
233 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
234 | 234 | } |
235 | 235 | if ($s) { |
236 | 236 | $sockets[$id] = $s; |
237 | 237 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
238 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | 245 | } elseif ($port == '10001') { |
246 | 246 | //$formats[$id] = 'tsv'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
280 | 280 | else $timeout = 20; |
281 | 281 | $errno = ''; |
282 | -$errstr=''; |
|
282 | +$errstr = ''; |
|
283 | 283 | |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | /* Initiate connections to all the hosts simultaneously */ |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | 292 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
293 | 293 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | |
315 | 315 | if ($use_aprs) { |
316 | 316 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
317 | - $APRS=new APRS(); |
|
317 | + $APRS = new APRS(); |
|
318 | 318 | $aprs_connect = 0; |
319 | 319 | $aprs_keep = 120; |
320 | 320 | $aprs_last_tx = time(); |
321 | 321 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
322 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
322 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
323 | 323 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
324 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
324 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
325 | 325 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
326 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
327 | 327 | if ($aprs_full) $aprs_filter = ''; |
328 | 328 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
329 | 329 | else $aprs_pass = '-1'; |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | sleep(1); |
338 | 338 | if ($globalDebug) echo "SCAN MODE \n\n"; |
339 | 339 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
340 | -$endtime = time()+$globalCronEnd; |
|
340 | +$endtime = time() + $globalCronEnd; |
|
341 | 341 | $i = 1; |
342 | 342 | $tt = array(); |
343 | 343 | // Delete all ATC |
344 | 344 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
345 | - $ATC=new ATC($Connection->db); |
|
345 | + $ATC = new ATC($Connection->db); |
|
346 | 346 | } |
347 | 347 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
348 | 348 | $ATC->deleteAll(); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 352 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
353 | + if (!$globalDaemon) $i = $endtime - time(); |
|
354 | 354 | // Delete old ATC |
355 | 355 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | } |
365 | 365 | if ($max != $globalMinFetch) { |
366 | 366 | if ($globalDebug) echo 'Sleeping...'."\n"; |
367 | - sleep($globalMinFetch-$max+2); |
|
367 | + sleep($globalMinFetch - $max + 2); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | //$buffer = $Common->getData($hosts[$id]); |
378 | 378 | $buffer = $Common->getData($value['host']); |
379 | 379 | if ($buffer != '') $reset = 0; |
380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | - $buffer = explode('\n',$buffer); |
|
380 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
381 | + $buffer = explode('\n', $buffer); |
|
382 | 382 | foreach ($buffer as $line) { |
383 | 383 | if ($line != '' && count($line) > 7) { |
384 | 384 | $line = explode(',', $line); |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | $last_exec[$id]['last'] = time(); |
407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
408 | 408 | date_default_timezone_set('CET'); |
409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
409 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | if ($buffer != '') $reset = 0; |
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
412 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
413 | + $buffer = explode('\n', $buffer); |
|
414 | 414 | foreach ($buffer as $line) { |
415 | 415 | if ($line != '') { |
416 | 416 | //echo "'".$line."'\n"; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
429 | 429 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
430 | 430 | if (isset($ais_data['timestamp'])) { |
431 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
431 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
433 | 433 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
434 | 434 | $add = true; |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | $w = $e = null; |
452 | 452 | |
453 | 453 | if (isset($arr[$id])) { |
454 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
454 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
455 | 455 | if ($nn > 0) { |
456 | 456 | foreach ($httpfeeds as $feed) { |
457 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
458 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
459 | - $buffer = explode('\n',$buffer); |
|
457 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
458 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
459 | + $buffer = explode('\n', $buffer); |
|
460 | 460 | foreach ($buffer as $line) { |
461 | 461 | if ($line != '') { |
462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
475 | 475 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
477 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
477 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
478 | 478 | if (isset($ais_data['timestamp'])) { |
479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
479 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
480 | 480 | } else { |
481 | 481 | $data['datetime'] = date('Y-m-d H:i:s'); |
482 | 482 | } |
@@ -502,10 +502,10 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
505 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
506 | 506 | if ($buffer != '') { |
507 | 507 | //echo $buffer; |
508 | - $all_data = json_decode($buffer,true); |
|
508 | + $all_data = json_decode($buffer, true); |
|
509 | 509 | //print_r($all_data); |
510 | 510 | if (isset($all_data[0]['DATA'])) { |
511 | 511 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
521 | 521 | $data['imo'] = $line['IMO']; |
522 | 522 | //$data['arrival_code'] = $ais_data['destination']; |
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
524 | 524 | $data['format_source'] = 'myshiptracking'; |
525 | 525 | $data['id_source'] = $id_source; |
526 | 526 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | } |
533 | 533 | $last_exec[$id]['last'] = time(); |
534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
535 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
536 | 536 | if ($buffer != '') { |
537 | - $all_data = json_decode($buffer,true); |
|
537 | + $all_data = json_decode($buffer, true); |
|
538 | 538 | if (isset($all_data[0]['mmsi'])) { |
539 | 539 | foreach ($all_data as $line) { |
540 | 540 | if ($line != '') { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
564 | 564 | $buffer = $Common->getData($value['host']); |
565 | 565 | if ($buffer != '') { |
566 | - $all_data = json_decode($buffer,true); |
|
566 | + $all_data = json_decode($buffer, true); |
|
567 | 567 | if (isset($all_data['features'][0]['id'])) { |
568 | 568 | foreach ($all_data['features'] as $line) { |
569 | 569 | $data = array(); |
@@ -591,27 +591,27 @@ discard block |
||
591 | 591 | $last_exec[$id]['last'] = time(); |
592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
593 | 593 | echo 'download...'; |
594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
594 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
595 | 595 | echo 'done !'."\n"; |
596 | 596 | if ($buffer != '') $reset = 0; |
597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | - $buffer = explode('\n',$buffer); |
|
597 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
598 | + $buffer = explode('\n', $buffer); |
|
599 | 599 | foreach ($buffer as $line) { |
600 | 600 | if ($line != '') { |
601 | 601 | $data = array(); |
602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
602 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
604 | 604 | //$data['status'] = substr($line,21,2); |
605 | 605 | //$data['type'] = substr($line,24,3); |
606 | - $data['latitude'] = substr($line,29,9); |
|
607 | - $data['longitude'] = substr($line,41,9); |
|
608 | - $data['speed'] = round(substr($line,51,5)); |
|
606 | + $data['latitude'] = substr($line, 29, 9); |
|
607 | + $data['longitude'] = substr($line, 41, 9); |
|
608 | + $data['speed'] = round(substr($line, 51, 5)); |
|
609 | 609 | //$data['course'] = substr($line,57,5); |
610 | - $data['heading'] = round(substr($line,63,3)); |
|
610 | + $data['heading'] = round(substr($line, 63, 3)); |
|
611 | 611 | //$data['draft'] = substr($line,67,4); |
612 | 612 | //$data['length'] = substr($line,72,3); |
613 | 613 | //$data['beam'] = substr($line,76,2); |
614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
614 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
615 | 615 | //$data['callsign'] = trim(substr($line,100,7); |
616 | 616 | //$data['dest'] = substr($line,108,20); |
617 | 617 | //$data['etaDate'] = substr($line,129,5); |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
631 | 631 | //$buffer = $Common->getData($hosts[$id]); |
632 | 632 | $buffer = $Common->getData($value['host']); |
633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | - $buffer = explode('\n',$buffer); |
|
633 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
634 | + $buffer = explode('\n', $buffer); |
|
635 | 635 | $reset = 0; |
636 | 636 | foreach ($buffer as $line) { |
637 | 637 | if ($line != '') { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
643 | 643 | $data['pilot_id'] = $line[1]; |
644 | 644 | $data['pilot_name'] = $line[2]; |
645 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
645 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
646 | 646 | $data['ident'] = $line[0]; // ident |
647 | 647 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
648 | 648 | $data['speed'] = $line[8]; // speed |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
660 | 660 | $data['departure_airport_icao'] = $line[11]; |
661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
662 | 662 | $data['arrival_airport_icao'] = $line[13]; |
663 | 663 | $data['frequency'] = $line[4]; |
664 | 664 | $data['type'] = $line[18]; |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $data['id_source'] = $id_source; |
668 | 668 | //$data['arrival_airport_time'] = ; |
669 | 669 | if ($line[9] != '') { |
670 | - $aircraft_data = explode('/',$line[9]); |
|
670 | + $aircraft_data = explode('/', $line[9]); |
|
671 | 671 | if (isset($aircraft_data[1])) { |
672 | 672 | $data['aircraft_icao'] = $aircraft_data[1]; |
673 | 673 | } |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | if ($line[3] == 'PILOT') $SI->add($data); |
683 | 683 | elseif ($line[3] == 'ATC') { |
684 | 684 | //print_r($data); |
685 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
686 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
687 | - $typec = substr($data['ident'],-3); |
|
685 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
686 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
687 | + $typec = substr($data['ident'], -3); |
|
688 | 688 | if ($typec == 'APP') $data['type'] = 'Approach'; |
689 | 689 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
690 | 690 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
697 | 697 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
698 | 698 | if (isset($ATC)) { |
699 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
700 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
699 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
700 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | unset($data); |
@@ -708,24 +708,24 @@ discard block |
||
708 | 708 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
709 | 709 | $last_exec[$id]['last'] = time(); |
710 | 710 | } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
712 | 712 | if ($buffer != '') { |
713 | 713 | $all_data = simplexml_load_string($buffer); |
714 | - foreach($all_data->children() as $childdata) { |
|
714 | + foreach ($all_data->children() as $childdata) { |
|
715 | 715 | $data = array(); |
716 | 716 | $line = $childdata; |
717 | 717 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
718 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
719 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
720 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
721 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
724 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
718 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
719 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
720 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
721 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
722 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
723 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
724 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
725 | 725 | $data['altitude_relative'] = 'AMSL'; |
726 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
726 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
727 | 727 | $data['aircraft_icao'] = 'PARAGLIDER'; |
728 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
728 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
729 | 729 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
730 | 730 | $data['format_source'] = $value['format']; |
731 | 731 | $SI->add($data); |
@@ -733,31 +733,31 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | $Source->deleteOldLocationByType('gs'); |
736 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
736 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
737 | 737 | if ($buffer != '') { |
738 | 738 | $all_data = simplexml_load_string($buffer); |
739 | - foreach($all_data->children() as $childdata) { |
|
739 | + foreach ($all_data->children() as $childdata) { |
|
740 | 740 | $data = array(); |
741 | 741 | $line = $childdata; |
742 | - $data['id'] = (int)$line['gsID']; |
|
743 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
744 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
745 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
742 | + $data['id'] = (int) $line['gsID']; |
|
743 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
744 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
745 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
746 | 746 | $data['altitude_relative'] = 'AMSL'; |
747 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
747 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
748 | 748 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
749 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
749 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
750 | 750 | } else { |
751 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
751 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
752 | 752 | } |
753 | 753 | unset($data); |
754 | 754 | } |
755 | 755 | } |
756 | 756 | $last_exec[$id]['last'] = time(); |
757 | 757 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
758 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
758 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
759 | 759 | if ($buffer != '') { |
760 | - $all_data = json_decode($buffer,true); |
|
760 | + $all_data = json_decode($buffer, true); |
|
761 | 761 | if (isset($all_data['acList'])) { |
762 | 762 | $reset = 0; |
763 | 763 | foreach ($all_data['acList'] as $line) { |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $data['emergency'] = ''; // emergency |
775 | 775 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
776 | 776 | |
777 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
777 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
778 | 778 | else $data['datetime'] = date('Y-m-d H:i:s'); |
779 | 779 | |
780 | 780 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $data['verticalrate'] = $line['vrt']; // verticale rate |
801 | 801 | $data['squawk'] = $line['squawk']; // squawk |
802 | 802 | $data['emergency'] = ''; // emergency |
803 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
803 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
804 | 804 | else $data['datetime'] = date('Y-m-d H:i:s'); |
805 | 805 | $data['format_source'] = 'aircraftlistjson'; |
806 | 806 | $data['id_source'] = $id_source; |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
817 | 817 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
818 | 818 | $buffer = $Common->getData($value['host']); |
819 | - $all_data = json_decode($buffer,true); |
|
819 | + $all_data = json_decode($buffer, true); |
|
820 | 820 | if (isset($all_data['planes'])) { |
821 | 821 | $reset = 0; |
822 | 822 | foreach ($all_data['planes'] as $key => $line) { |
@@ -833,12 +833,12 @@ discard block |
||
833 | 833 | $data['emergency'] = ''; // emergency |
834 | 834 | $data['registration'] = $line[2]; |
835 | 835 | $data['aircraft_icao'] = $line[0]; |
836 | - $deparr = explode('-',$line[1]); |
|
836 | + $deparr = explode('-', $line[1]); |
|
837 | 837 | if (count($deparr) == 2) { |
838 | 838 | $data['departure_airport_icao'] = $deparr[0]; |
839 | 839 | $data['arrival_airport_icao'] = $deparr[1]; |
840 | 840 | } |
841 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
841 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
842 | 842 | $data['format_source'] = 'planeupdatefaa'; |
843 | 843 | $data['id_source'] = $id_source; |
844 | 844 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $last_exec[$id]['last'] = time(); |
852 | 852 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
853 | 853 | $buffer = $Common->getData($value['host']); |
854 | - $all_data = json_decode($buffer,true); |
|
854 | + $all_data = json_decode($buffer, true); |
|
855 | 855 | if (isset($all_data['states'])) { |
856 | 856 | $reset = 0; |
857 | 857 | foreach ($all_data['states'] as $key => $line) { |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | //$data['emergency'] = ''; // emergency |
869 | 869 | //$data['registration'] = $line[2]; |
870 | 870 | //$data['aircraft_icao'] = $line[0]; |
871 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
871 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
872 | 872 | $data['format_source'] = 'opensky'; |
873 | 873 | $data['id_source'] = $id_source; |
874 | 874 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
883 | 883 | //$buffer = $Common->getData($hosts[$id]); |
884 | 884 | $buffer = $Common->getData($value['host']); |
885 | - $all_data = json_decode($buffer,true); |
|
885 | + $all_data = json_decode($buffer, true); |
|
886 | 886 | if (!empty($all_data)) $reset = 0; |
887 | 887 | foreach ($all_data as $key => $line) { |
888 | 888 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -915,11 +915,11 @@ discard block |
||
915 | 915 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
916 | 916 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
917 | 917 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
918 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
918 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
919 | 919 | //echo $buffer; |
920 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
921 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
922 | - $all_data = json_decode($buffer,true); |
|
920 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
921 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
922 | + $all_data = json_decode($buffer, true); |
|
923 | 923 | if (json_last_error() != JSON_ERROR_NONE) { |
924 | 924 | die(json_last_error_msg()); |
925 | 925 | } |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | //$data['departure_airport_iata'] = $line[11]; |
943 | 943 | //$data['arrival_airport_iata'] = $line[12]; |
944 | 944 | //$data['emergency'] = ''; // emergency |
945 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
945 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
946 | 946 | $data['format_source'] = 'radarvirtueljson'; |
947 | 947 | $data['id_source'] = $id_source; |
948 | 948 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
959 | 959 | //$buffer = $Common->getData($hosts[$id]); |
960 | 960 | $buffer = $Common->getData($value['host'].'?'.time()); |
961 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
961 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
962 | 962 | |
963 | 963 | if (isset($all_data['pireps'])) { |
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data['pireps'] as $line) { |
966 | 966 | $data = array(); |
967 | 967 | $data['id'] = $line['id']; |
968 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
968 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
969 | 969 | $data['ident'] = $line['callsign']; // ident |
970 | 970 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
971 | 971 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -995,9 +995,9 @@ discard block |
||
995 | 995 | $SI->add($data); |
996 | 996 | // print_r($data); |
997 | 997 | } elseif ($line['icon'] == 'ct') { |
998 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
999 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1000 | - $typec = substr($data['ident'],-3); |
|
998 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
999 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1000 | + $typec = substr($data['ident'], -3); |
|
1001 | 1001 | $data['type'] = ''; |
1002 | 1002 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1003 | 1003 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1009 | 1009 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1010 | 1010 | else $data['type'] = 'Observer'; |
1011 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1011 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
1012 | 1012 | } |
1013 | 1013 | unset($data); |
1014 | 1014 | } |
@@ -1020,14 +1020,14 @@ discard block |
||
1020 | 1020 | //$buffer = $Common->getData($hosts[$id]); |
1021 | 1021 | if ($globalDebug) echo 'Get Data...'."\n"; |
1022 | 1022 | $buffer = $Common->getData($value['host']); |
1023 | - $all_data = json_decode($buffer,true); |
|
1023 | + $all_data = json_decode($buffer, true); |
|
1024 | 1024 | if ($buffer != '' && is_array($all_data)) { |
1025 | 1025 | $reset = 0; |
1026 | 1026 | foreach ($all_data as $line) { |
1027 | 1027 | $data = array(); |
1028 | 1028 | //$data['id'] = $line['id']; // id not usable |
1029 | 1029 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1030 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1030 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1031 | 1031 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1032 | 1032 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1033 | 1033 | $data['ident'] = $line['flightnum']; // ident |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | //$data['datetime'] = $line['lastupdate']; |
1043 | 1043 | //$data['last_update'] = $line['lastupdate']; |
1044 | 1044 | if (isset($value['timezone'])) { |
1045 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1045 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1046 | 1046 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1047 | 1047 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1048 | 1048 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1056 | 1056 | if (isset($line['aircraftname'])) { |
1057 | 1057 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1058 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1059 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1058 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1059 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1060 | 1060 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1061 | 1061 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1062 | 1062 | else { |
1063 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1064 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1065 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1063 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1064 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1065 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1082,14 +1082,14 @@ discard block |
||
1082 | 1082 | //$buffer = $Common->getData($hosts[$id]); |
1083 | 1083 | if ($globalDebug) echo 'Get Data...'."\n"; |
1084 | 1084 | $buffer = $Common->getData($value['host']); |
1085 | - $all_data = json_decode($buffer,true); |
|
1085 | + $all_data = json_decode($buffer, true); |
|
1086 | 1086 | if ($buffer != '' && is_array($all_data)) { |
1087 | 1087 | $reset = 0; |
1088 | 1088 | foreach ($all_data as $line) { |
1089 | 1089 | $data = array(); |
1090 | 1090 | //$data['id'] = $line['id']; // id not usable |
1091 | 1091 | $data['id'] = trim($line['flight_id']); |
1092 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1092 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1093 | 1093 | $data['pilot_name'] = $line['pilot_name']; |
1094 | 1094 | $data['pilot_id'] = $line['pilot_id']; |
1095 | 1095 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | //$value = $formats[$nb]; |
1142 | 1142 | $format = $globalSources[$nb]['format']; |
1143 | 1143 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1144 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1144 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1145 | 1145 | } elseif ($format == 'vrstcp') { |
1146 | 1146 | $buffer = @socket_read($r, 6000); |
1147 | 1147 | } else { |
1148 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1148 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1149 | 1149 | } |
1150 | 1150 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1151 | 1151 | //echo $buffer."\n"; |
@@ -1154,8 +1154,8 @@ discard block |
||
1154 | 1154 | $error = false; |
1155 | 1155 | //$SI::del(); |
1156 | 1156 | if ($format == 'vrstcp') { |
1157 | - $buffer = explode('},{',$buffer); |
|
1158 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1157 | + $buffer = explode('},{', $buffer); |
|
1158 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1159 | 1159 | // SBS format is CSV format |
1160 | 1160 | if ($buffer !== FALSE && $buffer != '') { |
1161 | 1161 | $tt[$format] = 0; |
@@ -1189,13 +1189,13 @@ discard block |
||
1189 | 1189 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1190 | 1190 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1191 | 1191 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1192 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1192 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1193 | 1193 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1194 | 1194 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1195 | 1195 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1196 | 1196 | |
1197 | 1197 | if (isset($ais_data['timestamp'])) { |
1198 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1198 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1199 | 1199 | } else { |
1200 | 1200 | $data['datetime'] = date('Y-m-d H:i:s'); |
1201 | 1201 | } |
@@ -1206,10 +1206,10 @@ discard block |
||
1206 | 1206 | } elseif ($format == 'flightgearsp') { |
1207 | 1207 | //echo $buffer."\n"; |
1208 | 1208 | if (strlen($buffer) > 5) { |
1209 | - $line = explode(',',$buffer); |
|
1209 | + $line = explode(',', $buffer); |
|
1210 | 1210 | $data = array(); |
1211 | 1211 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1212 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1212 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1213 | 1213 | $data['ident'] = $line[6]; |
1214 | 1214 | $data['aircraft_name'] = $line[7]; |
1215 | 1215 | $data['longitude'] = $line[1]; |
@@ -1226,16 +1226,16 @@ discard block |
||
1226 | 1226 | } elseif ($format == 'acars') { |
1227 | 1227 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1228 | 1228 | $ACARS->add(trim($buffer)); |
1229 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1229 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1230 | 1230 | $ACARS->deleteLiveAcarsData(); |
1231 | 1231 | } elseif ($format == 'flightgearmp') { |
1232 | - if (substr($buffer,0,1) != '#') { |
|
1232 | + if (substr($buffer, 0, 1) != '#') { |
|
1233 | 1233 | $data = array(); |
1234 | 1234 | //echo $buffer."\n"; |
1235 | - $line = explode(' ',$buffer); |
|
1235 | + $line = explode(' ', $buffer); |
|
1236 | 1236 | if (count($line) == 11) { |
1237 | - $userserver = explode('@',$line[0]); |
|
1238 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1237 | + $userserver = explode('@', $line[0]); |
|
1238 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1239 | 1239 | $data['ident'] = $userserver[0]; |
1240 | 1240 | $data['registration'] = $userserver[0]; |
1241 | 1241 | $data['latitude'] = $line[4]; |
@@ -1243,8 +1243,8 @@ discard block |
||
1243 | 1243 | $data['altitude'] = $line[6]; |
1244 | 1244 | $data['datetime'] = date('Y-m-d H:i:s'); |
1245 | 1245 | $aircraft_type = $line[10]; |
1246 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1247 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1246 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1247 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1248 | 1248 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1249 | 1249 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1250 | 1250 | } |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1254 | 1254 | die; |
1255 | 1255 | } elseif ($format == 'vrstcp') { |
1256 | - foreach($buffer as $all_data) { |
|
1257 | - $line = json_decode('{'.$all_data.'}',true); |
|
1256 | + foreach ($buffer as $all_data) { |
|
1257 | + $line = json_decode('{'.$all_data.'}', true); |
|
1258 | 1258 | $data = array(); |
1259 | 1259 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1260 | 1260 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1280,16 +1280,16 @@ discard block |
||
1280 | 1280 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1281 | 1281 | unset($data); |
1282 | 1282 | } |
1283 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1283 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1284 | 1284 | $line = explode("\t", $buffer); |
1285 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1285 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1286 | 1286 | $key = $line[$k]; |
1287 | - $lined[$key] = $line[$k+1]; |
|
1287 | + $lined[$key] = $line[$k + 1]; |
|
1288 | 1288 | } |
1289 | 1289 | if (count($lined) > 3) { |
1290 | 1290 | $data['hex'] = $lined['hexid']; |
1291 | 1291 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1292 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1292 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1293 | 1293 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1294 | 1294 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1295 | 1295 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1308,22 +1308,22 @@ discard block |
||
1308 | 1308 | } else $error = true; |
1309 | 1309 | } elseif ($format == 'aprs' && $use_aprs) { |
1310 | 1310 | if ($aprs_connect == 0) { |
1311 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1311 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1312 | 1312 | $aprs_connect = 1; |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1315 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1316 | 1316 | $aprs_last_tx = time(); |
1317 | 1317 | $data_aprs = "# Keep alive"; |
1318 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1318 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1322 | 1322 | //echo 'APRS data : '.$buffer."\n"; |
1323 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1324 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1323 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1324 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1325 | 1325 | //echo $buffer."\n"; |
1326 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1326 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1327 | 1327 | $line = $APRS->parse($buffer); |
1328 | 1328 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1329 | 1329 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1339 | 1339 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1340 | 1340 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1341 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1341 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1342 | 1342 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1343 | 1343 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1344 | 1344 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1386,9 +1386,9 @@ discard block |
||
1386 | 1386 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1387 | 1387 | $Source->deleteOldLocationByType('gs'); |
1388 | 1388 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
1389 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1389 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1390 | 1390 | } else { |
1391 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1391 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1392 | 1392 | } |
1393 | 1393 | } else { |
1394 | 1394 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1404 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1404 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1405 | 1405 | } |
1406 | 1406 | /* |
1407 | 1407 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | connect_all($sourceee); |
1489 | 1489 | $sourceee = array(); |
1490 | 1490 | //connect_all($globalSources); |
1491 | - $tt[$format]=0; |
|
1491 | + $tt[$format] = 0; |
|
1492 | 1492 | break; |
1493 | 1493 | } |
1494 | 1494 | } |
@@ -1497,14 +1497,14 @@ discard block |
||
1497 | 1497 | } else { |
1498 | 1498 | $error = socket_strerror(socket_last_error()); |
1499 | 1499 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1500 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1500 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1501 | 1501 | if (isset($globalDebug)) echo "Restarting...\n"; |
1502 | 1502 | // Restart the script if possible |
1503 | 1503 | if (is_array($sockets)) { |
1504 | 1504 | if ($globalDebug) echo "Shutdown all sockets..."; |
1505 | 1505 | |
1506 | 1506 | foreach ($sockets as $sock) { |
1507 | - @socket_shutdown($sock,2); |
|
1507 | + @socket_shutdown($sock, 2); |
|
1508 | 1508 | @socket_close($sock); |
1509 | 1509 | } |
1510 | 1510 |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $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); |
|
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); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($spotter_array) || $usecoord) { |
154 | 154 | if ($usecoord) { |
155 | 155 | if (isset($_GET['archive'])) { |
156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
157 | 157 | } else { |
158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($flightcnt == '') $flightcnt = 0; |
162 | 162 | } else $flightcnt = 0; |
163 | 163 | |
164 | -$sqltime = round(microtime(true)-$begintime,2); |
|
164 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
165 | 165 | |
166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
167 | 167 | else $usenextlatlon = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (!empty($spotter_array) && is_array($spotter_array)) |
179 | 179 | { |
180 | 180 | $output .= '"features": ['; |
181 | - foreach($spotter_array as $spotter_item) |
|
181 | + foreach ($spotter_array as $spotter_item) |
|
182 | 182 | { |
183 | 183 | $j++; |
184 | 184 | date_default_timezone_set('UTC'); |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 236 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
238 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
237 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
238 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
239 | 239 | //" |
240 | 240 | } else { |
241 | 241 | if ($compress) $output .= '"c": "NA",'; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
245 | 245 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
246 | 246 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
247 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
247 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
248 | 248 | } elseif (isset($spotter_item['aircraft_type'])) { |
249 | 249 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
250 | 250 | } elseif (!$min) { |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
386 | 386 | |
387 | 387 | if (isset($archivespeed)) { |
388 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
388 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
389 | 389 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
390 | 390 | } elseif ($usenextlatlon) { |
391 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
391 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
392 | 392 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
393 | 393 | } |
394 | 394 | |
395 | 395 | if (!$min) $output .= '"image": "'.$image.'",'; |
396 | 396 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
397 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
397 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
398 | 398 | } |
399 | 399 | if (isset($spotter_item['image_source_website'])) { |
400 | 400 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
417 | 417 | } |
418 | 418 | if (isset($spotter_item['acars'])) { |
419 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
419 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
420 | 420 | } |
421 | 421 | // type when not aircraft ? |
422 | 422 | if (isset($spotter_item['type'])) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | } |
496 | 496 | */ |
497 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
497 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
498 | 498 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
499 | 499 | |
500 | 500 | if ( |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
504 | 504 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
505 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
506 | 506 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
507 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
508 | 508 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
511 | 511 | ) { |
512 | 512 | if ($tracker) { |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
544 | 544 | } |
545 | 545 | $output_history .= '['; |
546 | - $output_history .= $spotter_history['longitude'].', '; |
|
547 | - $output_history .= $spotter_history['latitude'].', '; |
|
548 | - $output_history .= $spotter_history['altitude']*30.48; |
|
546 | + $output_history .= $spotter_history['longitude'].', '; |
|
547 | + $output_history .= $spotter_history['latitude'].', '; |
|
548 | + $output_history .= $spotter_history['altitude']*30.48; |
|
549 | 549 | $output_history .= '],'; |
550 | 550 | /* |
551 | 551 | if ($from_archive === false) { |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
564 | 564 | } else $d = true; |
565 | 565 | $output_history .= '['; |
566 | - $output_history .= $spotter_history['longitude'].', '; |
|
567 | - $output_history .= $spotter_history['latitude']; |
|
566 | + $output_history .= $spotter_history['longitude'].', '; |
|
567 | + $output_history .= $spotter_history['latitude']; |
|
568 | 568 | $output_history .= '],'; |
569 | 569 | /* |
570 | 570 | if ($from_archive === false) { |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | |
581 | 581 | if ($from_archive === false) { |
582 | 582 | $output_historyd = '['; |
583 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | - $output_historyd .= $spotter_item['latitude']; |
|
585 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
583 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | + $output_historyd .= $spotter_item['latitude']; |
|
585 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
586 | 586 | $output_historyd .= '],'; |
587 | 587 | //$output_history = $output_historyd.$output_history; |
588 | 588 | $output_history = $output_history.$output_historyd; |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
599 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
600 | 600 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
601 | 601 | && (isset($spotter_item['departure_airport']) |
602 | 602 | && $spotter_item['departure_airport'] != 'NA' |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | |
631 | 631 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
632 | 632 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
633 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
633 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
634 | 634 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
635 | 635 | && (isset($spotter_item['arrival_airport']) |
636 | 636 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $output = substr($output, 0, -1); |
662 | 662 | $output .= ']'; |
663 | 663 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
664 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
664 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
665 | 665 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
666 | 666 | $output .= '"fc": "'.$j.'"'; |
667 | 667 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | 49 | $Tracker = new Tracker($this->db); |
50 | - $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'],$this->all_tracked[$key]['datetime']); |
|
50 | + $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'], $this->all_tracked[$key]['datetime']); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | 60 | if (isset($flight['lastupdate'])) { |
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
61 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
62 | 62 | if (isset($this->all_tracked[$key]['id'])) { |
63 | 63 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
64 | 64 | /* |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | //$real_arrival = $this->arrival($key); |
70 | 70 | $Tracker = new Tracker($this->db); |
71 | 71 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | - $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']); |
|
72 | + $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 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $send = false; |
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | - if(is_array($line) && isset($line['ident'])) { |
|
92 | + if (is_array($line) && isset($line['ident'])) { |
|
93 | 93 | //print_r($line); |
94 | 94 | if (isset($line['ident'])) { |
95 | 95 | |
@@ -113,33 +113,33 @@ discard block |
||
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | 115 | $this->all_tracked[$id] = array(); |
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $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 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
117 | + $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 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
119 | 119 | if (!isset($line['id'])) { |
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | - $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'])); |
|
121 | + $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 | 123 | if ($globalAllTracked !== FALSE) $dataFound = true; |
124 | 124 | } |
125 | 125 | |
126 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
126 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
127 | 127 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
128 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
129 | 129 | } else { |
130 | 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 | 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"; |
132 | 132 | return ''; |
133 | 133 | } |
134 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
134 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
137 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
137 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
138 | 138 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
139 | 139 | return ''; |
140 | 140 | } elseif (!isset($line['datetime'])) { |
141 | 141 | date_default_timezone_set('UTC'); |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
143 | 143 | } else { |
144 | 144 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
145 | 145 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
151 | 151 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
152 | 152 | $timeelapsed = microtime(true); |
153 | 153 | $Tracker = new Tracker($this->db); |
154 | 154 | $fromsource = NULL; |
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
158 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
159 | 159 | } |
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'])); |
|
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 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
166 | 166 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
167 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
168 | 168 | if ($distance > 100 && $distance < 10000) { |
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
171 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | 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']); |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
178 | 178 | else unset($timediff); |
179 | - 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')))) { |
|
179 | + 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 | 180 | 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 | - 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'])) { |
|
181 | + 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'])) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
187 | 187 | $timeelapsed = microtime(true); |
188 | 188 | $Tracker = new Tracker($this->db); |
189 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
189 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
190 | 190 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
191 | 191 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | 195 | } |
@@ -197,75 +197,75 @@ discard block |
||
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | - 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') { |
|
200 | + 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') { |
|
201 | 201 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 202 | $dataFound = true; |
203 | 203 | $this->all_tracked[$id]['time_last_coord'] = time(); |
204 | 204 | } |
205 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
205 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | 208 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | - 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') { |
|
210 | + 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') { |
|
211 | 211 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 212 | $dataFound = true; |
213 | 213 | $this->all_tracked[$id]['time_last_coord'] = time(); |
214 | 214 | } |
215 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
215 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | } else if ($globalDebug && $timediff > 20) { |
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
223 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
222 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
223 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | 229 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
240 | 240 | //$dataFound = true; |
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
244 | 244 | //$dataFound = true; |
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 248 | //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; |
|
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
|
251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
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; |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude'])); |
|
251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
252 | 252 | //$dataFound = true; |
253 | 253 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | 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; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
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; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
264 | 264 | //$dataFound = true; |
265 | 265 | } 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 | - $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 | - $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; |
|
266 | + $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 | + $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 | 269 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -273,54 +273,54 @@ discard block |
||
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | 274 | $this->all_tracked[$id]['lastupdate'] = time(); |
275 | 275 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | - 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'])) { |
|
276 | + 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 | 277 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | 282 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 285 | $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"; |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | - $TrackerLive->db=null; |
|
288 | + $TrackerLive->db = null; |
|
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | 292 | } else { |
293 | 293 | $recent_ident = ''; |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
295 | 295 | } |
296 | 296 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | - if($recent_ident == "") |
|
297 | + if ($recent_ident == "") |
|
298 | 298 | { |
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | 301 | $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'))); |
|
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'))); |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | $Tracker = new Tracker($this->db); |
305 | - $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']); |
|
305 | + $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 | 306 | $Tracker->db = null; |
307 | 307 | if ($globalDebug && isset($result)) echo $result."\n"; |
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | 311 | // Add source stat in DB |
312 | 312 | $Stats = new Stats($this->db); |
313 | 313 | if (!empty($this->stats)) { |
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
315 | + foreach ($this->stats as $date => $data) { |
|
316 | + foreach ($data as $source => $sourced) { |
|
317 | 317 | //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); |
|
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); |
|
320 | 320 | if (isset($sourced['msg'])) { |
321 | 321 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 322 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
323 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date); |
|
324 | 324 | unset($this->stats[$date][$source]['msg']); |
325 | 325 | } |
326 | 326 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 344 | $TrackerLive = new TrackerLive($this->db); |
345 | 345 | $TrackerLive->deleteLiveTrackerData(); |
346 | - $TrackerLive->db=null; |
|
346 | + $TrackerLive->db = null; |
|
347 | 347 | if ($globalDebug) echo " Done\n"; |
348 | 348 | $this->last_delete = time(); |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
354 | 354 | $Tracker = new Tracker($this->db); |
355 | - $Tracker->updateLatestTrackerData($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]['speed'],$this->all_tracked[$id]['datetime']); |
|
355 | + $Tracker->updateLatestTrackerData($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]['speed'], $this->all_tracked[$id]['datetime']); |
|
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | $ignoreImport = false; |
367 | 367 | |
368 | 368 | if (!$ignoreImport) { |
369 | - 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'])) { |
|
369 | + 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 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
372 | 372 | $TrackerLive = new TrackerLive($this->db); |
373 | - $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']); |
|
373 | + $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 | 374 | $TrackerLive->db = null; |
375 | 375 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
377 | 377 | |
378 | 378 | // Put statistics in $this->stats variable |
379 | 379 | |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | $latitude = $globalCenterLatitude; |
391 | 391 | $longitude = $globalCenterLongitude; |
392 | 392 | } |
393 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
393 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
394 | 394 | } else { |
395 | 395 | $latitude = $this->source_location[$source]['latitude']; |
396 | 396 | $longitude = $this->source_location[$source]['longitude']; |
397 | 397 | } |
398 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
398 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
399 | 399 | //$stats_heading = $stats_heading%22.5; |
400 | 400 | $stats_heading = round($stats_heading/22.5); |
401 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
401 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
402 | 402 | $current_date = date('Y-m-d'); |
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | - for ($i=0;$i<=15;$i++) { |
|
405 | + for ($i = 0; $i <= 15; $i++) { |
|
406 | 406 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 419 | end($this->stats[$current_date][$source]['hist']); |
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
421 | 421 | } else $mini = 0; |
422 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
422 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
423 | 423 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
433 | 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"; |
|
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"; |
|
435 | 435 | //$this->del(); |
436 | 436 | |
437 | 437 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute(); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | echo $e->getMessage(); |
165 | 165 | die; |
166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
181 | 181 | date_default_timezone_set('UTC'); |
182 | 182 | |
183 | - $filter_query = $this->getFilter($filter,true,true); |
|
183 | + $filter_query = $this->getFilter($filter, true, true); |
|
184 | 184 | |
185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
186 | 186 | if ($globalDBdriver == 'mysql') { |
187 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
187 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | 190 | } else { |
191 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
191 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | echo $e->getMessage(); |
201 | 201 | die; |
202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
216 | - $filter_query = $this->getFilter($filter,true,true); |
|
216 | + $filter_query = $this->getFilter($filter, true, true); |
|
217 | 217 | |
218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo $e->getMessage(); |
229 | 229 | die; |
230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | $filter_query = $this->getFilter($filter); |
248 | 248 | |
249 | 249 | if (is_array($coord)) { |
250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
254 | 254 | } else return array(); |
255 | 255 | if ($globalDBdriver == 'mysql') { |
256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -275,17 +275,17 @@ discard block |
||
275 | 275 | $filter_query = $this->getFilter($filter); |
276 | 276 | |
277 | 277 | if (is_array($coord)) { |
278 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
279 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
280 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
281 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
280 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
281 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
282 | 282 | } else return array(); |
283 | 283 | if ($globalDBdriver == 'mysql') { |
284 | 284 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
285 | 285 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
286 | 286 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
287 | 287 | } else { |
288 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
288 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
289 | 289 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
290 | 290 | } |
291 | 291 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | if ($interval == '1m') |
334 | 334 | { |
335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
336 | - } else if ($interval == '15m'){ |
|
336 | + } else if ($interval == '15m') { |
|
337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
338 | 338 | } |
339 | 339 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
342 | 342 | } |
343 | 343 | |
344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
345 | 345 | WHERE tracker_live.latitude <> '' |
346 | 346 | AND tracker_live.longitude <> '' |
347 | 347 | ".$additional_query." |
348 | 348 | HAVING distance < :radius |
349 | 349 | ORDER BY distance"; |
350 | 350 | |
351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
352 | 352 | |
353 | 353 | return $spotter_array; |
354 | 354 | } |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
370 | 370 | |
371 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
371 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | * @return Array the spotter information |
380 | 380 | * |
381 | 381 | */ |
382 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
382 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
383 | 383 | { |
384 | 384 | $Tracker = new Tracker($this->db); |
385 | 385 | date_default_timezone_set('UTC'); |
386 | 386 | |
387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
389 | 389 | |
390 | - $date = date('c',$date); |
|
391 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
390 | + $date = date('c', $date); |
|
391 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
409 | 409 | |
410 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
410 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | * @return Array the spotter information |
419 | 419 | * |
420 | 420 | */ |
421 | - public function getDateLiveTrackerDataById($id,$date) |
|
421 | + public function getDateLiveTrackerDataById($id, $date) |
|
422 | 422 | { |
423 | 423 | $Tracker = new Tracker($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | - $date = date('c',$date); |
|
429 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | + $date = date('c', $date); |
|
429 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
@@ -443,13 +443,13 @@ discard block |
||
443 | 443 | date_default_timezone_set('UTC'); |
444 | 444 | |
445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
447 | 447 | |
448 | 448 | try { |
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | echo $e->getMessage(); |
454 | 454 | die; |
455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return Array the spotter information |
465 | 465 | * |
466 | 466 | */ |
467 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
467 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
470 | 470 | date_default_timezone_set('UTC'); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | try { |
484 | 484 | $sth = $this->db->prepare($query); |
485 | 485 | $sth->execute(array(':id' => $id)); |
486 | - } catch(PDOException $e) { |
|
486 | + } catch (PDOException $e) { |
|
487 | 487 | echo $e->getMessage(); |
488 | 488 | die; |
489 | 489 | } |
@@ -501,12 +501,12 @@ discard block |
||
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
504 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
505 | 505 | try { |
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
509 | - } catch(PDOException $e) { |
|
509 | + } catch (PDOException $e) { |
|
510 | 510 | echo $e->getMessage(); |
511 | 511 | die; |
512 | 512 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
539 | - } catch(PDOException $e) { |
|
539 | + } catch (PDOException $e) { |
|
540 | 540 | return "error"; |
541 | 541 | } |
542 | 542 | |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
562 | - } catch(PDOException $e) { |
|
562 | + } catch (PDOException $e) { |
|
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | 566 | $i = 0; |
567 | - $j =0; |
|
567 | + $j = 0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | - foreach($all as $row) |
|
569 | + foreach ($all as $row) |
|
570 | 570 | { |
571 | 571 | $i++; |
572 | 572 | $j++; |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | if ($globalDebug) echo "."; |
575 | 575 | try { |
576 | 576 | |
577 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
577 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
578 | 578 | $sth->execute(); |
579 | - } catch(PDOException $e) { |
|
579 | + } catch (PDOException $e) { |
|
580 | 580 | return "error"; |
581 | 581 | } |
582 | 582 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | if ($i > 0) { |
588 | 588 | try { |
589 | 589 | |
590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error"; |
594 | 594 | } |
595 | 595 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
605 | - } catch(PDOException $e) { |
|
605 | + } catch (PDOException $e) { |
|
606 | 606 | return "error"; |
607 | 607 | } |
608 | 608 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
653 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
654 | 654 | |
655 | 655 | try { |
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
675 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
676 | 676 | |
677 | 677 | try { |
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
681 | - } catch(PDOException $e) { |
|
681 | + } catch (PDOException $e) { |
|
682 | 682 | return "error"; |
683 | 683 | } |
684 | 684 | |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
698 | 698 | if ($globalDBdriver == 'mysql') { |
699 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
699 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
700 | 700 | WHERE tracker_live.ident = :ident |
701 | 701 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
702 | 702 | AND tracker_live.date < UTC_TIMESTAMP()'; |
703 | 703 | $query_data = array(':ident' => $ident); |
704 | 704 | } else { |
705 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
705 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
706 | 706 | WHERE tracker_live.ident = :ident |
707 | 707 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
708 | 708 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | |
712 | 712 | $sth = $this->db->prepare($query); |
713 | 713 | $sth->execute($query_data); |
714 | - $ident_result=''; |
|
715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
714 | + $ident_result = ''; |
|
715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
716 | 716 | { |
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
732 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
733 | 733 | WHERE tracker_live.ident = :ident |
734 | 734 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
735 | 735 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
736 | 736 | $query_data = array(':ident' => $ident); |
737 | 737 | } else { |
738 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
738 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
739 | 739 | WHERE tracker_live.ident = :ident |
740 | 740 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
741 | 741 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -744,8 +744,8 @@ discard block |
||
744 | 744 | |
745 | 745 | $sth = $this->db->prepare($query); |
746 | 746 | $sth->execute($query_data); |
747 | - $ident_result=''; |
|
748 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
747 | + $ident_result = ''; |
|
748 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
749 | 749 | { |
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
@@ -762,13 +762,13 @@ discard block |
||
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
764 | 764 | if ($globalDBdriver == 'mysql') { |
765 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
765 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
766 | 766 | WHERE tracker_live.famtrackid = :id |
767 | 767 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
768 | 768 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
769 | 769 | $query_data = array(':id' => $id); |
770 | 770 | } else { |
771 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
771 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
772 | 772 | WHERE tracker_live.famtrackid = :id |
773 | 773 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
774 | 774 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | |
778 | 778 | $sth = $this->db->prepare($query); |
779 | 779 | $sth->execute($query_data); |
780 | - $ident_result=''; |
|
781 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
780 | + $ident_result = ''; |
|
781 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
782 | 782 | { |
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @return String success or false |
797 | 797 | * |
798 | 798 | */ |
799 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
799 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
800 | 800 | { |
801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
802 | 802 | $Common = new Common(); |
@@ -855,21 +855,21 @@ discard block |
||
855 | 855 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
856 | 856 | |
857 | 857 | |
858 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
859 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
860 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
861 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
862 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
863 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
864 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
865 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
866 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
867 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
868 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
869 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
870 | - |
|
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
858 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
859 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
860 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
861 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
862 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
863 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
864 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
865 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
866 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
867 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
868 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
869 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
870 | + |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
873 | 873 | |
874 | 874 | $query = ''; |
875 | 875 | if ($globalArchive) { |
@@ -879,12 +879,12 @@ discard block |
||
879 | 879 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
880 | 880 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
881 | 881 | |
882 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
882 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
883 | 883 | try { |
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_values); |
887 | - } catch(PDOException $e) { |
|
887 | + } catch (PDOException $e) { |
|
888 | 888 | return "error : ".$e->getMessage(); |
889 | 889 | } |
890 | 890 | /* |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
895 | 895 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
896 | 896 | $TrackerArchive = new TrackerArchive($this->db); |
897 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
897 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
898 | 898 | if ($globalDebug) echo $result.')'; |
899 | 899 | } |
900 | 900 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | |
905 | 905 | public function getOrderBy() |
906 | 906 | { |
907 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
907 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
908 | 908 | return $orderby; |
909 | 909 | } |
910 | 910 |