@@ -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 = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
74 | + $ident = 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 = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING); |
|
96 | + $famtrack_id = 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 = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
100 | + $fammarine_id = 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) { |
@@ -384,16 +384,16 @@ discard block |
||
384 | 384 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
385 | 385 | |
386 | 386 | if (isset($archivespeed)) { |
387 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
387 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
388 | 388 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
389 | 389 | } elseif ($usenextlatlon) { |
390 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
390 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
391 | 391 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
392 | 392 | } |
393 | 393 | |
394 | 394 | if (!$min) $output .= '"image": "'.$image.'",'; |
395 | 395 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
396 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
396 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
397 | 397 | } |
398 | 398 | if (isset($spotter_item['image_source_website'])) { |
399 | 399 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
416 | 416 | } |
417 | 417 | if (isset($spotter_item['acars'])) { |
418 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
418 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
419 | 419 | } |
420 | 420 | // type when not aircraft ? |
421 | 421 | if (isset($spotter_item['type'])) { |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | } |
495 | 495 | */ |
496 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
496 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
498 | 498 | |
499 | 499 | if ( |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
505 | 505 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
507 | 507 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
509 | 509 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
510 | 510 | ) { |
511 | 511 | if ($tracker) { |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
539 | 539 | } |
540 | 540 | $output_history .= '['; |
541 | - $output_history .= $spotter_history['longitude'].', '; |
|
542 | - $output_history .= $spotter_history['latitude'].', '; |
|
543 | - $output_history .= $spotter_history['altitude']*30.48; |
|
541 | + $output_history .= $spotter_history['longitude'].', '; |
|
542 | + $output_history .= $spotter_history['latitude'].', '; |
|
543 | + $output_history .= $spotter_history['altitude']*30.48; |
|
544 | 544 | $output_history .= '],'; |
545 | 545 | /* |
546 | 546 | if ($from_archive === false) { |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
559 | 559 | } else $d = true; |
560 | 560 | $output_history .= '['; |
561 | - $output_history .= $spotter_history['longitude'].', '; |
|
562 | - $output_history .= $spotter_history['latitude']; |
|
561 | + $output_history .= $spotter_history['longitude'].', '; |
|
562 | + $output_history .= $spotter_history['latitude']; |
|
563 | 563 | $output_history .= '],'; |
564 | 564 | /* |
565 | 565 | if ($from_archive === false) { |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | |
576 | 576 | if ($from_archive === false) { |
577 | 577 | $output_historyd = '['; |
578 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
579 | - $output_historyd .= $spotter_item['latitude']; |
|
580 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
578 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
579 | + $output_historyd .= $spotter_item['latitude']; |
|
580 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
581 | 581 | $output_historyd .= '],'; |
582 | 582 | //$output_history = $output_historyd.$output_history; |
583 | 583 | $output_history = $output_history.$output_historyd; |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | $output = substr($output, 0, -1); |
618 | 618 | $output .= ']'; |
619 | 619 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
620 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
620 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
621 | 621 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
622 | 622 | $output .= '"fc": "'.$j.'"'; |
623 | 623 | } else { |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param String $date get data for a date |
30 | 30 | * @return Array Return Accidents data in array |
31 | 31 | */ |
32 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
32 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
33 | 33 | global $globalURL, $globalDBdriver; |
34 | 34 | $Image = new Image($this->db); |
35 | 35 | $Spotter = new Spotter($this->db); |
36 | 36 | $Translation = new Translation($this->db); |
37 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
37 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | $result = array(); |
40 | 40 | $limit_query = ''; |
41 | 41 | if ($limit != "") |
42 | 42 | { |
43 | 43 | $limit_array = explode(",", $limit); |
44 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
45 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
45 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
46 | 46 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
47 | 47 | { |
48 | 48 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($type != '') { |
53 | 53 | if ($date != '') { |
54 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
54 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
55 | 55 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
56 | 56 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
57 | - $query_values = array(':type' => $type,':date' => $date); |
|
58 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
57 | + $query_values = array(':type' => $type, ':date' => $date); |
|
58 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
59 | 59 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
60 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
60 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
62 | 62 | if ($globalDBdriver == 'mysql') { |
63 | 63 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
64 | 64 | } else { |
65 | 65 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
66 | 66 | } |
67 | - $query_values = array(':type' => $type,':date' => $date); |
|
67 | + $query_values = array(':type' => $type, ':date' => $date); |
|
68 | 68 | } else { |
69 | 69 | $date = $date.'%'; |
70 | 70 | if ($globalDBdriver == 'mysql') { |
71 | 71 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
72 | - $query_values = array(':type' => $type,':date' => $date); |
|
72 | + $query_values = array(':type' => $type, ':date' => $date); |
|
73 | 73 | } else { |
74 | 74 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
75 | 75 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
76 | - $query_values = array(':type' => $type,':date' => $date); |
|
76 | + $query_values = array(':type' => $type, ':date' => $date); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } else { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | if ($date != '') { |
86 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
86 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
89 | 89 | } else { |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | echo "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | $i = 0; |
109 | 109 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 110 | //print_r($row); |
111 | 111 | //echo $row['flightaware_id']; |
112 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
112 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
113 | 113 | $data = array(); |
114 | 114 | if ($row['registration'] != '') { |
115 | 115 | $image_array = $Image->getSpotterImage($row['registration']); |
116 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
117 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
116 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
117 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
118 | 118 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
119 | 119 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
120 | 120 | if (!empty($aircraft_info)) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
123 | 123 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
124 | 124 | } else { |
125 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
125 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
126 | 126 | } |
127 | 127 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
128 | 128 | if (!empty($owner_data)) { |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | $data['aircraft_base'] = $owner_data['base']; |
131 | 131 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
132 | 132 | } |
133 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
133 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
134 | 134 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
135 | 135 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
136 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
136 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
137 | 137 | if (isset($identicao[0])) { |
138 | - if (substr($row['ident'],0,2) == 'AF') { |
|
139 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
141 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
142 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
138 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
139 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
140 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
141 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
142 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
143 | 143 | } else $icao = $row['ident']; |
144 | - $icao = $Translation->checkTranslation($icao,false); |
|
144 | + $icao = $Translation->checkTranslation($icao, false); |
|
145 | 145 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
146 | 146 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
147 | 147 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | if (!empty($airline_info)) { |
151 | 151 | //echo 'data found !'."\n"; |
152 | 152 | //print_r($airline_info); |
153 | - $data = array_merge($data,$airline_info); |
|
153 | + $data = array_merge($data, $airline_info); |
|
154 | 154 | } |
155 | 155 | //else echo 'No data...'."\n"; |
156 | 156 | } |
157 | - $data = array_merge($row,$data); |
|
157 | + $data = array_merge($row, $data); |
|
158 | 158 | if ($data['ident'] == null) $data['ident'] = $icao; |
159 | 159 | if ($data['title'] == null) { |
160 | 160 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | try { |
191 | 191 | $sth = $this->db->prepare($query); |
192 | 192 | $sth->execute(); |
193 | - } catch(PDOException $e) { |
|
193 | + } catch (PDOException $e) { |
|
194 | 194 | echo "Error : ".$e->getMessage(); |
195 | 195 | } |
196 | 196 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | try { |
211 | 211 | $sth = $this->db->prepare($query); |
212 | 212 | $sth->execute(); |
213 | - } catch(PDOException $e) { |
|
213 | + } catch (PDOException $e) { |
|
214 | 214 | echo "Error : ".$e->getMessage(); |
215 | 215 | } |
216 | 216 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | if ($globalDebug) echo 'Import '.$file."\n"; |
226 | 226 | $result = array(); |
227 | 227 | if (file_exists($file)) { |
228 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
229 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
228 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
229 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
230 | 230 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
231 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
231 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | fclose($handle); |
235 | 235 | } |
236 | - if (!empty($result)) $this->add($result,true); |
|
236 | + if (!empty($result)) $this->add($result, true); |
|
237 | 237 | elseif ($globalDebug) echo 'Nothing to import'; |
238 | 238 | } |
239 | 239 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | $all_md5_new = array(); |
250 | 250 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
251 | 251 | if ($this->check_accidents_nb() > 0) { |
252 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
253 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
252 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
253 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
254 | 254 | if (isset($data[1])) { |
255 | 255 | $year = $data[0]; |
256 | 256 | $all_md5[$year] = $data[1]; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
263 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
264 | 264 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
265 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
266 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
265 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
266 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
267 | 267 | if (isset($data[1])) { |
268 | 268 | $year = $data[0]; |
269 | 269 | $all_md5_new[$year] = $data[1]; |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | fclose($handle); |
273 | 273 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
274 | 274 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
275 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
275 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
276 | 276 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
277 | 277 | foreach ($result as $file => $md5) { |
278 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
278 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
279 | 279 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
280 | 280 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Add data to DB |
286 | 286 | * @param Array $crash An array with accidents/incidents data |
287 | 287 | */ |
288 | - public function add($crash,$new = false) { |
|
288 | + public function add($crash, $new = false) { |
|
289 | 289 | global $globalTransaction, $globalDebug; |
290 | 290 | require_once('class.Connection.php'); |
291 | 291 | require_once('class.Image.php'); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $sthd->execute(array(':source' => $crash[0]['source'])); |
302 | 302 | } |
303 | 303 | if ($globalTransaction) $Connection->db->beginTransaction(); |
304 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
304 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
305 | 305 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
306 | 306 | $sth_check = $Connection->db->prepare($query_check); |
307 | 307 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | $cr = array_map(function($value) { |
315 | 315 | return $value === "" ? NULL : $value; |
316 | 316 | }, $cr); |
317 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
318 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
317 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
318 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
319 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
320 | 320 | $sth_check->execute($query_check_values); |
321 | 321 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
322 | 322 | if ($result_check['nb'] == 0) { |
323 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
323 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
324 | 324 | $sth->execute($query_values); |
325 | - if ($cr['date'] > time()-(30*86400)) { |
|
325 | + if ($cr['date'] > time() - (30*86400)) { |
|
326 | 326 | if (empty($Image->getSpotterImage($cr['registration']))) { |
327 | 327 | //if ($globalDebug) echo 'Get image...'."\n"; |
328 | 328 | $Image->addSpotterImage($cr['registration']); |
329 | 329 | } |
330 | 330 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
331 | 331 | } |
332 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
332 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
333 | 333 | } |
334 | 334 | } |
335 | - if ($globalTransaction && $j % 1000 == 0) { |
|
335 | + if ($globalTransaction && $j%1000 == 0) { |
|
336 | 336 | $Connection->db->commit(); |
337 | 337 | $Connection->db->beginTransaction(); |
338 | 338 | } |
339 | 339 | } |
340 | 340 | if ($globalTransaction) $Connection->db->commit(); |
341 | - } catch(PDOException $e) { |
|
341 | + } catch (PDOException $e) { |
|
342 | 342 | if ($globalTransaction) $Connection->db->rollBack(); |
343 | 343 | echo $e->getMessage(); |
344 | 344 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $Connection = new Connection(); |
357 | 357 | $sth = $Connection->db->prepare($query); |
358 | 358 | $sth->execute(); |
359 | - } catch(PDOException $e) { |
|
359 | + } catch (PDOException $e) { |
|
360 | 360 | return "error : ".$e->getMessage(); |
361 | 361 | } |
362 | 362 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $Connection = new Connection(); |
375 | 375 | $sth = $Connection->db->prepare($query); |
376 | 376 | $sth->execute(); |
377 | - } catch(PDOException $e) { |
|
377 | + } catch (PDOException $e) { |
|
378 | 378 | return "error : ".$e->getMessage(); |
379 | 379 | } |
380 | 380 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | 391 | $sth->execute(); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | return "error : ".$e->getMessage(); |
394 | 394 | } |
395 | 395 | } |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | if (isset($_GET['currenttime'])) { |
14 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
14 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | $currenttime = round($currenttime/1000); |
16 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime); |
|
16 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime); |
|
17 | 17 | if (empty($spotter_array)) { |
18 | 18 | $from_archive = true; |
19 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime); |
|
19 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($_GET['flightaware_id'])) { |
30 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
30 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
31 | 31 | if (isset($_GET['currenttime'])) { |
32 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
32 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
33 | 33 | $currenttime = round($currenttime/1000); |
34 | - $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime); |
|
34 | + $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime); |
|
35 | 35 | if (empty($spotter_array)) { |
36 | 36 | $from_archive = true; |
37 | 37 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
38 | - $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime); |
|
38 | + $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime); |
|
39 | 39 | } |
40 | 40 | } else { |
41 | 41 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
55 | 55 | { |
56 | 56 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
57 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
57 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
58 | 58 | } else $image = $spotter_item['image_thumbnail']; |
59 | 59 | |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
73 | 73 | if (isset($spotter_item['departure_airport_time'])) { |
74 | 74 | if ($spotter_item['departure_airport_time'] > 2460) { |
75 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
75 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
76 | 76 | } else { |
77 | 77 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
82 | 82 | if (isset($spotter_item['arrival_airport_time'])) { |
83 | 83 | if ($spotter_item['arrival_airport_time'] > 2460) { |
84 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
84 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
85 | 85 | } else { |
86 | 86 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
87 | 87 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
153 | 153 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
154 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
154 | +if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>'; |
|
155 | 155 | if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
156 | 156 | print '</div>'; |
157 | 157 | ?> |
@@ -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 | } |
@@ -441,13 +441,13 @@ discard block |
||
441 | 441 | ?> |
442 | 442 | <tr> |
443 | 443 | <?php |
444 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
444 | + if (filter_var($source['host'], FILTER_VALIDATE_URL)) { |
|
445 | 445 | ?> |
446 | 446 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
447 | 447 | <td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td> |
448 | 448 | <?php |
449 | 449 | } else { |
450 | - $hostport = explode(':',$source['host']); |
|
450 | + $hostport = explode(':', $source['host']); |
|
451 | 451 | if (isset($hostport[1])) { |
452 | 452 | $host = $hostport[0]; |
453 | 453 | $port = $hostport[1]; |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | <br /> |
792 | 792 | <p> |
793 | 793 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
794 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
794 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" /> |
|
795 | 795 | </p> |
796 | 796 | <br /> |
797 | 797 | <p> |
@@ -842,14 +842,14 @@ discard block |
||
842 | 842 | $error = ''; |
843 | 843 | |
844 | 844 | if (isset($_POST['dbtype'])) { |
845 | - $dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING); |
|
846 | - $dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING); |
|
847 | - $dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING); |
|
848 | - $dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING); |
|
849 | - $dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING); |
|
850 | - $dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING); |
|
851 | - $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
|
852 | - $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
|
845 | + $dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING); |
|
846 | + $dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING); |
|
847 | + $dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING); |
|
848 | + $dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING); |
|
849 | + $dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING); |
|
850 | + $dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING); |
|
851 | + $dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING); |
|
852 | + $dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING); |
|
853 | 853 | |
854 | 854 | if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
855 | 855 | if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
@@ -869,48 +869,48 @@ discard block |
||
869 | 869 | } else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
870 | 870 | */ |
871 | 871 | |
872 | - $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname)); |
|
872 | + $settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname)); |
|
873 | 873 | |
874 | - $sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING); |
|
875 | - $siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING); |
|
876 | - $timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING); |
|
877 | - $language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING); |
|
878 | - $settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language)); |
|
874 | + $sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING); |
|
875 | + $siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING); |
|
876 | + $timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING); |
|
877 | + $language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING); |
|
878 | + $settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language)); |
|
879 | 879 | |
880 | - $mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING); |
|
881 | - $mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING); |
|
882 | - $mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING); |
|
883 | - $googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING); |
|
884 | - $bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING); |
|
885 | - $mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING); |
|
886 | - $hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING); |
|
887 | - $hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING); |
|
888 | - $settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey)); |
|
880 | + $mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING); |
|
881 | + $mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING); |
|
882 | + $mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING); |
|
883 | + $googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING); |
|
884 | + $bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING); |
|
885 | + $mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING); |
|
886 | + $hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING); |
|
887 | + $hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING); |
|
888 | + $settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey)); |
|
889 | 889 | |
890 | - $latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING); |
|
891 | - $latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING); |
|
892 | - $longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING); |
|
893 | - $longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING); |
|
894 | - $livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT); |
|
895 | - $settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom)); |
|
890 | + $latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING); |
|
891 | + $latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING); |
|
892 | + $longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING); |
|
893 | + $longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING); |
|
894 | + $livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT); |
|
895 | + $settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom)); |
|
896 | 896 | |
897 | - $squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING); |
|
898 | - $settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country)); |
|
897 | + $squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING); |
|
898 | + $settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country)); |
|
899 | 899 | |
900 | - $latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING); |
|
901 | - $longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING); |
|
902 | - $settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter)); |
|
900 | + $latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING); |
|
901 | + $longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING); |
|
902 | + $settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter)); |
|
903 | 903 | |
904 | - $acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING); |
|
904 | + $acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING); |
|
905 | 905 | if ($acars == 'acars') { |
906 | - $settings = array_merge($settings,array('globalACARS' => 'TRUE')); |
|
906 | + $settings = array_merge($settings, array('globalACARS' => 'TRUE')); |
|
907 | 907 | } else { |
908 | - $settings = array_merge($settings,array('globalACARS' => 'FALSE')); |
|
908 | + $settings = array_merge($settings, array('globalACARS' => 'FALSE')); |
|
909 | 909 | } |
910 | 910 | |
911 | - $flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING); |
|
912 | - $flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING); |
|
913 | - $settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword)); |
|
911 | + $flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING); |
|
912 | + $flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING); |
|
913 | + $settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword)); |
|
914 | 914 | |
915 | 915 | $source_name = $_POST['source_name']; |
916 | 916 | $source_latitude = $_POST['source_latitude']; |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | |
925 | 925 | $sources = array(); |
926 | 926 | foreach ($source_name as $keys => $name) { |
927 | - 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]); |
|
928 | - 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]); |
|
927 | + 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]); |
|
928 | + 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]); |
|
929 | 929 | } |
930 | 930 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
931 | 931 | |
@@ -938,24 +938,24 @@ discard block |
||
938 | 938 | $sbsurl = $_POST['sbsurl']; |
939 | 939 | */ |
940 | 940 | |
941 | - $globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING); |
|
942 | - $globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING); |
|
943 | - $globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING); |
|
944 | - $globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING); |
|
945 | - $globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING); |
|
946 | - $globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING); |
|
947 | - $globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING); |
|
948 | - $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
|
941 | + $globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING); |
|
942 | + $globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING); |
|
943 | + $globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING); |
|
944 | + $globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING); |
|
945 | + $globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING); |
|
946 | + $globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING); |
|
947 | + $globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING); |
|
948 | + $datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING); |
|
949 | 949 | |
950 | - $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
|
951 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
952 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
953 | - $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
|
954 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
955 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
956 | - $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
|
957 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
958 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
950 | + $globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING); |
|
951 | + if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE')); |
|
952 | + else $settings = array_merge($settings, array('globalAircraft' => 'FALSE')); |
|
953 | + $globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING); |
|
954 | + if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE')); |
|
955 | + else $settings = array_merge($settings, array('globalTracker' => 'FALSE')); |
|
956 | + $globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING); |
|
957 | + if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE')); |
|
958 | + else $settings = array_merge($settings, array('globalMarine' => 'FALSE')); |
|
959 | 959 | |
960 | 960 | /* |
961 | 961 | $globalSBS1Hosts = array(); |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | } |
972 | 972 | $settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts)); |
973 | 973 | */ |
974 | - $settings_comment = array_merge($settings_comment,array('globalSBS1Hosts')); |
|
974 | + $settings_comment = array_merge($settings_comment, array('globalSBS1Hosts')); |
|
975 | 975 | $host = $_POST['host']; |
976 | 976 | $port = $_POST['port']; |
977 | 977 | $name = $_POST['name']; |
@@ -986,96 +986,96 @@ discard block |
||
986 | 986 | else $cov = 'FALSE'; |
987 | 987 | if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
988 | 988 | else $arch = 'FALSE'; |
989 | - if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch); |
|
989 | + if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch); |
|
990 | 990 | } |
991 | - $settings = array_merge($settings,array('globalSources' => $gSources)); |
|
991 | + $settings = array_merge($settings, array('globalSources' => $gSources)); |
|
992 | 992 | |
993 | 993 | /* |
994 | 994 | $sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT); |
995 | 995 | $settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout)); |
996 | 996 | */ |
997 | - $acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING); |
|
998 | - $acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT); |
|
999 | - $settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport)); |
|
997 | + $acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING); |
|
998 | + $acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT); |
|
999 | + $settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport)); |
|
1000 | 1000 | |
1001 | - $bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING); |
|
1002 | - $settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly)); |
|
1001 | + $bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING); |
|
1002 | + $settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly)); |
|
1003 | 1003 | |
1004 | - $notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING); |
|
1005 | - $settings = array_merge($settings,array('globalNOTAMSource' => $notamsource)); |
|
1006 | - $metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING); |
|
1007 | - $settings = array_merge($settings,array('globalMETARurl' => $metarsource)); |
|
1004 | + $notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING); |
|
1005 | + $settings = array_merge($settings, array('globalNOTAMSource' => $notamsource)); |
|
1006 | + $metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING); |
|
1007 | + $settings = array_merge($settings, array('globalMETARurl' => $metarsource)); |
|
1008 | 1008 | |
1009 | - $zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING); |
|
1010 | - $zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING); |
|
1011 | - $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
|
1009 | + $zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING); |
|
1010 | + $zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING); |
|
1011 | + $zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT); |
|
1012 | 1012 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1013 | - $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
|
1014 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1013 | + $settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance))); |
|
1014 | + } else $settings = array_merge($settings, array('globalDistanceIgnore' => array())); |
|
1015 | 1015 | |
1016 | - $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
|
1017 | - $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
|
1018 | - $maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT); |
|
1019 | - $settings = array_merge($settings,array('globalMapRefresh' => $maprefresh)); |
|
1020 | - $mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT); |
|
1021 | - $settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle)); |
|
1022 | - $closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT); |
|
1023 | - $settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist)); |
|
1016 | + $refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT); |
|
1017 | + $settings = array_merge($settings, array('globalLiveInterval' => $refresh)); |
|
1018 | + $maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT); |
|
1019 | + $settings = array_merge($settings, array('globalMapRefresh' => $maprefresh)); |
|
1020 | + $mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT); |
|
1021 | + $settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle)); |
|
1022 | + $closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT); |
|
1023 | + $settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist)); |
|
1024 | 1024 | |
1025 | - $aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT); |
|
1026 | - $settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize)); |
|
1025 | + $aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT); |
|
1026 | + $settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize)); |
|
1027 | 1027 | |
1028 | - $archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT); |
|
1029 | - $settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths)); |
|
1028 | + $archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths)); |
|
1030 | 1030 | |
1031 | - $archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING); |
|
1031 | + $archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING); |
|
1032 | 1032 | if ($archiveyear == "archiveyear") { |
1033 | - $settings = array_merge($settings,array('globalArchiveYear' => 'TRUE')); |
|
1033 | + $settings = array_merge($settings, array('globalArchiveYear' => 'TRUE')); |
|
1034 | 1034 | } else { |
1035 | - $settings = array_merge($settings,array('globalArchiveYear' => 'FALSE')); |
|
1035 | + $settings = array_merge($settings, array('globalArchiveYear' => 'FALSE')); |
|
1036 | 1036 | } |
1037 | - $archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1038 | - $settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1039 | - $archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT); |
|
1040 | - $settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1037 | + $archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1038 | + $settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths)); |
|
1039 | + $archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths)); |
|
1041 | 1041 | |
1042 | - $britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING); |
|
1043 | - $settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways)); |
|
1044 | - $transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING); |
|
1045 | - $settings = array_merge($settings,array('globalTransaviaKey' => $transavia)); |
|
1042 | + $britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING); |
|
1043 | + $settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways)); |
|
1044 | + $transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING); |
|
1045 | + $settings = array_merge($settings, array('globalTransaviaKey' => $transavia)); |
|
1046 | 1046 | |
1047 | - $lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING); |
|
1048 | - $lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING); |
|
1049 | - $settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret))); |
|
1047 | + $lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING); |
|
1048 | + $lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING); |
|
1049 | + $settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret))); |
|
1050 | 1050 | |
1051 | 1051 | // Create in settings.php keys not yet configurable if not already here |
1052 | 1052 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1053 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1053 | + if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE')); |
|
1054 | 1054 | |
1055 | - $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
|
1055 | + $resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING); |
|
1056 | 1056 | if ($resetyearstats == 'resetyearstats') { |
1057 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE')); |
|
1057 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE')); |
|
1058 | 1058 | } else { |
1059 | - $settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE')); |
|
1059 | + $settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE')); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | - $archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING); |
|
1062 | + $archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING); |
|
1063 | 1063 | if ($archive == 'archive') { |
1064 | - $settings = array_merge($settings,array('globalArchive' => 'TRUE')); |
|
1064 | + $settings = array_merge($settings, array('globalArchive' => 'TRUE')); |
|
1065 | 1065 | } else { |
1066 | - $settings = array_merge($settings,array('globalArchive' => 'FALSE')); |
|
1066 | + $settings = array_merge($settings, array('globalArchive' => 'FALSE')); |
|
1067 | 1067 | } |
1068 | - $daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING); |
|
1068 | + $daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING); |
|
1069 | 1069 | if ($daemon == 'daemon') { |
1070 | - $settings = array_merge($settings,array('globalDaemon' => 'TRUE')); |
|
1070 | + $settings = array_merge($settings, array('globalDaemon' => 'TRUE')); |
|
1071 | 1071 | } else { |
1072 | - $settings = array_merge($settings,array('globalDaemon' => 'FALSE')); |
|
1072 | + $settings = array_merge($settings, array('globalDaemon' => 'FALSE')); |
|
1073 | 1073 | } |
1074 | - $schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING); |
|
1074 | + $schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING); |
|
1075 | 1075 | if ($schedules == 'schedules') { |
1076 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE')); |
|
1076 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE')); |
|
1077 | 1077 | } else { |
1078 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE')); |
|
1078 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE')); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /* |
@@ -1086,195 +1086,195 @@ discard block |
||
1086 | 1086 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE')); |
1087 | 1087 | } |
1088 | 1088 | */ |
1089 | - $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
|
1090 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1091 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1092 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1093 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1089 | + $settings = array_merge($settings, array('globalFlightAware' => 'FALSE')); |
|
1090 | + if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE')); |
|
1091 | + else $settings = array_merge($settings, array('globalSBS1' => 'FALSE')); |
|
1092 | + if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE')); |
|
1093 | + else $settings = array_merge($settings, array('globalAPRS' => 'FALSE')); |
|
1094 | 1094 | $va = false; |
1095 | 1095 | if ($globalivao == 'ivao') { |
1096 | - $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
|
1096 | + $settings = array_merge($settings, array('globalIVAO' => 'TRUE')); |
|
1097 | 1097 | $va = true; |
1098 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1098 | + } else $settings = array_merge($settings, array('globalIVAO' => 'FALSE')); |
|
1099 | 1099 | if ($globalvatsim == 'vatsim') { |
1100 | - $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
|
1100 | + $settings = array_merge($settings, array('globalVATSIM' => 'TRUE')); |
|
1101 | 1101 | $va = true; |
1102 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1102 | + } else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE')); |
|
1103 | 1103 | if ($globalphpvms == 'phpvms') { |
1104 | - $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
|
1104 | + $settings = array_merge($settings, array('globalphpVMS' => 'TRUE')); |
|
1105 | 1105 | $va = true; |
1106 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1106 | + } else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE')); |
|
1107 | 1107 | if ($globalvam == 'vam') { |
1108 | - $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
|
1108 | + $settings = array_merge($settings, array('globalVAM' => 'TRUE')); |
|
1109 | 1109 | $va = true; |
1110 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1110 | + } else $settings = array_merge($settings, array('globalVAM' => 'FALSE')); |
|
1111 | 1111 | if ($va) { |
1112 | - $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
|
1113 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1112 | + $settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE')); |
|
1113 | + } else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE')); |
|
1114 | 1114 | if ($globalva == 'va' || $va) { |
1115 | - $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
|
1116 | - } else $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
|
1115 | + $settings = array_merge($settings, array('globalVA' => 'TRUE')); |
|
1116 | + } else $settings = array_merge($settings, array('globalVA' => 'FALSE')); |
|
1117 | 1117 | |
1118 | 1118 | |
1119 | 1119 | |
1120 | - $notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING); |
|
1120 | + $notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING); |
|
1121 | 1121 | if ($notam == 'notam') { |
1122 | - $settings = array_merge($settings,array('globalNOTAM' => 'TRUE')); |
|
1122 | + $settings = array_merge($settings, array('globalNOTAM' => 'TRUE')); |
|
1123 | 1123 | } else { |
1124 | - $settings = array_merge($settings,array('globalNOTAM' => 'FALSE')); |
|
1124 | + $settings = array_merge($settings, array('globalNOTAM' => 'FALSE')); |
|
1125 | 1125 | } |
1126 | - $owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING); |
|
1126 | + $owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING); |
|
1127 | 1127 | if ($owner == 'owner') { |
1128 | - $settings = array_merge($settings,array('globalOwner' => 'TRUE')); |
|
1128 | + $settings = array_merge($settings, array('globalOwner' => 'TRUE')); |
|
1129 | 1129 | } else { |
1130 | - $settings = array_merge($settings,array('globalOwner' => 'FALSE')); |
|
1130 | + $settings = array_merge($settings, array('globalOwner' => 'FALSE')); |
|
1131 | 1131 | } |
1132 | - $map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING); |
|
1132 | + $map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING); |
|
1133 | 1133 | if ($map3d == 'map3d') { |
1134 | - $settings = array_merge($settings,array('globalMap3D' => 'TRUE')); |
|
1134 | + $settings = array_merge($settings, array('globalMap3D' => 'TRUE')); |
|
1135 | 1135 | } else { |
1136 | - $settings = array_merge($settings,array('globalMap3D' => 'FALSE')); |
|
1136 | + $settings = array_merge($settings, array('globalMap3D' => 'FALSE')); |
|
1137 | 1137 | } |
1138 | - $crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING); |
|
1138 | + $crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING); |
|
1139 | 1139 | if ($crash == 'crash') { |
1140 | - $settings = array_merge($settings,array('globalAccidents' => 'TRUE')); |
|
1140 | + $settings = array_merge($settings, array('globalAccidents' => 'TRUE')); |
|
1141 | 1141 | } else { |
1142 | - $settings = array_merge($settings,array('globalAccidents' => 'FALSE')); |
|
1142 | + $settings = array_merge($settings, array('globalAccidents' => 'FALSE')); |
|
1143 | 1143 | } |
1144 | - $mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING); |
|
1144 | + $mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING); |
|
1145 | 1145 | if ($mapsatellites == 'mapsatellites') { |
1146 | - $settings = array_merge($settings,array('globalMapSatellites' => 'TRUE')); |
|
1146 | + $settings = array_merge($settings, array('globalMapSatellites' => 'TRUE')); |
|
1147 | 1147 | } else { |
1148 | - $settings = array_merge($settings,array('globalMapSatellites' => 'FALSE')); |
|
1148 | + $settings = array_merge($settings, array('globalMapSatellites' => 'FALSE')); |
|
1149 | 1149 | } |
1150 | - $map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING); |
|
1150 | + $map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING); |
|
1151 | 1151 | if ($map3ddefault == 'map3ddefault') { |
1152 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE')); |
|
1152 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE')); |
|
1153 | 1153 | } else { |
1154 | - $settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE')); |
|
1154 | + $settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE')); |
|
1155 | 1155 | } |
1156 | - $translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING); |
|
1156 | + $translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING); |
|
1157 | 1157 | if ($translate == 'translate') { |
1158 | - $settings = array_merge($settings,array('globalTranslate' => 'TRUE')); |
|
1158 | + $settings = array_merge($settings, array('globalTranslate' => 'TRUE')); |
|
1159 | 1159 | } else { |
1160 | - $settings = array_merge($settings,array('globalTranslate' => 'FALSE')); |
|
1160 | + $settings = array_merge($settings, array('globalTranslate' => 'FALSE')); |
|
1161 | 1161 | } |
1162 | - $realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING); |
|
1162 | + $realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING); |
|
1163 | 1163 | if ($realairlines == 'realairlines') { |
1164 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE')); |
|
1164 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE')); |
|
1165 | 1165 | } else { |
1166 | - $settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE')); |
|
1166 | + $settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE')); |
|
1167 | 1167 | } |
1168 | - $estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING); |
|
1168 | + $estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING); |
|
1169 | 1169 | if ($estimation == 'estimation') { |
1170 | - $settings = array_merge($settings,array('globalMapEstimation' => 'TRUE')); |
|
1170 | + $settings = array_merge($settings, array('globalMapEstimation' => 'TRUE')); |
|
1171 | 1171 | } else { |
1172 | - $settings = array_merge($settings,array('globalMapEstimation' => 'FALSE')); |
|
1172 | + $settings = array_merge($settings, array('globalMapEstimation' => 'FALSE')); |
|
1173 | 1173 | } |
1174 | - $metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING); |
|
1174 | + $metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING); |
|
1175 | 1175 | if ($metar == 'metar') { |
1176 | - $settings = array_merge($settings,array('globalMETAR' => 'TRUE')); |
|
1176 | + $settings = array_merge($settings, array('globalMETAR' => 'TRUE')); |
|
1177 | 1177 | } else { |
1178 | - $settings = array_merge($settings,array('globalMETAR' => 'FALSE')); |
|
1178 | + $settings = array_merge($settings, array('globalMETAR' => 'FALSE')); |
|
1179 | 1179 | } |
1180 | - $metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING); |
|
1180 | + $metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING); |
|
1181 | 1181 | if ($metarcycle == 'metarcycle') { |
1182 | - $settings = array_merge($settings,array('globalMETARcycle' => 'TRUE')); |
|
1182 | + $settings = array_merge($settings, array('globalMETARcycle' => 'TRUE')); |
|
1183 | 1183 | } else { |
1184 | - $settings = array_merge($settings,array('globalMETARcycle' => 'FALSE')); |
|
1184 | + $settings = array_merge($settings, array('globalMETARcycle' => 'FALSE')); |
|
1185 | 1185 | } |
1186 | - $fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING); |
|
1186 | + $fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING); |
|
1187 | 1187 | if ($fork == 'fork') { |
1188 | - $settings = array_merge($settings,array('globalFork' => 'TRUE')); |
|
1188 | + $settings = array_merge($settings, array('globalFork' => 'TRUE')); |
|
1189 | 1189 | } else { |
1190 | - $settings = array_merge($settings,array('globalFork' => 'FALSE')); |
|
1190 | + $settings = array_merge($settings, array('globalFork' => 'FALSE')); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | - $colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING); |
|
1193 | + $colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING); |
|
1194 | 1194 | if ($colormap == 'colormap') { |
1195 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE')); |
|
1195 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE')); |
|
1196 | 1196 | } else { |
1197 | - $settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE')); |
|
1197 | + $settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE')); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | if (isset($_POST['aircrafticoncolor'])) { |
1201 | - $aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING); |
|
1202 | - $settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1))); |
|
1201 | + $aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING); |
|
1202 | + $settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1))); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | - $airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT); |
|
1206 | - $settings = array_merge($settings,array('globalAirportZoom' => $airportzoom)); |
|
1205 | + $airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT); |
|
1206 | + $settings = array_merge($settings, array('globalAirportZoom' => $airportzoom)); |
|
1207 | 1207 | |
1208 | - $unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING); |
|
1209 | - $settings = array_merge($settings,array('globalUnitDistance' => $unitdistance)); |
|
1210 | - $unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING); |
|
1211 | - $settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude)); |
|
1212 | - $unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING); |
|
1213 | - $settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed)); |
|
1208 | + $unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING); |
|
1209 | + $settings = array_merge($settings, array('globalUnitDistance' => $unitdistance)); |
|
1210 | + $unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING); |
|
1211 | + $settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude)); |
|
1212 | + $unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING); |
|
1213 | + $settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed)); |
|
1214 | 1214 | |
1215 | - $mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING); |
|
1215 | + $mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING); |
|
1216 | 1216 | if ($mappopup == 'mappopup') { |
1217 | - $settings = array_merge($settings,array('globalMapPopup' => 'TRUE')); |
|
1217 | + $settings = array_merge($settings, array('globalMapPopup' => 'TRUE')); |
|
1218 | 1218 | } else { |
1219 | - $settings = array_merge($settings,array('globalMapPopup' => 'FALSE')); |
|
1219 | + $settings = array_merge($settings, array('globalMapPopup' => 'FALSE')); |
|
1220 | 1220 | } |
1221 | - $airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING); |
|
1221 | + $airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING); |
|
1222 | 1222 | if ($airportpopup == 'airportpopup') { |
1223 | - $settings = array_merge($settings,array('globalAirportPopup' => 'TRUE')); |
|
1223 | + $settings = array_merge($settings, array('globalAirportPopup' => 'TRUE')); |
|
1224 | 1224 | } else { |
1225 | - $settings = array_merge($settings,array('globalAirportPopup' => 'FALSE')); |
|
1225 | + $settings = array_merge($settings, array('globalAirportPopup' => 'FALSE')); |
|
1226 | 1226 | } |
1227 | - $maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING); |
|
1227 | + $maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING); |
|
1228 | 1228 | if ($maphistory == 'maphistory') { |
1229 | - $settings = array_merge($settings,array('globalMapHistory' => 'TRUE')); |
|
1229 | + $settings = array_merge($settings, array('globalMapHistory' => 'TRUE')); |
|
1230 | 1230 | } else { |
1231 | - $settings = array_merge($settings,array('globalMapHistory' => 'FALSE')); |
|
1231 | + $settings = array_merge($settings, array('globalMapHistory' => 'FALSE')); |
|
1232 | 1232 | } |
1233 | - $flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING); |
|
1233 | + $flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING); |
|
1234 | 1234 | if ($flightroute == 'flightroute') { |
1235 | - $settings = array_merge($settings,array('globalMapRoute' => 'TRUE')); |
|
1235 | + $settings = array_merge($settings, array('globalMapRoute' => 'TRUE')); |
|
1236 | 1236 | } else { |
1237 | - $settings = array_merge($settings,array('globalMapRoute' => 'FALSE')); |
|
1237 | + $settings = array_merge($settings, array('globalMapRoute' => 'FALSE')); |
|
1238 | 1238 | } |
1239 | - $allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING); |
|
1239 | + $allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING); |
|
1240 | 1240 | if ($allflights == 'allflights') { |
1241 | - $settings = array_merge($settings,array('globalAllFlights' => 'TRUE')); |
|
1241 | + $settings = array_merge($settings, array('globalAllFlights' => 'TRUE')); |
|
1242 | 1242 | } else { |
1243 | - $settings = array_merge($settings,array('globalAllFlights' => 'FALSE')); |
|
1243 | + $settings = array_merge($settings, array('globalAllFlights' => 'FALSE')); |
|
1244 | 1244 | } |
1245 | - $bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING); |
|
1245 | + $bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING); |
|
1246 | 1246 | if ($bbox == 'bbox') { |
1247 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE')); |
|
1247 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE')); |
|
1248 | 1248 | } else { |
1249 | - $settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE')); |
|
1249 | + $settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE')); |
|
1250 | 1250 | } |
1251 | - $waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING); |
|
1251 | + $waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING); |
|
1252 | 1252 | if ($waypoints == 'waypoints') { |
1253 | - $settings = array_merge($settings,array('globalWaypoints' => 'TRUE')); |
|
1253 | + $settings = array_merge($settings, array('globalWaypoints' => 'TRUE')); |
|
1254 | 1254 | } else { |
1255 | - $settings = array_merge($settings,array('globalWaypoints' => 'FALSE')); |
|
1255 | + $settings = array_merge($settings, array('globalWaypoints' => 'FALSE')); |
|
1256 | 1256 | } |
1257 | - $noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING); |
|
1257 | + $noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING); |
|
1258 | 1258 | if ($noairlines == 'noairlines') { |
1259 | - $settings = array_merge($settings,array('globalNoAirlines' => 'TRUE')); |
|
1259 | + $settings = array_merge($settings, array('globalNoAirlines' => 'TRUE')); |
|
1260 | 1260 | } else { |
1261 | - $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
|
1261 | + $settings = array_merge($settings, array('globalNoAirlines' => 'FALSE')); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1264 | + if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE')); |
|
1265 | 1265 | |
1266 | 1266 | // Set some defaults values... |
1267 | 1267 | if (!isset($globalAircraftImageSources)) { |
1268 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1269 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1268 | + $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
1269 | + $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | if (!isset($globalSchedulesSources)) { |
1273 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1274 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1273 | + $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1274 | + $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | - $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
|
1277 | + $settings = array_merge($settings, array('globalInstalled' => 'TRUE')); |
|
1278 | 1278 | |
1279 | 1279 | if ($error == '') settings::modify_settings($settings); |
1280 | 1280 | if ($error == '') settings::comment_settings($settings_comment); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 39; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver, $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | try { |
154 | 154 | //$Connection = new Connection(); |
155 | 155 | $results = $this->db->query($query); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | - if($results->rowCount()>0) { |
|
159 | + if ($results->rowCount() > 0) { |
|
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | else return false; |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | - } catch(PDOException $e) { |
|
181 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
180 | + } catch (PDOException $e) { |
|
181 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | 182 | throw $e; |
183 | 183 | } |
184 | 184 | //echo 'error ! '.$e->getMessage(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /* |
191 | 191 | * Check if index exist |
192 | 192 | */ |
193 | - public function indexExists($table,$index) |
|
193 | + public function indexExists($table, $index) |
|
194 | 194 | { |
195 | 195 | global $globalDBdriver, $globalDBname; |
196 | 196 | if ($globalDBdriver == 'mysql') { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | try { |
202 | 202 | //$Connection = new Connection(); |
203 | 203 | $results = $this->db->query($query); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
208 | - if($nb[0]['nb'] > 0) { |
|
208 | + if ($nb[0]['nb'] > 0) { |
|
209 | 209 | return true; |
210 | 210 | } |
211 | 211 | else return false; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
221 | 221 | try { |
222 | 222 | $results = $this->db->query($query); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | return "error : ".$e->getMessage()."\n"; |
225 | 225 | } |
226 | 226 | $columns = array(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | return $columns; |
233 | 233 | } |
234 | 234 | |
235 | - public function getColumnType($table,$column) { |
|
235 | + public function getColumnType($table, $column) { |
|
236 | 236 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
237 | 237 | $tomet = $select->getColumnMeta(0); |
238 | 238 | return $tomet['native_type']; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Check if a column name exist in a table |
243 | 243 | * @return Boolean column exist or not |
244 | 244 | */ |
245 | - public function checkColumnName($table,$name) |
|
245 | + public function checkColumnName($table, $name) |
|
246 | 246 | { |
247 | 247 | global $globalDBdriver, $globalDBname; |
248 | 248 | if ($globalDBdriver == 'mysql') { |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | } |
253 | 253 | try { |
254 | 254 | $sth = $this->db()->prepare($query); |
255 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
256 | - } catch(PDOException $e) { |
|
255 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo "error : ".$e->getMessage()."\n"; |
258 | 258 | } |
259 | 259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | try { |
293 | 293 | $sth = $this->db->prepare($query); |
294 | 294 | $sth->execute(); |
295 | - } catch(PDOException $e) { |
|
295 | + } catch (PDOException $e) { |
|
296 | 296 | return "error : ".$e->getMessage()."\n"; |
297 | 297 | } |
298 | 298 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -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 fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | 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 marine_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
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]; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
119 | 119 | } |
120 | 120 | } |
121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
121 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
122 | 122 | |
123 | 123 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
124 | 124 | if ($globalDBdriver == 'mysql') { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } else { |
128 | 128 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
129 | 129 | } |
130 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
130 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
131 | 131 | |
132 | 132 | return $spotter_array; |
133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
144 | 144 | date_default_timezone_set('UTC'); |
145 | 145 | |
146 | - $filter_query = $this->getFilter($filter,true,true); |
|
146 | + $filter_query = $this->getFilter($filter, true, true); |
|
147 | 147 | |
148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | try { |
158 | 158 | $sth = $this->db->prepare($query); |
159 | 159 | $sth->execute(); |
160 | - } catch(PDOException $e) { |
|
160 | + } catch (PDOException $e) { |
|
161 | 161 | echo $e->getMessage(); |
162 | 162 | die; |
163 | 163 | } |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | global $globalDBdriver, $globalLiveInterval; |
178 | 178 | date_default_timezone_set('UTC'); |
179 | 179 | |
180 | - $filter_query = $this->getFilter($filter,true,true); |
|
180 | + $filter_query = $this->getFilter($filter, true, true); |
|
181 | 181 | |
182 | 182 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
183 | 183 | if ($globalDBdriver == 'mysql') { |
184 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
184 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
185 | 185 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
186 | 186 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
187 | 187 | } else { |
188 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
188 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
189 | 189 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
190 | 190 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | try { |
194 | 194 | $sth = $this->db->prepare($query); |
195 | 195 | $sth->execute(); |
196 | - } catch(PDOException $e) { |
|
196 | + } catch (PDOException $e) { |
|
197 | 197 | echo $e->getMessage(); |
198 | 198 | die; |
199 | 199 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | public function getLiveMarineCount($filter = array()) |
211 | 211 | { |
212 | 212 | global $globalDBdriver, $globalLiveInterval; |
213 | - $filter_query = $this->getFilter($filter,true,true); |
|
213 | + $filter_query = $this->getFilter($filter, true, true); |
|
214 | 214 | |
215 | 215 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
216 | 216 | if ($globalDBdriver == 'mysql') { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | 223 | $sth->execute(); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo $e->getMessage(); |
226 | 226 | die; |
227 | 227 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | $filter_query = $this->getFilter($filter); |
245 | 245 | |
246 | 246 | if (is_array($coord)) { |
247 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
248 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
249 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
247 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
248 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
249 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | 251 | } else return array(); |
252 | 252 | if ($globalDBdriver == 'mysql') { |
253 | 253 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | $filter_query = $this->getFilter($filter); |
273 | 273 | |
274 | 274 | if (is_array($coord)) { |
275 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
276 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
277 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
275 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
276 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
277 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | 279 | } else return array(); |
280 | 280 | if ($globalDBdriver == 'mysql') { |
281 | 281 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
282 | 282 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
283 | 283 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
284 | 284 | } else { |
285 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
285 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
286 | 286 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
287 | 287 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
288 | 288 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($interval == '1m') |
332 | 332 | { |
333 | 333 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
334 | - } else if ($interval == '15m'){ |
|
334 | + } else if ($interval == '15m') { |
|
335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
336 | 336 | } |
337 | 337 | } |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
340 | 340 | } |
341 | 341 | |
342 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
342 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
343 | 343 | WHERE marine_live.latitude <> '' |
344 | 344 | AND marine_live.longitude <> '' |
345 | 345 | ".$additional_query." |
346 | 346 | HAVING distance < :radius |
347 | 347 | ORDER BY distance"; |
348 | 348 | |
349 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
349 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
350 | 350 | |
351 | 351 | return $spotter_array; |
352 | 352 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | date_default_timezone_set('UTC'); |
365 | 365 | |
366 | 366 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
367 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
367 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
368 | 368 | |
369 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
369 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
370 | 370 | |
371 | 371 | return $spotter_array; |
372 | 372 | } |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | * @return Array the spotter information |
378 | 378 | * |
379 | 379 | */ |
380 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
380 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
381 | 381 | { |
382 | 382 | $Marine = new Marine($this->db); |
383 | 383 | date_default_timezone_set('UTC'); |
384 | 384 | |
385 | 385 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
386 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
386 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
387 | 387 | |
388 | - $date = date('c',$date); |
|
389 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
388 | + $date = date('c', $date); |
|
389 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
390 | 390 | |
391 | 391 | return $spotter_array; |
392 | 392 | } |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | date_default_timezone_set('UTC'); |
404 | 404 | |
405 | 405 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
407 | 407 | |
408 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
408 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
409 | 409 | |
410 | 410 | return $spotter_array; |
411 | 411 | } |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @return Array the spotter information |
417 | 417 | * |
418 | 418 | */ |
419 | - public function getDateLiveMarineDataById($id,$date) |
|
419 | + public function getDateLiveMarineDataById($id, $date) |
|
420 | 420 | { |
421 | 421 | $Marine = new Marine($this->db); |
422 | 422 | date_default_timezone_set('UTC'); |
423 | 423 | |
424 | 424 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
426 | - $date = date('c',$date); |
|
427 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
426 | + $date = date('c', $date); |
|
427 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
428 | 428 | |
429 | 429 | return $spotter_array; |
430 | 430 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * @return Array the spotter information |
437 | 437 | * |
438 | 438 | */ |
439 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
439 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
440 | 440 | { |
441 | 441 | global $globalDBdriver, $globalLiveInterval; |
442 | 442 | date_default_timezone_set('UTC'); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | try { |
456 | 456 | $sth = $this->db->prepare($query); |
457 | 457 | $sth->execute(array(':id' => $id)); |
458 | - } catch(PDOException $e) { |
|
458 | + } catch (PDOException $e) { |
|
459 | 459 | echo $e->getMessage(); |
460 | 460 | die; |
461 | 461 | } |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | { |
474 | 474 | date_default_timezone_set('UTC'); |
475 | 475 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
476 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
476 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
477 | 477 | try { |
478 | 478 | |
479 | 479 | $sth = $this->db->prepare($query); |
480 | 480 | $sth->execute(array(':ident' => $ident)); |
481 | - } catch(PDOException $e) { |
|
481 | + } catch (PDOException $e) { |
|
482 | 482 | echo $e->getMessage(); |
483 | 483 | die; |
484 | 484 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $sth = $this->db->prepare($query); |
510 | 510 | $sth->execute(); |
511 | - } catch(PDOException $e) { |
|
511 | + } catch (PDOException $e) { |
|
512 | 512 | return "error"; |
513 | 513 | } |
514 | 514 | |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(); |
534 | - } catch(PDOException $e) { |
|
534 | + } catch (PDOException $e) { |
|
535 | 535 | return "error"; |
536 | 536 | } |
537 | 537 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
538 | 538 | $i = 0; |
539 | - $j =0; |
|
539 | + $j = 0; |
|
540 | 540 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
541 | - foreach($all as $row) |
|
541 | + foreach ($all as $row) |
|
542 | 542 | { |
543 | 543 | $i++; |
544 | 544 | $j++; |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | if ($globalDebug) echo "."; |
547 | 547 | try { |
548 | 548 | |
549 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
549 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
550 | 550 | $sth->execute(); |
551 | - } catch(PDOException $e) { |
|
551 | + } catch (PDOException $e) { |
|
552 | 552 | return "error"; |
553 | 553 | } |
554 | 554 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | if ($i > 0) { |
560 | 560 | try { |
561 | 561 | |
562 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
562 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
563 | 563 | $sth->execute(); |
564 | - } catch(PDOException $e) { |
|
564 | + } catch (PDOException $e) { |
|
565 | 565 | return "error"; |
566 | 566 | } |
567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | $sth = $this->db->prepare($query); |
576 | 576 | $sth->execute(); |
577 | - } catch(PDOException $e) { |
|
577 | + } catch (PDOException $e) { |
|
578 | 578 | return "error"; |
579 | 579 | } |
580 | 580 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | public function deleteLiveMarineDataByIdent($ident) |
623 | 623 | { |
624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
625 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
625 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
626 | 626 | |
627 | 627 | try { |
628 | 628 | |
629 | 629 | $sth = $this->db->prepare($query); |
630 | 630 | $sth->execute(array(':ident' => $ident)); |
631 | - } catch(PDOException $e) { |
|
631 | + } catch (PDOException $e) { |
|
632 | 632 | return "error"; |
633 | 633 | } |
634 | 634 | |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | public function deleteLiveMarineDataById($id) |
645 | 645 | { |
646 | 646 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
647 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
647 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
648 | 648 | |
649 | 649 | try { |
650 | 650 | |
651 | 651 | $sth = $this->db->prepare($query); |
652 | 652 | $sth->execute(array(':id' => $id)); |
653 | - } catch(PDOException $e) { |
|
653 | + } catch (PDOException $e) { |
|
654 | 654 | return "error"; |
655 | 655 | } |
656 | 656 | |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | { |
669 | 669 | global $globalDBdriver, $globalTimezone; |
670 | 670 | if ($globalDBdriver == 'mysql') { |
671 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
671 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
672 | 672 | WHERE marine_live.ident = :ident |
673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
674 | 674 | AND marine_live.date < UTC_TIMESTAMP()'; |
675 | 675 | $query_data = array(':ident' => $ident); |
676 | 676 | } else { |
677 | - $query = "SELECT marine_live.ident FROM marine_live |
|
677 | + $query = "SELECT marine_live.ident FROM marine_live |
|
678 | 678 | WHERE marine_live.ident = :ident |
679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
680 | 680 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | |
684 | 684 | $sth = $this->db->prepare($query); |
685 | 685 | $sth->execute($query_data); |
686 | - $ident_result=''; |
|
687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
686 | + $ident_result = ''; |
|
687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
688 | 688 | { |
689 | 689 | $ident_result = $row['ident']; |
690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
701 | 701 | { |
702 | 702 | global $globalDBdriver, $globalTimezone; |
703 | 703 | if ($globalDBdriver == 'mysql') { |
704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
705 | 705 | WHERE marine_live.ident = :ident |
706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
708 | 708 | $query_data = array(':ident' => $ident); |
709 | 709 | } else { |
710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
711 | 711 | WHERE marine_live.ident = :ident |
712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | |
717 | 717 | $sth = $this->db->prepare($query); |
718 | 718 | $sth->execute($query_data); |
719 | - $ident_result=''; |
|
720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
719 | + $ident_result = ''; |
|
720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
721 | 721 | { |
722 | 722 | $ident_result = $row['fammarine_id']; |
723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
737 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
738 | 738 | WHERE marine_live.fammarine_id = :id |
739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
741 | 741 | $query_data = array(':id' => $id); |
742 | 742 | } else { |
743 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
743 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
744 | 744 | WHERE marine_live.fammarine_id = :id |
745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
752 | + $ident_result = ''; |
|
753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
754 | 754 | { |
755 | 755 | $ident_result = $row['fammarine_id']; |
756 | 756 | } |
@@ -767,13 +767,13 @@ discard block |
||
767 | 767 | { |
768 | 768 | global $globalDBdriver, $globalTimezone; |
769 | 769 | if ($globalDBdriver == 'mysql') { |
770 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
770 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
771 | 771 | WHERE marine_live.mmsi = :mmsi |
772 | 772 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
773 | 773 | // AND marine_live.date < UTC_TIMESTAMP()"; |
774 | 774 | $query_data = array(':mmsi' => $mmsi); |
775 | 775 | } else { |
776 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
776 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
777 | 777 | WHERE marine_live.mmsi = :mmsi |
778 | 778 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
779 | 779 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | |
783 | 783 | $sth = $this->db->prepare($query); |
784 | 784 | $sth->execute($query_data); |
785 | - $ident_result=''; |
|
786 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
785 | + $ident_result = ''; |
|
786 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
787 | 787 | { |
788 | 788 | $ident_result = $row['fammarine_id']; |
789 | 789 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @return String success or false |
802 | 802 | * |
803 | 803 | */ |
804 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
804 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
805 | 805 | { |
806 | 806 | global $globalURL, $globalArchive, $globalDebug; |
807 | 807 | $Common = new Common(); |
@@ -853,26 +853,26 @@ discard block |
||
853 | 853 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
854 | 854 | |
855 | 855 | |
856 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
857 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
858 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
859 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
860 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
861 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
862 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
863 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
864 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
865 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
866 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
867 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
868 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
869 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
870 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
871 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
856 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
857 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
858 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
859 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
860 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
861 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
862 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
863 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
864 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
865 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
866 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
867 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
868 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
869 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
870 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
871 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
872 | 872 | |
873 | 873 | |
874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
874 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
875 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
876 | 876 | if ($arrival_date == '') $arrival_date = NULL; |
877 | 877 | $query = ''; |
878 | 878 | if ($globalArchive) { |
@@ -882,18 +882,18 @@ discard block |
||
882 | 882 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
883 | 883 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
884 | 884 | |
885 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
885 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
886 | 886 | try { |
887 | 887 | $sth = $this->db->prepare($query); |
888 | 888 | $sth->execute($query_values); |
889 | - } catch(PDOException $e) { |
|
889 | + } catch (PDOException $e) { |
|
890 | 890 | return "error : ".$e->getMessage(); |
891 | 891 | } |
892 | 892 | |
893 | 893 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
894 | 894 | if ($globalDebug) echo '(Add to Marine archive : '; |
895 | 895 | $MarineArchive = new MarineArchive($this->db); |
896 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
896 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
897 | 897 | if ($globalDebug) echo $result.')'; |
898 | 898 | } |
899 | 899 | return "success"; |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | |
902 | 902 | public function getOrderBy() |
903 | 903 | { |
904 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
904 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
905 | 905 | return $orderby; |
906 | 906 | } |
907 | 907 |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | * @return Array the images list |
18 | 18 | * |
19 | 19 | */ |
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
21 | 21 | { |
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
25 | 25 | $reg = $registration; |
26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
27 | 27 | $reg = trim($reg); |
28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | 29 | FROM spotter_image |
30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
31 | 31 | $sth = $this->db->prepare($query); |
32 | 32 | $sth->execute(array(':registration' => $reg)); |
33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
34 | 34 | if (!empty($result)) return $result; |
35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
36 | 36 | else return array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * @return Array the images list |
43 | 43 | * |
44 | 44 | */ |
45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
46 | 46 | { |
47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
50 | 50 | $name = trim($name); |
51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | 52 | FROM marine_image |
53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
54 | 54 | $query_data = array(':mmsi' => $mmsi); |
55 | 55 | if ($imo != '') { |
56 | 56 | $query .= " AND marine_image.imo = :imo"; |
57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
58 | 58 | } |
59 | 59 | if ($name != '') { |
60 | 60 | $query .= " AND marine_image.name = :name"; |
61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
62 | 62 | } |
63 | 63 | $query .= " LIMIT 1"; |
64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
81 | 81 | if ($copyright != '') { |
82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
83 | - $copyright = str_replace('© ','',$copyright); |
|
84 | - $copyright = str_replace('(c) ','',$copyright); |
|
82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
83 | + $copyright = str_replace('© ', '', $copyright); |
|
84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
85 | 85 | } |
86 | 86 | return $copyright; |
87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * @return String either success or error |
93 | 93 | * |
94 | 94 | */ |
95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
96 | 96 | { |
97 | - global $globalDebug,$globalAircraftImageFetch; |
|
97 | + global $globalDebug, $globalAircraftImageFetch; |
|
98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
100 | 100 | $registration = trim($registration); |
101 | 101 | //getting the aircraft image |
102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
107 | 107 | if ($image_url['original'] != '') { |
108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | 110 | try { |
111 | 111 | $sth = $this->db->prepare($query); |
112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
113 | - } catch(PDOException $e) { |
|
112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | echo $e->getMessage()."\n"; |
115 | 115 | return "error"; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @return String either success or error |
125 | 125 | * |
126 | 126 | */ |
127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
128 | 128 | { |
129 | - global $globalDebug,$globalMarineImageFetch; |
|
129 | + global $globalDebug, $globalMarineImageFetch; |
|
130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
134 | 134 | $name = trim($name); |
135 | 135 | $Marine = new Marine($this->db); |
136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | |
145 | 145 | //getting the aircraft image |
146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
148 | 148 | if ($image_url['original'] != '') { |
149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | 151 | try { |
152 | 152 | $sth = $this->db->prepare($query); |
153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
154 | - } catch(PDOException $e) { |
|
153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
154 | + } catch (PDOException $e) { |
|
155 | 155 | echo $e->getMessage()."\n"; |
156 | 156 | return "error"; |
157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
172 | 172 | $Spotter = new Spotter($this->db); |
173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
175 | 175 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
188 | 188 | else $aircraft_name = ''; |
189 | 189 | $aircraft_registration = $aircraft_icao; |
190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
191 | 191 | unset($Spotter); |
192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
193 | 193 | foreach ($globalAircraftImageSources as $source) { |
194 | 194 | $source = strtolower($source); |
195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
206 | 206 | } |
207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
218 | 218 | * |
219 | 219 | */ |
220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
221 | 221 | { |
222 | 222 | global $globalMarineImageSources; |
223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
224 | 224 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
226 | 226 | $name = trim($name); |
227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
228 | 228 | /* |
229 | 229 | $Marine = new Marine($this->db); |
230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | unset($Marine); |
238 | 238 | */ |
239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
240 | 240 | foreach ($globalMarineImageSources as $source) { |
241 | 241 | $source = strtolower($source); |
242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
248 | 248 | } |
249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
258 | 258 | * |
259 | 259 | */ |
260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
261 | 261 | $Common = new Common(); |
262 | 262 | // If aircraft registration is only number, also check with aircraft model |
263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
265 | 265 | } else { |
266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | 268 | } |
269 | 269 | $data = $Common->getData($url); |
270 | 270 | if ($xml = simplexml_load_string($data)) { |
271 | 271 | if (isset($xml->channel->item)) { |
272 | 272 | $image_url = array(); |
273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
278 | 278 | $image_url['source'] = 'planespotters'; |
279 | 279 | return $image_url; |
280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
291 | 291 | * |
292 | 292 | */ |
293 | - public function fromDeviantart($type,$registration, $name='') { |
|
293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
294 | 294 | $Common = new Common(); |
295 | 295 | if ($type == 'aircraft') { |
296 | 296 | // If aircraft registration is only number, also check with aircraft model |
297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | 299 | } else { |
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
301 | 301 | } |
302 | 302 | } elseif ($type == 'marine') { |
303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $data = $Common->getData($url); |
307 | 307 | if ($xml = simplexml_load_string($data)) { |
308 | 308 | if (isset($xml->channel->item->link)) { |
309 | 309 | $image_url = array(); |
310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
313 | 313 | $image_url['original'] = $original_url; |
314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
316 | 316 | $image_url['source'] = 'deviantart'; |
317 | 317 | return $image_url; |
318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
329 | 329 | * |
330 | 330 | */ |
331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
332 | 332 | $Common = new Common(); |
333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
334 | 334 | $data = $Common->getData($url); |
335 | 335 | $dom = new DOMDocument(); |
336 | 336 | @$dom->loadHTML($data); |
337 | 337 | $all_pics = array(); |
338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
340 | 340 | $all_pics[] = $image->getAttribute('src'); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | $all_authors = array(); |
344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
346 | 346 | $all_authors[] = $author->getAttribute('content'); |
347 | 347 | } |
348 | 348 | } |
349 | 349 | $all_ref = array(); |
350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
351 | 351 | $all_ref[] = $link->getAttribute('href'); |
352 | 352 | } |
353 | 353 | if (isset($all_pics[0])) { |
354 | 354 | $image_url = array(); |
355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
357 | 357 | $image_url['copyright'] = $all_authors[0]; |
358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
371 | 371 | * |
372 | 372 | */ |
373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
374 | 374 | $Common = new Common(); |
375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
376 | 376 | $data = $Common->getData($url); |
377 | 377 | $dom = new DOMDocument(); |
378 | 378 | @$dom->loadHTML($data); |
379 | 379 | $all_pics = array(); |
380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
381 | 381 | $all_pics[] = $image->getAttribute('src'); |
382 | 382 | } |
383 | 383 | $all_links = array(); |
384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
386 | 386 | } |
387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
388 | 388 | $image_url = array(); |
389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
405 | 405 | * |
406 | 406 | */ |
407 | - public function fromFlickr($type,$registration,$name='') { |
|
407 | + public function fromFlickr($type, $registration, $name = '') { |
|
408 | 408 | $Common = new Common(); |
409 | 409 | if ($type == 'aircraft') { |
410 | 410 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $data = $Common->getData($url); |
417 | 417 | if ($xml = simplexml_load_string($data)) { |
418 | 418 | if (isset($xml->channel->item)) { |
419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
420 | 420 | $image_url = array(); |
421 | 421 | $image_url['thumbnail'] = $original_url; |
422 | 422 | $image_url['original'] = $original_url; |
423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
425 | 425 | $image_url['source'] = 'flickr'; |
426 | 426 | return $image_url; |
427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
433 | 433 | $Common = new Common(); |
434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
454 | 454 | * |
455 | 455 | */ |
456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
457 | 457 | global $globalImageBingKey; |
458 | 458 | $Common = new Common(); |
459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
465 | 465 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
466 | 466 | } |
467 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
468 | - $data = $Common->getData($url,'get','',$headers); |
|
467 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
468 | + $data = $Common->getData($url, 'get', '', $headers); |
|
469 | 469 | $result = json_decode($data); |
470 | 470 | if (isset($result->d->results[0]->MediaUrl)) { |
471 | 471 | $image_url = array(); |
@@ -490,14 +490,14 @@ discard block |
||
490 | 490 | * @return Array the aircraft thumbnail, orignal url and copyright |
491 | 491 | * |
492 | 492 | */ |
493 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
493 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
494 | 494 | $Common = new Common(); |
495 | 495 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
496 | 496 | $data = $Common->getData($url); |
497 | 497 | $result = json_decode($data); |
498 | 498 | if (isset($result->count) && $result->count > 0) { |
499 | 499 | $image_url = array(); |
500 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
500 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
501 | 501 | $image_url['source_website'] = $result->data[0]->link; |
502 | 502 | $image_url['thumbnail'] = $result->data[0]->image; |
503 | 503 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return Array the aircraft thumbnail, orignal url and copyright |
516 | 516 | * |
517 | 517 | */ |
518 | - public function fromWikimedia($type,$registration,$name='') { |
|
518 | + public function fromWikimedia($type, $registration, $name = '') { |
|
519 | 519 | $Common = new Common(); |
520 | 520 | if ($type == 'aircraft') { |
521 | 521 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | $result = json_decode($data); |
529 | 529 | if (isset($result->query->search[0]->title)) { |
530 | 530 | $fileo = $result->query->search[0]->title; |
531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
531 | + if (substr($fileo, -3) == 'pdf') return false; |
|
532 | 532 | $file = urlencode($fileo); |
533 | 533 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
534 | 534 | $data2 = $Common->getData($url2); |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | if (isset($result2->query->pages)) { |
554 | 554 | foreach ($result2->query->pages as $page) { |
555 | 555 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
556 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
556 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
557 | 557 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
558 | 558 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
559 | 559 | } |
560 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
560 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
561 | 561 | return $image_url; |
562 | 562 | } |
563 | 563 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return Array the aircraft thumbnail, orignal url and copyright |
577 | 577 | * |
578 | 578 | */ |
579 | - public function fromCustomSource($type,$registration,$name='') { |
|
579 | + public function fromCustomSource($type, $registration, $name = '') { |
|
580 | 580 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
581 | 581 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
582 | 582 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | print_r($source); |
594 | 594 | print_r($customsources); |
595 | 595 | } |
596 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
597 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
596 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
597 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
598 | 598 | if ($Common->urlexist($url)) { |
599 | 599 | $image_url = array(); |
600 | 600 | $image_url['thumbnail'] = $url_thumbnail; |
601 | 601 | $image_url['original'] = $url; |
602 | 602 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
603 | 603 | else $exifCopyright = ''; |
604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
604 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
605 | 605 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
606 | 606 | else $image_url['copyright'] = $source['source_website']; |
607 | 607 | $image_url['source_website'] = $source['source_website']; |
@@ -625,19 +625,19 @@ discard block |
||
625 | 625 | print_r($source); |
626 | 626 | print_r($customsources); |
627 | 627 | } |
628 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
629 | - $url = str_replace('{mmsi}',$registration,$url); |
|
630 | - $url = str_replace('{name}',$name,$url); |
|
631 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
632 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
633 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
628 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
629 | + $url = str_replace('{mmsi}', $registration, $url); |
|
630 | + $url = str_replace('{name}', $name, $url); |
|
631 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
632 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
633 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
634 | 634 | if ($Common->urlexist($url)) { |
635 | 635 | $image_url = array(); |
636 | 636 | $image_url['thumbnail'] = $url_thumbnail; |
637 | 637 | $image_url['original'] = $url; |
638 | 638 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
639 | 639 | else $exifCopyright = ''; |
640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
640 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
641 | 641 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
642 | 642 | else $image_url['copyright'] = $source['source_website']; |
643 | 643 | $image_url['source_website'] = $source['source_website']; |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,20 +385,20 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
398 | - $seq = (int)$pcs[2]; // get sequence |
|
397 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
398 | + $seq = (int) $pcs[2]; // get sequence |
|
399 | 399 | // get msg sequence id |
400 | 400 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
401 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
402 | 402 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 403 | // message sequence checking |
404 | 404 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | - $filler += (int)$pcs[6][0]; // get filler |
|
434 | + $filler += (int) $pcs[6][0]; // get filler |
|
435 | 435 | if ($num_seq == 1 // valid single message |
436 | 436 | || $num_seq == $pseq // valid multi-part message |
437 | 437 | ) { |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | $cbuf = $cbuf.$ibuf; |
452 | 452 | $last_pos = 0; |
453 | 453 | $result = new stdClass(); |
454 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
454 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
455 | 455 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
456 | 456 | //DEBUG echo $cbuf; |
457 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
457 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
458 | 458 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
459 | 459 | //DEBUG echo "[$start $end $tst]\n"; |
460 | - $result = $this->process_ais_raw( $tst, "" ); |
|
460 | + $result = $this->process_ais_raw($tst, ""); |
|
461 | 461 | $last_pos = $end + 1; |
462 | 462 | } else break; |
463 | 463 | } |
@@ -469,41 +469,41 @@ discard block |
||
469 | 469 | // incoming data from serial or IP comms |
470 | 470 | public function process_ais_line($cbuf) { |
471 | 471 | $result = new stdClass(); |
472 | - $start = strpos($cbuf,"VDM"); |
|
472 | + $start = strpos($cbuf, "VDM"); |
|
473 | 473 | $tst = substr($cbuf, $start - 3); |
474 | - $result = $this->process_ais_raw( $tst, "" ); |
|
474 | + $result = $this->process_ais_raw($tst, ""); |
|
475 | 475 | return $result; |
476 | 476 | } |
477 | 477 | |
478 | 478 | /* AIS Encoding |
479 | 479 | */ |
480 | - private function mk_ais_lat( $lat ) { |
|
480 | + private function mk_ais_lat($lat) { |
|
481 | 481 | //$lat = 1.2569; |
482 | - if ($lat<0.0) { |
|
482 | + if ($lat < 0.0) { |
|
483 | 483 | $lat = -$lat; |
484 | - $neg=true; |
|
485 | - } else $neg=false; |
|
484 | + $neg = true; |
|
485 | + } else $neg = false; |
|
486 | 486 | $latd = 0x00000000; |
487 | - $latd = intval ($lat * 600000.0); |
|
488 | - if ($neg==true) { |
|
487 | + $latd = intval($lat*600000.0); |
|
488 | + if ($neg == true) { |
|
489 | 489 | $latd = ~$latd; |
490 | - $latd+=1; |
|
490 | + $latd += 1; |
|
491 | 491 | $latd &= 0x07FFFFFF; |
492 | 492 | } |
493 | 493 | return $latd; |
494 | 494 | } |
495 | 495 | |
496 | - private function mk_ais_lon( $lon ) { |
|
496 | + private function mk_ais_lon($lon) { |
|
497 | 497 | //$lon = 103.851; |
498 | - if ($lon<0.0) { |
|
498 | + if ($lon < 0.0) { |
|
499 | 499 | $lon = -$lon; |
500 | - $neg=true; |
|
501 | - } else $neg=false; |
|
500 | + $neg = true; |
|
501 | + } else $neg = false; |
|
502 | 502 | $lond = 0x00000000; |
503 | - $lond = intval ($lon * 600000.0); |
|
504 | - if ($neg==true) { |
|
503 | + $lond = intval($lon*600000.0); |
|
504 | + if ($neg == true) { |
|
505 | 505 | $lond = ~$lond; |
506 | - $lond+=1; |
|
506 | + $lond += 1; |
|
507 | 507 | $lond &= 0x0FFFFFFF; |
508 | 508 | } |
509 | 509 | return $lond; |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | |
512 | 512 | private function char2bin($name, $max_len) { |
513 | 513 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
514 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
515 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
@@ -529,26 +529,26 @@ discard block |
||
529 | 529 | if ($_a) foreach ($_a as $_1) { |
530 | 530 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | 531 | else $dec = 0; |
532 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
532 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
533 | 533 | $rv .= $bin; |
534 | 534 | //echo "$_1 $dec ($bin)<br/>"; |
535 | 535 | } |
536 | 536 | return $rv.$pad; |
537 | 537 | } |
538 | 538 | |
539 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
539 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
540 | 540 | $len_bit = strlen($_enc); |
541 | - $rem6 = $len_bit % 6; |
|
541 | + $rem6 = $len_bit%6; |
|
542 | 542 | $pad6_len = 0; |
543 | 543 | if ($rem6) $pad6_len = 6 - $rem6; |
544 | 544 | //echo $pad6_len.'<br>'; |
545 | 545 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | - $len_enc = strlen($_enc) / 6; |
|
546 | + $len_enc = strlen($_enc)/6; |
|
547 | 547 | //echo $_enc.' '.$len_enc.'<br/>'; |
548 | 548 | $itu = ''; |
549 | - for ($i=0; $i<$len_enc; $i++) { |
|
550 | - $offset = $i * 6; |
|
551 | - $dec = bindec(substr($_enc,$offset,6)); |
|
549 | + for ($i = 0; $i < $len_enc; $i++) { |
|
550 | + $offset = $i*6; |
|
551 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
552 | 552 | if ($dec < 40) $dec += 48; |
553 | 553 | else $dec += 56; |
554 | 554 | //echo chr($dec)." $dec<br/>"; |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | $chksum = 0; |
559 | 559 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
560 | 560 | $len_itu = strlen($itu); |
561 | - for ($i=0; $i<$len_itu; $i++) { |
|
562 | - $chksum ^= ord( $itu[$i] ); |
|
561 | + for ($i = 0; $i < $len_itu; $i++) { |
|
562 | + $chksum ^= ord($itu[$i]); |
|
563 | 563 | } |
564 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
565 | - $lsb = $chksum & 0x0F; |
|
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
564 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
565 | + $lsb = $chksum&0x0F; |
|
566 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
567 | 567 | else $lsbc = '0'; |
568 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
568 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
569 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
570 | 570 | else $msbc = '0'; |
571 | 571 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 572 | return $itu; |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | |
592 | 592 | public function mmsitype($mmsi) { |
593 | 593 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
594 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
600 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
601 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
602 | 602 | else return 'Ship'; |
603 | 603 | } |
604 | 604 | |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | global $globalDebug; |
610 | 610 | $result = array(); |
611 | 611 | $data = new stdClass(); |
612 | - $start = strpos($buffer,"VDM"); |
|
612 | + $start = strpos($buffer, "VDM"); |
|
613 | 613 | $tst = substr($buffer, $start - 3); |
614 | - $data = $this->process_ais_raw( $tst, "" ); |
|
614 | + $data = $this->process_ais_raw($tst, ""); |
|
615 | 615 | if (!is_object($data)) { |
616 | 616 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 617 | return array(); |
618 | 618 | } |
619 | 619 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
620 | 620 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
621 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
621 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
622 | 622 | $result['timestamp'] = $data->ts; |
623 | 623 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
624 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
625 | 625 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | 626 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
627 | 627 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | if ($data->type !== '') $result['type'] = $data->type; |
632 | 632 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
633 | 633 | if ($data->imo !== '') $result['imo'] = $data->imo; |
634 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
634 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
635 | 635 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
636 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
636 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
637 | 637 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
638 | 638 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
639 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
639 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
640 | 640 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
641 | 641 | } |
642 | 642 | if ($data->destination != '') { |
643 | - $dest = trim(str_replace('@','',$data->destination)); |
|
643 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
644 | 644 | if ($dest != '') $result['destination'] = $dest; |
645 | 645 | } |
646 | 646 | $result['all'] = (array) $data; |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING); |
|
5 | +if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
6 | 6 | if ($ident != '') |
7 | 7 | { |
8 | 8 | if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |